예제 #1
0
    def test_create_vpe_config(self):
        vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
        config_create = vpe_vnf.ConfigCreate(vnfd_helper, 23)
        config_create.uplink_ports = ['xe1']
        with mock.patch.object(config_create, 'vpe_upstream') as mock_up, \
                mock.patch.object(config_create, 'vpe_downstream') as \
                mock_down, \
                mock.patch.object(config_create, 'vpe_tmq') as mock_tmq, \
                mock.patch.object(config_create, 'vpe_initialize') as \
                mock_ini, \
                mock.patch.object(config_create, 'vpe_rxq') as mock_rxq:
            mock_ini_obj = mock.Mock()
            mock_rxq_obj = mock.Mock()
            mock_up_obj = mock.Mock()
            mock_down_obj = mock.Mock()
            mock_tmq_obj = mock.Mock()
            mock_ini.return_value = mock_ini_obj
            mock_rxq.return_value = mock_rxq_obj
            mock_up.return_value = mock_up_obj
            mock_down.return_value = mock_down_obj
            mock_tmq.return_value = mock_tmq_obj
            config_create.create_vpe_config('fake_config_file')

        mock_rxq.assert_called_once_with(mock_ini_obj)
        mock_up.assert_called_once_with('fake_config_file', 0)
        mock_down.assert_called_once_with('fake_config_file', 0)
        mock_tmq.assert_called_once_with(mock_down_obj, 0)
        mock_up_obj.write.assert_called_once()
        mock_tmq_obj.write.assert_called_once()
예제 #2
0
 def test_vpe_rxq(self):
     vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
     config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
     config = configparser.ConfigParser()
     config_create.downlink_ports = ['xe0']
     config_create.vpe_rxq(config)
     self.assertEqual(config.get('RXQ0.0', 'mempool'), 'MEMPOOL1')
예제 #3
0
 def test_vpe_initialize(self):
     vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
     config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
     config = configparser.ConfigParser()
     config_create.vpe_initialize(config)
     self.assertEqual(config.get('EAL', 'log_level'), '0')
     self.assertEqual(config.get('PIPELINE0', 'type'), 'MASTER')
     self.assertEqual(config.get('PIPELINE0', 'core'), 's2C0')
     self.assertEqual(config.get('MEMPOOL0', 'pool_size'), '256K')
     self.assertEqual(config.get('MEMPOOL1', 'pool_size'), '2M')
예제 #4
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)
예제 #5
0
    def test_get_sink_swq(self):
        vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
        config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
        config = configparser.ConfigParser()
        config.add_section('PIPELINE0')
        config.set('PIPELINE0', 'key1', 'value1')
        config.set('PIPELINE0', 'key2', 'value2 SINK')
        config.set('PIPELINE0', 'key3', 'TM value3')
        config.set('PIPELINE0', 'key4', 'value4')
        config.set('PIPELINE0', 'key5', 'the SINK value5')

        self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key1', 5), 'SWQ-1')
        self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key2', 5), 'SWQ-1 SINK0')
        self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key3', 5), 'SWQ-1 TM5')
        config_create.sw_q += 1
        self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key4', 5), 'SWQ0')
        self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key5', 5), 'SWQ0 SINK1')
예제 #6
0
 def test_generate_vpe_script(self):
     vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
     vpe_config_vnf = vpe_vnf.ConfigCreate(vnfd_helper, 2)
     intf = [
         {
             "name": 'xe1',
             "virtual-interface": {
                 "dst_ip": "1.1.1.1",
                 "dst_mac": "00:00:00:00:00:00:02",
             },
         },
         {
             "name": 'xe2',
             "virtual-interface": {
                 "dst_ip": "1.1.1.1",
                 "dst_mac": "00:00:00:00:00:00:02",
             },
         },
     ]
     vpe_config_vnf.downlink_ports = ['xe1']
     vpe_config_vnf.uplink_ports = ['xe2']
     result = vpe_config_vnf.generate_vpe_script(intf)
     self.assertIsInstance(result, str)
     self.assertNotEqual(result, '')
예제 #7
0
 def test___init__(self):
     vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
     config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
     self.assertEqual(config_create.uplink_ports, ['xe0'])
     self.assertEqual(config_create.downlink_ports, ['xe1'])
     self.assertEqual(config_create.socket, 2)
예제 #8
0
 def test_dpdk_port_to_link_id(self):
     vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
     config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
     self.assertEqual(config_create.dpdk_port_to_link_id_map, {'xe0': 0, 'xe1': 1})
예제 #9
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))
예제 #10
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))