Exemple #1
0
    def test__run_traffic_once(self):
        mock_setup_helper = mock.Mock()
        mock_traffic_profile = mock.Mock()
        vpp_rfc = tg_trex_vpp.TrexVppResourceHelper(mock_setup_helper)
        vpp_rfc.TRANSIENT_PERIOD = 0
        vpp_rfc.rfc2544_helper = mock.Mock()

        self.assertTrue(vpp_rfc._run_traffic_once(mock_traffic_profile))
        mock_traffic_profile.execute_traffic.assert_called_once_with(vpp_rfc)
Exemple #2
0
 def test_run_traffic(self):
     mock_traffic_profile = mock.Mock(autospec=tp_base.TrafficProfile)
     mock_traffic_profile.get_traffic_definition.return_value = "64"
     mock_traffic_profile.params = self.TRAFFIC_PROFILE
     mock_setup_helper = mock.Mock()
     vpp_rfc = tg_trex_vpp.TrexVppResourceHelper(mock_setup_helper)
     vpp_rfc.ssh_helper = mock.Mock()
     vpp_rfc.ssh_helper.run = mock.Mock()
     vpp_rfc._traffic_runner = mock.Mock(return_value=0)
     vpp_rfc._build_ports = mock.Mock()
     vpp_rfc._connect = mock.Mock()
     vpp_rfc.run_traffic(mock_traffic_profile)
Exemple #3
0
 def test_send_traffic_on_tg_error(self):
     mock_setup_helper = mock.Mock()
     vpp_rfc = tg_trex_vpp.TrexVppResourceHelper(mock_setup_helper)
     vpp_rfc.vnfd_helper = base.VnfdHelper(TestTrexTrafficGenVpp.VNFD_0)
     vpp_rfc.client = mock.Mock()
     vpp_rfc.client.get_warnings.return_value = 'get_warnings'
     vpp_rfc.client.get_stats.side_effect = STLError('get_stats')
     vpp_rfc.client.wait_on_traffic.side_effect = STLError(
         'wait_on_traffic')
     port_pg_id = rfc2544.PortPgIDMap()
     port_pg_id.add_port(1)
     port_pg_id.increase_pg_id()
     port_pg_id.add_port(0)
     port_pg_id.increase_pg_id()
     # with self.assertRaises(RuntimeError) as raised:
     vpp_rfc.send_traffic_on_tg([0, 1], port_pg_id, 30, 10000, True)
Exemple #4
0
 def test_send_traffic_on_tg(self):
     stats = {
         0: {
             "ibytes": 55549120,
             "ierrors": 0,
             "ipackets": 867955,
             "obytes": 55549696,
             "oerrors": 0,
             "opackets": 867964,
             "rx_bps": 104339032.0,
             "rx_bps_L1": 136944984.0,
             "rx_pps": 203787.2,
             "rx_util": 1.36944984,
             "tx_bps": 134126008.0,
             "tx_bps_L1": 176040392.0,
             "tx_pps": 261964.9,
             "tx_util": 1.7604039200000001
         },
         1: {
             "ibytes": 55549696,
             "ierrors": 0,
             "ipackets": 867964,
             "obytes": 55549120,
             "oerrors": 0,
             "opackets": 867955,
             "rx_bps": 134119648.0,
             "rx_bps_L1": 176032032.0,
             "rx_pps": 261952.4,
             "rx_util": 1.76032032,
             "tx_bps": 104338192.0,
             "tx_bps_L1": 136943872.0,
             "tx_pps": 203785.5,
             "tx_util": 1.36943872
         },
         "flow_stats": {
             1: {
                 "rx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "rx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "rx_bytes": {
                     "0": 6400,
                     "1": 0,
                     "total": 6400
                 },
                 "rx_pkts": {
                     "0": 100,
                     "1": 0,
                     "total": 100
                 },
                 "rx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "tx_bytes": {
                     "0": 0,
                     "1": 6400,
                     "total": 6400
                 },
                 "tx_pkts": {
                     "0": 0,
                     "1": 100,
                     "total": 100
                 },
                 "tx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 }
             },
             2: {
                 "rx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "rx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "rx_bytes": {
                     "0": 0,
                     "1": 6464,
                     "total": 6464
                 },
                 "rx_pkts": {
                     "0": 0,
                     "1": 101,
                     "total": 101
                 },
                 "rx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "tx_bytes": {
                     "0": 6464,
                     "1": 0,
                     "total": 6464
                 },
                 "tx_pkts": {
                     "0": 101,
                     "1": 0,
                     "total": 101
                 },
                 "tx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 }
             },
             "global": {
                 "rx_err": {
                     "0": 0,
                     "1": 0
                 },
                 "tx_err": {
                     "0": 0,
                     "1": 0
                 }
             }
         },
         "global": {
             "bw_per_core": 45.6,
             "cpu_util": 0.1494,
             "queue_full": 0,
             "rx_bps": 238458672.0,
             "rx_cpu_util": 4.751e-05,
             "rx_drop_bps": 0.0,
             "rx_pps": 465739.6,
             "tx_bps": 238464208.0,
             "tx_pps": 465750.4
         },
         "latency": {
             1: {
                 "err_cntrs": {
                     "dropped": 0,
                     "dup": 0,
                     "out_of_order": 0,
                     "seq_too_high": 0,
                     "seq_too_low": 0
                 },
                 "latency": {
                     "average": 63.375,
                     "histogram": {
                         "20": 1,
                         "30": 18,
                         "40": 12,
                         "50": 10,
                         "60": 12,
                         "70": 11,
                         "80": 6,
                         "90": 10,
                         "100": 20
                     },
                     "jitter": 23,
                     "last_max": 122,
                     "total_max": 123,
                     "total_min": 20
                 }
             },
             2: {
                 "err_cntrs": {
                     "dropped": 0,
                     "dup": 0,
                     "out_of_order": 0,
                     "seq_too_high": 0,
                     "seq_too_low": 0
                 },
                 "latency": {
                     "average": 74,
                     "histogram": {
                         "60": 20,
                         "70": 10,
                         "80": 3,
                         "90": 4,
                         "100": 64
                     },
                     "jitter": 6,
                     "last_max": 83,
                     "total_max": 135,
                     "total_min": 60
                 }
             },
             "global": {
                 "bad_hdr": 0,
                 "old_flow": 0
             }
         },
         "total": {
             "ibytes": 111098816,
             "ierrors": 0,
             "ipackets": 1735919,
             "obytes": 111098816,
             "oerrors": 0,
             "opackets": 1735919,
             "rx_bps": 238458680.0,
             "rx_bps_L1": 312977016.0,
             "rx_pps": 465739.6,
             "rx_util": 3.1297701599999996,
             "tx_bps": 238464200.0,
             "tx_bps_L1": 312984264.0,
             "tx_pps": 465750.4,
             "tx_util": 3.12984264
         }
     }
     mock_setup_helper = mock.Mock()
     vpp_rfc = tg_trex_vpp.TrexVppResourceHelper(mock_setup_helper)
     vpp_rfc.vnfd_helper = base.VnfdHelper(TestTrexTrafficGenVpp.VNFD_0)
     vpp_rfc.client = mock.Mock()
     vpp_rfc.client.get_warnings.return_value = 'get_warnings'
     vpp_rfc.client.get_stats.return_value = stats
     port_pg_id = rfc2544.PortPgIDMap()
     port_pg_id.add_port(1)
     port_pg_id.increase_pg_id()
     port_pg_id.add_port(0)
     port_pg_id.increase_pg_id()
     self.assertEqual(
         stats,
         vpp_rfc.send_traffic_on_tg([0, 1], port_pg_id, 30, 10000, True))
Exemple #5
0
 def test_fmt_latency_error(self):
     mock_setup_helper = mock.Mock()
     vpp_rfc = tg_trex_vpp.TrexVppResourceHelper(mock_setup_helper)
     self.assertEqual('-1/-1/-1', vpp_rfc.fmt_latency('err', 'err', 'err'))
Exemple #6
0
 def test_fmt_latency(self):
     mock_setup_helper = mock.Mock()
     vpp_rfc = tg_trex_vpp.TrexVppResourceHelper(mock_setup_helper)
     self.assertEqual('10/90/489', vpp_rfc.fmt_latency(10, 90, 489))
Exemple #7
0
 def test_generate_samples_error(self):
     stats = {
         0: {
             "ibytes": 55549120,
             "ierrors": 0,
             "ipackets": 867955,
             "obytes": 55549696,
             "oerrors": 0,
             "opackets": 867964,
             "rx_bps": 104339032.0,
             "rx_bps_L1": 136944984.0,
             "rx_pps": 203787.2,
             "rx_util": 1.36944984,
             "tx_bps": 134126008.0,
             "tx_bps_L1": 176040392.0,
             "tx_pps": 261964.9,
             "tx_util": 1.7604039200000001
         },
         1: {
             "ibytes": 55549696,
             "ierrors": 0,
             "ipackets": 867964,
             "obytes": 55549120,
             "oerrors": 0,
             "opackets": 867955,
             "rx_bps": 134119648.0,
             "rx_bps_L1": 176032032.0,
             "rx_pps": 261952.4,
             "rx_util": 1.76032032,
             "tx_bps": 104338192.0,
             "tx_bps_L1": 136943872.0,
             "tx_pps": 203785.5,
             "tx_util": 1.36943872
         },
         "flow_stats": {
             1: {
                 "rx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "rx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "rx_bytes": {
                     "0": 6400,
                     "1": 0,
                     "total": 6400
                 },
                 "rx_pkts": {
                     "0": 100,
                     "1": 0,
                     "total": 100
                 },
                 "rx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "tx_bytes": {
                     "0": 0,
                     "1": 6400,
                     "total": 6400
                 },
                 "tx_pkts": {
                     "0": 0,
                     "1": 100,
                     "total": 100
                 },
                 "tx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 }
             },
             2: {
                 "rx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "rx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "rx_bytes": {
                     "0": 0,
                     "1": 6464,
                     "total": 6464
                 },
                 "rx_pkts": {
                     "0": 0,
                     "1": 101,
                     "total": 101
                 },
                 "rx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 },
                 "tx_bps_l1": {
                     "0": 0.0,
                     "1": 0.0,
                     "total": 0.0
                 },
                 "tx_bytes": {
                     "0": 6464,
                     "1": 0,
                     "total": 6464
                 },
                 "tx_pkts": {
                     "0": 101,
                     "1": 0,
                     "total": 101
                 },
                 "tx_pps": {
                     "0": 0,
                     "1": 0,
                     "total": 0
                 }
             },
             "global": {
                 "rx_err": {
                     "0": 0,
                     "1": 0
                 },
                 "tx_err": {
                     "0": 0,
                     "1": 0
                 }
             }
         },
         "global": {
             "bw_per_core": 45.6,
             "cpu_util": 0.1494,
             "queue_full": 0,
             "rx_bps": 238458672.0,
             "rx_cpu_util": 4.751e-05,
             "rx_drop_bps": 0.0,
             "rx_pps": 465739.6,
             "tx_bps": 238464208.0,
             "tx_pps": 465750.4
         },
         "latency": {
             1: {
                 "err_cntrs": {
                     "dropped": 0,
                     "dup": 0,
                     "out_of_order": 0,
                     "seq_too_high": 0,
                     "seq_too_low": 0
                 },
                 "latency": {
                     "average": "err",
                     "histogram": {
                         "20": 1,
                         "30": 18,
                         "40": 12,
                         "50": 10,
                         "60": 12,
                         "70": 11,
                         "80": 6,
                         "90": 10,
                         "100": 20
                     },
                     "jitter": 23,
                     "last_max": 122,
                     "total_max": "err",
                     "total_min": "err"
                 }
             },
             2: {
                 "err_cntrs": {
                     "dropped": 0,
                     "dup": 0,
                     "out_of_order": 0,
                     "seq_too_high": 0,
                     "seq_too_low": 0
                 },
                 "latency": {
                     "average": 74,
                     "histogram": {
                         "60": 20,
                         "70": 10,
                         "80": 3,
                         "90": 4,
                         "100": 64
                     },
                     "jitter": 6,
                     "last_max": 83,
                     "total_max": 135,
                     "total_min": 60
                 }
             },
             "global": {
                 "bad_hdr": 0,
                 "old_flow": 0
             }
         },
         "total": {
             "ibytes": 111098816,
             "ierrors": 0,
             "ipackets": 1735919,
             "obytes": 111098816,
             "oerrors": 0,
             "opackets": 1735919,
             "rx_bps": 238458680.0,
             "rx_bps_L1": 312977016.0,
             "rx_pps": 465739.6,
             "rx_util": 3.1297701599999996,
             "tx_bps": 238464200.0,
             "tx_bps_L1": 312984264.0,
             "tx_pps": 465750.4,
             "tx_util": 3.12984264
         }
     }
     expected = {
         'xe0': {
             'in_packets': 867955,
             'latency': {
                 2: {
                     'avg_latency': 74.0,
                     'max_latency': 135.0,
                     'min_latency': 60.0
                 }
             },
             'out_packets': 867964,
             'rx_throughput_bps': 104339032.0,
             'rx_throughput_fps': 203787.2,
             'tx_throughput_bps': 134126008.0,
             'tx_throughput_fps': 261964.9
         },
         'xe1': {
             'in_packets': 867964,
             'latency': {
                 1: {
                     'avg_latency': -1.0,
                     'max_latency': -1.0,
                     'min_latency': -1.0
                 }
             },
             'out_packets': 867955,
             'rx_throughput_bps': 134119648.0,
             'rx_throughput_fps': 261952.4,
             'tx_throughput_bps': 104338192.0,
             'tx_throughput_fps': 203785.5
         }
     }
     mock_setup_helper = mock.Mock()
     vpp_rfc = tg_trex_vpp.TrexVppResourceHelper(mock_setup_helper)
     vpp_rfc.vnfd_helper = base.VnfdHelper(TestTrexTrafficGenVpp.VNFD_0)
     vpp_rfc.get_stats = mock.Mock()
     vpp_rfc.get_stats.return_value = stats
     port_pg_id = rfc2544.PortPgIDMap()
     port_pg_id.add_port(1)
     port_pg_id.increase_pg_id()
     port_pg_id.add_port(0)
     port_pg_id.increase_pg_id()
     self.assertEqual(
         expected,
         vpp_rfc.generate_samples(stats=None,
                                  ports=[0, 1],
                                  port_pg_id=port_pg_id,
                                  latency=True))