Add API for PPPoE clients statistic retrieval 59/63859/3
authorOleksandr Naumets <oleksandrx.naumets@intel.com>
Mon, 22 Oct 2018 06:59:52 +0000 (07:59 +0100)
committerOleksandr Naumets <oleksandrx.naumets@intel.com>
Mon, 5 Nov 2018 12:16:25 +0000 (12:16 +0000)
Add IxNextgen API for PPPoE clients per port statistics retrieval.

JIRA: YARDSTICK-1480

Change-Id: Ic22cf4a085ad957891575e9728584aee939a6630
Signed-off-by: Oleksandr Naumets <oleksandrx.naumets@intel.com>
yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py

index 556682b..631abec 100644 (file)
@@ -69,6 +69,7 @@ class IxNextgen(object):  # pragma: no cover
 
     PORT_STATS_NAME_MAP = {
         "stat_name": 'Stat Name',
+        "port_name": 'Port Name',
         "Frames_Tx": 'Frames Tx.',
         "Valid_Frames_Rx": 'Valid Frames Rx.',
         "Frames_Tx_Rate": 'Frames Tx. Rate',
@@ -85,6 +86,18 @@ class IxNextgen(object):  # pragma: no cover
         "Store-Forward_Max_latency_ns": 'Store-Forward Max Latency (ns)',
     }
 
+    PPPOX_CLIENT_PER_PORT_NAME_MAP = {
+        'subs_port': 'Port',
+        'Sessions_Up': 'Sessions Up',
+        'Sessions_Down': 'Sessions Down',
+        'Sessions_Not_Started': 'Sessions Not Started',
+        'Sessions_Total': 'Sessions Total'
+    }
+
+    PORT_STATISTICS = '::ixNet::OBJ-/statistics/view:"Port Statistics"'
+    FLOW_STATISTICS = '::ixNet::OBJ-/statistics/view:"Flow Statistics"'
+    PPPOX_CLIENT_PER_PORT = '::ixNet::OBJ-/statistics/view:"PPPoX Client Per Port"'
+
     @staticmethod
     def get_config(tg_cfg):
         card = []
@@ -681,12 +694,30 @@ class IxNextgen(object):  # pragma: no cover
         :return: dictionary with the statistics; the keys of this dictionary
                  are PORT_STATS_NAME_MAP and LATENCY_NAME_MAP keys.
         """
-        port_statistics = '::ixNet::OBJ-/statistics/view:"Port Statistics"'
-        flow_statistics = '::ixNet::OBJ-/statistics/view:"Flow Statistics"'
-        stats = self._build_stats_map(port_statistics,
+        stats = self._build_stats_map(self.PORT_STATISTICS,
+                                      self.PORT_STATS_NAME_MAP)
+        stats.update(self._build_stats_map(self.FLOW_STATISTICS,
+                                           self.LATENCY_NAME_MAP))
+        return stats
+
+    def get_pppoe_scenario_statistics(self):
+        """Retrieve port, flow and PPPoE subscribers statistics
+
+        "Port Statistics" parameters are stored in self.PORT_STATS_NAME_MAP.
+        "Flow Statistics" parameters are stored in self.LATENCY_NAME_MAP.
+        "PPPoX Client Per Port" parameters are stored in
+        self.PPPOE_CLIENT_PER_PORT_NAME_MAP
+
+        :return: dictionary with the statistics; the keys of this dictionary
+                 are PORT_STATS_NAME_MAP, LATENCY_NAME_MAP and
+                 PPPOE_CLIENT_PER_PORT_NAME_MAP keys.
+        """
+        stats = self._build_stats_map(self.PORT_STATISTICS,
                                       self.PORT_STATS_NAME_MAP)
-        stats.update(self._build_stats_map(flow_statistics,
-                                          self.LATENCY_NAME_MAP))
+        stats.update(self._build_stats_map(self.FLOW_STATISTICS,
+                                           self.LATENCY_NAME_MAP))
+        stats.update(self._build_stats_map(self.PPPOX_CLIENT_PER_PORT,
+                                           self.PPPOX_CLIENT_PER_PORT_NAME_MAP))
         return stats
 
     def start_protocols(self):
index c80cbbe..bea0cf1 100644 (file)
@@ -582,15 +582,15 @@ class TestIxNextgen(unittest.TestCase):
                 self.ixnet_gen.update_frame(TRAFFIC_PARAMETERS, 40)
 
     def test_get_statistics(self):
-        port_statistics = '::ixNet::OBJ-/statistics/view:"Port Statistics"'
-        flow_statistics = '::ixNet::OBJ-/statistics/view:"Flow Statistics"'
         with mock.patch.object(self.ixnet_gen, '_build_stats_map') as \
                 mock_build_stats:
             self.ixnet_gen.get_statistics()
 
         mock_build_stats.assert_has_calls([
-            mock.call(port_statistics, self.ixnet_gen.PORT_STATS_NAME_MAP),
-            mock.call(flow_statistics, self.ixnet_gen.LATENCY_NAME_MAP)])
+            mock.call(self.ixnet_gen.PORT_STATISTICS,
+                      self.ixnet_gen.PORT_STATS_NAME_MAP),
+            mock.call(self.ixnet_gen.FLOW_STATISTICS,
+                      self.ixnet_gen.LATENCY_NAME_MAP)])
 
     def test__set_flow_tracking(self):
         self.ixnet_gen._ixnet.getList.return_value = ['traffic_item']
@@ -612,6 +612,18 @@ class TestIxNextgen(unittest.TestCase):
             'encapsulation', '-offset', 'IPv4 TOS Precedence')
         self.assertEqual(self.ixnet.commit.call_count, 2)
 
+    def test_get_pppoe_scenario_statistics(self):
+        with mock.patch.object(self.ixnet_gen, '_build_stats_map') as \
+                mock_build_stats:
+            self.ixnet_gen.get_pppoe_scenario_statistics()
+
+        mock_build_stats.assert_any_call(self.ixnet_gen.PORT_STATISTICS,
+                                         self.ixnet_gen.PORT_STATS_NAME_MAP)
+        mock_build_stats.assert_any_call(self.ixnet_gen.FLOW_STATISTICS,
+                                         self.ixnet_gen.LATENCY_NAME_MAP)
+        mock_build_stats.assert_any_call(self.ixnet_gen.PPPOX_CLIENT_PER_PORT,
+                                         self.ixnet_gen.PPPOX_CLIENT_PER_PORT_NAME_MAP)
+
     def test__update_ipv4_address(self):
         with mock.patch.object(self.ixnet_gen, '_get_field_in_stack_item',
                                return_value='field_desc'):