From 67bd29933789e7f31c52290fdd43835e54f89eaf Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 23 Nov 2017 09:08:14 +0000 Subject: Make GenericVNF an abstract class GenericVNF class is now an abstract class. Only optional methods are implemented. Mandatory methods: - instantiate - wait_for_instantiate - terminate - scale - collect_kpi. JIRA: YARDSTICK-866 Change-Id: Ia8766f9f98816e11894d1e72b0f3bd573d091d99 Signed-off-by: Rodolfo Alonso Hernandez --- .../vnf_generic/vnf/test_udp_replay.py | 37 +++++++--------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py') diff --git a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py index d4d3439f3..635ce2735 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py @@ -15,26 +15,24 @@ # 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) 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' @@ -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,7 +418,7 @@ 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) @@ -434,11 +432,9 @@ 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 @@ -456,7 +452,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase): @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") @@ -467,15 +463,9 @@ class TestUdpReplayApproxVnf(unittest.TestCase): 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, _): + def test_terminate(self, ssh, *args): mock_ssh(ssh) udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0) @@ -484,6 +474,3 @@ class TestUdpReplayApproxVnf(unittest.TestCase): 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() -- cgit 1.2.3-korg