Merge "Remove references to "dpdk_nic_bind" utility"
[yardstick.git] / tests / unit / network_services / vnf_generic / vnf / test_udp_replay.py
index 95bc08b..472052b 100644 (file)
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-
 import unittest
 import mock
 import os
 
 from tests.unit import STL_MOCKS
-SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
+from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+
 
+SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
 
 STLClient = mock.MagicMock()
 stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -31,10 +31,8 @@ stl_patch.start()
 
 if stl_patch:
     from yardstick.network_services.vnf_generic.vnf.udp_replay import UdpReplayApproxVnf
-    from yardstick.network_services.nfvi.resource import ResourceProfile
     from yardstick.network_services.vnf_generic.vnf.sample_vnf import ScenarioHelper
 
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 
 TEST_FILE_YAML = 'nsb_test_case.yaml'
 
@@ -78,7 +76,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
                             'netmask': '255.255.255.0',
                             'dst_ip': '152.16.100.20',
                             'type': 'PCI-PASSTHROUGH',
-                            'vld_id': 'private_0',
+                            'vld_id': 'uplink_0',
                             'ifname': 'xe0',
                         },
                         'vnfd-connection-point-ref': 'xe0',
@@ -97,7 +95,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
                             'netmask': '255.255.255.0',
                             'dst_ip': '152.16.40.20',
                             'type': 'PCI-PASSTHROUGH',
-                            'vld_id': 'public_0',
+                            'vld_id': 'downlink_0',
                             'ifname': 'xe1',
                         },
                         'vnfd-connection-point-ref': 'xe1',
@@ -200,7 +198,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
                 "interfaces": {
                     "xe0": {
                         "local_iface_name": "ens786f0",
-                        "vld_id": "private",
+                        "vld_id": UdpReplayApproxVnf.UPLINK,
                         "netmask": "255.255.255.0",
                         "vpci": "0000:05:00.0",
                         "local_ip": "152.16.100.19",
@@ -212,7 +210,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
                     },
                     "xe1": {
                         "local_iface_name": "ens786f1",
-                        "vld_id": "public",
+                        "vld_id": UdpReplayApproxVnf.DOWNLINK,
                         "netmask": "255.255.255.0",
                         "vpci": "0000:05:00.1",
                         "local_ip": "152.16.40.19",
@@ -268,7 +266,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
                 "interfaces": {
                     "xe0": {
                         "local_iface_name": "ens513f0",
-                        "vld_id": "public",
+                        "vld_id": UdpReplayApproxVnf.DOWNLINK,
                         "netmask": "255.255.255.0",
                         "vpci": "0000:02:00.0",
                         "local_ip": "152.16.40.20",
@@ -302,7 +300,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
                 "interfaces": {
                     "xe0": {
                         "local_iface_name": "ens785f0",
-                        "vld_id": "private",
+                        "vld_id": UdpReplayApproxVnf.UPLINK,
                         "netmask": "255.255.255.0",
                         "vpci": "0000:05:00.0",
                         "local_ip": "152.16.100.20",
@@ -329,13 +327,13 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
         }
     }
 
-    def test___init__(self, _):
+    def test___init__(self, *args):
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
         self.assertIsNone(udp_replay_approx_vnf._vnf_process)
 
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
     @mock.patch(SSH_HELPER)
-    def test_collect_kpi(self, ssh, mock_time, _):
+    def test_collect_kpi(self, ssh, *args):
         mock_ssh(ssh)
 
         vnfd = self.VNFD_0
@@ -354,7 +352,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
         self.assertEqual(result, udp_replay_approx_vnf.collect_kpi())
 
     @mock.patch(SSH_HELPER)
-    def test_get_stats(self, ssh, _):
+    def test_get_stats(self, ssh, *args):
         mock_ssh(ssh)
 
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
@@ -376,7 +374,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
 
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
     @mock.patch(SSH_HELPER)
-    def test__build_config(self, ssh, mock_context, *_):
+    def test__build_config(self, ssh, mock_context, *args):
         mock_ssh(ssh)
 
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
@@ -397,7 +395,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
     @mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open')
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
     @mock.patch(SSH_HELPER)
-    def test__build_pipeline_kwargs(self, ssh, mock_context, *_):
+    def test__build_pipeline_kwargs(self, ssh, mock_context, *args):
         mock_ssh(ssh)
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
         udp_replay_approx_vnf.nfvi_context = mock_context
@@ -420,12 +418,13 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
         })
 
     @mock.patch(SSH_HELPER)
-    def test_run_udp_replay(self, ssh, _):
+    def test_run_udp_replay(self, ssh, *args):
         mock_ssh(ssh)
 
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
         udp_replay_approx_vnf._build_config = mock.MagicMock()
         udp_replay_approx_vnf.queue_wrapper = mock.MagicMock()
+        udp_replay_approx_vnf.scenario_helper = mock.MagicMock()
 
         udp_replay_approx_vnf._run()
 
@@ -433,53 +432,33 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
 
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
     @mock.patch(SSH_HELPER)
-    def test_instantiate(self, ssh, *_):
+    def test_instantiate(self, ssh, *args):
         mock_ssh(ssh)
 
-        resource = mock.Mock(autospec=ResourceProfile)
-
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
         udp_replay_approx_vnf.q_out.put("Replay>")
         udp_replay_approx_vnf.WAIT_TIME = 0
         udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock()
 
+        udp_replay_approx_vnf.deploy_helper = mock.MagicMock()
+        udp_replay_approx_vnf.deploy_vnfs = mock.MagicMock()
         self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
 
         udp_replay_approx_vnf._vnf_process.is_alive = mock.Mock(return_value=1)
         udp_replay_approx_vnf._vnf_process.exitcode = 0
 
-        self.assertEquals(udp_replay_approx_vnf.wait_for_instantiate(), 0)
+        self.assertEqual(udp_replay_approx_vnf.wait_for_instantiate(), 0)
 
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
     @mock.patch('yardstick.ssh.SSH')
     @mock.patch(SSH_HELPER)
-    def test_instantiate_panic(self, ssh, resource_ssh, *_):
+    def test_instantiate_panic(self, *args):
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
         udp_replay_approx_vnf.WAIT_TIME = 0
         udp_replay_approx_vnf.q_out.put("some text PANIC some text")
         udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock()
 
+        udp_replay_approx_vnf.deploy_helper = mock.MagicMock()
         self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
         with self.assertRaises(RuntimeError):
             udp_replay_approx_vnf.wait_for_instantiate()
-
-    def test_scale(self, _):
-        udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
-        flavor = ""
-
-        self.assertRaises(NotImplementedError, udp_replay_approx_vnf.scale, flavor)
-
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
-    @mock.patch(SSH_HELPER)
-    def test_terminate(self, ssh, mock_time, _):
-        mock_ssh(ssh)
-
-        udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
-        udp_replay_approx_vnf._vnf_process = mock.MagicMock()
-        udp_replay_approx_vnf._vnf_process.terminate = mock.Mock()
-        udp_replay_approx_vnf.used_drivers = {"01:01.0": "i40e", "01:01.1": "i40e"}
-        udp_replay_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
-        self.assertEqual(None, udp_replay_approx_vnf.terminate())
-
-if __name__ == '__main__':
-    unittest.main()