Merge "NSB: ignore VNF node if there is no VNF model"
[yardstick.git] / tests / unit / network_services / vnf_generic / vnf / test_sample_vnf.py
index fa73348..d0c4b6f 100644 (file)
@@ -102,7 +102,7 @@ class TestVnfSshHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.100.20',
                             'local_mac': '00:00:00:00:00:01',
-                            'vld_id': 'private_0',
+                            'vld_id': 'uplink_0',
                             'ifname': 'xe0',
                         },
                         'vnfd-connection-point-ref': 'xe0',
@@ -119,7 +119,7 @@ class TestVnfSshHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.40.20',
                             'local_mac': '00:00:00:00:00:02',
-                            'vld_id': 'public_0',
+                            'vld_id': 'downlink_0',
                             'ifname': 'xe1',
                         },
                         'vnfd-connection-point-ref': 'xe1',
@@ -300,7 +300,7 @@ class TestSetupEnvHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.100.20',
                             'local_mac': '00:00:00:00:00:01',
-                            'vld_id': 'private_0',
+                            'vld_id': 'uplink_0',
                             'ifname': 'xe0',
                         },
                         'vnfd-connection-point-ref': 'xe0',
@@ -317,7 +317,7 @@ class TestSetupEnvHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.40.20',
                             'local_mac': '00:00:00:00:00:02',
-                            'vld_id': 'public_0',
+                            'vld_id': 'downlink_0',
                             'ifname': 'xe1',
                         },
                         'vnfd-connection-point-ref': 'xe1',
@@ -430,7 +430,7 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.100.20',
                             'local_mac': '00:00:00:00:00:01',
-                            'vld_id': 'private_0',
+                            'vld_id': 'uplink_0',
                             'ifname': 'xe0',
                         },
                         'vnfd-connection-point-ref': 'xe0',
@@ -448,7 +448,7 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.40.20',
                             'local_mac': '00:00:00:00:00:02',
-                            'vld_id': 'public_0',
+                            'vld_id': 'downlink_0',
                             'ifname': 'xe1',
                         },
                         'vnfd-connection-point-ref': 'xe1',
@@ -723,8 +723,9 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
         result = dpdk_setup_helper._validate_cpu_cfg()
         self.assertEqual(result, expected)
 
+    @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
     @mock.patch('yardstick.ssh.SSH')
-    def test_setup_vnf_environment(self, _):
+    def test_setup_vnf_environment(self, _, mock_time):
         def execute(cmd, *args, **kwargs):
             if cmd.startswith('which '):
                 return exec_failure
@@ -782,6 +783,8 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
         dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
         dpdk_setup_helper._validate_cpu_cfg = mock.Mock()
 
+        dpdk_setup_helper.bound_pci = [v['virtual-interface']["vpci"] for v in
+                                       vnfd_helper.interfaces]
         result = dpdk_setup_helper._setup_resources()
         self.assertIsInstance(result, ResourceProfile)
         self.assertEqual(dpdk_setup_helper.socket, 0)
@@ -796,11 +799,14 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
         dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
         dpdk_setup_helper._validate_cpu_cfg = mock.Mock()
 
+        dpdk_setup_helper.bound_pci = [v['virtual-interface']["vpci"] for v in
+                                       vnfd_helper.interfaces]
         result = dpdk_setup_helper._setup_resources()
         self.assertIsInstance(result, ResourceProfile)
         self.assertEqual(dpdk_setup_helper.socket, 1)
 
-    def test__detect_and_bind_drivers(self):
+    @mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
+    def test__detect_and_bind_drivers(self, mock_time):
         vnfd_helper = VnfdHelper(deepcopy(self.VNFD_0))
         ssh_helper = mock.Mock()
         # ssh_helper.execute = mock.Mock(return_value = (0, 'text', ''))
@@ -1029,7 +1035,7 @@ class TestClientResourceHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.100.20',
                             'local_mac': '00:00:00:00:00:01',
-                            'vld_id': 'private_0',
+                            'vld_id': 'uplink_0',
                             'ifname': 'xe0',
                         },
                         'vnfd-connection-point-ref': 'xe0',
@@ -1047,7 +1053,7 @@ class TestClientResourceHelper(unittest.TestCase):
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.40.20',
                             'local_mac': '00:00:00:00:00:02',
-                            'vld_id': 'public_0',
+                            'vld_id': 'downlink_0',
                             'ifname': 'xe1',
                         },
                         'vnfd-connection-point-ref': 'xe1',
@@ -1912,8 +1918,8 @@ class TestSampleVnf(unittest.TestCase):
 
         self.assertIsNone(sample_vnf._build_ports())
         self.assertIsNotNone(sample_vnf.networks)
-        self.assertIsNotNone(sample_vnf.priv_ports)
-        self.assertIsNotNone(sample_vnf.pub_ports)
+        self.assertIsNotNone(sample_vnf.uplink_ports)
+        self.assertIsNotNone(sample_vnf.downlink_ports)
         self.assertIsNotNone(sample_vnf.my_ports)
 
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")