Пример #1
0
 def test_build_ports_reversed_pci_ordering(self):
     vnfd = copy.deepcopy(self.VNFD['vnfd:vnfd-catalog']['vnfd'][0])
     vnfd['vdu'][0]['external-interface'] = [{
         'virtual-interface': {
             'dst_mac': '00:00:00:00:00:04',
             'vpci': '0000:05:00.0',
             'local_ip': '152.16.100.19',
             'type': 'PCI-PASSTHROUGH',
             'netmask': '255.255.255.0',
             'dpdk_port_num': 2,
             'bandwidth': '10 Gbps',
             'driver': "i40e",
             'dst_ip': '152.16.100.20',
             'local_iface_name': 'xe0',
             'vld_id': 'downlink_0',
             'ifname': 'xe0',
             'local_mac': '00:00:00:00:00:02'
         },
         'vnfd-connection-point-ref': 'xe0',
         'name': 'xe0'
     }, {
         'virtual-interface': {
             'dst_mac': '00:00:00:00:00:03',
             'vpci': '0000:04:00.0',
             'local_ip': '152.16.40.19',
             'type': 'PCI-PASSTHROUGH',
             'driver': "i40e",
             'netmask': '255.255.255.0',
             'dpdk_port_num': 0,
             'bandwidth': '10 Gbps',
             'dst_ip': '152.16.40.20',
             'local_iface_name': 'xe1',
             'vld_id': 'uplink_0',
             'ifname': 'xe1',
             'local_mac': '00:00:00:00:00:01'
         },
         'vnfd-connection-point-ref': 'xe1',
         'name': 'xe1'
     }]
     trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd)
     trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
     trex_traffic_gen.resource_helper.generate_cfg()
     trex_traffic_gen.resource_helper._build_ports()
     self.assertEqual(sorted(trex_traffic_gen.resource_helper.all_ports),
                      [0, 1])
     # there is a gap in ordering
     self.assertEqual({
         0: 0,
         2: 1
     }, dict(trex_traffic_gen.resource_helper.dpdk_to_trex_port_map))
Пример #2
0
    def test__traffic_runner(self):
        mock_traffic_profile = mock.Mock(autospec=tp_base.TrafficProfile)
        mock_traffic_profile.get_traffic_definition.return_value = "64"
        mock_traffic_profile.execute_traffic.return_value = "64"
        mock_traffic_profile.params = self.TRAFFIC_PROFILE

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        self.sut = tg_trex.TrexTrafficGen(NAME, vnfd)
        self.sut.ssh_helper = mock.Mock()
        self.sut.ssh_helper.run = mock.Mock()
        self.sut._connect_client = mock.Mock()
        self.sut._connect_client.get_stats = mock.Mock(return_value="0")
        self.sut.resource_helper.RUN_DURATION = 0
        self.sut.resource_helper.QUEUE_WAIT_TIME = 0
        # must generate cfg before we can run traffic so Trex port mapping is
        # created
        self.sut.resource_helper.generate_cfg()
        with mock.patch.object(self.sut.resource_helper, 'run_traffic'):
            self.sut._traffic_runner(mock_traffic_profile)
Пример #3
0
 def test__connect_client(self):
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id')
     client = mock.Mock()
     client.connect = mock.Mock(return_value=0)
     self.assertIsNotNone(trex_traffic_gen.resource_helper._connect(client))
Пример #4
0
 def test_terminate(self):
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id')
     trex_traffic_gen.ssh_helper = mock.MagicMock()
     trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
     self.assertIsNone(trex_traffic_gen.terminate())
Пример #5
0
 def test_listen_traffic(self):
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id')
     self.assertIsNone(trex_traffic_gen.listen_traffic({}))
Пример #6
0
 def test___init__(self):
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd, 'task_id')
     self.assertIsInstance(trex_traffic_gen.resource_helper,
                           tg_trex.TrexResourceHelper)
Пример #7
0
 def test__generate_trex_cfg(self):
     vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
     trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd)
     trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
     self.assertIsNone(trex_traffic_gen.resource_helper.generate_cfg())