X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Ftests%2Funit%2Fnetwork_services%2Fvnf_generic%2Fvnf%2Ftest_tg_rfc2544_ixia.py;h=42ac40b5008e3a4e80e8de72b0ee45a55ff94053;hb=e8eca1a5678754b54d5c83c28ba2f7cd38d85880;hp=8cc118a311c14e540d1c04894a31c99db43cab8c;hpb=b4bba7a8d9d1e3379209d13a3272412e55f1dc74;p=yardstick.git diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py index 8cc118a31..42ac40b50 100644 --- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py +++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py @@ -18,8 +18,10 @@ import mock import six import unittest -from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_ixia +from yardstick.network_services.libs.ixia_libs.ixnet import ixnet_api from yardstick.network_services.traffic_profile import base as tp_base +from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_ixia +from yardstick.benchmark.contexts import base as ctx_base TEST_FILE_YAML = 'nsb_test_case.yaml' @@ -30,8 +32,7 @@ NAME = "tg__1" class TestIxiaResourceHelper(unittest.TestCase): def setUp(self): - self._mock_IxNextgen = mock.patch.object(tg_rfc2544_ixia, - 'IxNextgen') + self._mock_IxNextgen = mock.patch.object(ixnet_api, 'IxNextgen') self.mock_IxNextgen = self._mock_IxNextgen.start() self.addCleanup(self._stop_mocks) @@ -48,12 +49,10 @@ class TestIxiaResourceHelper(unittest.TestCase): def test_stop_collect_with_client(self): mock_client = mock.Mock() - ixia_resource_helper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock()) - ixia_resource_helper.client = mock_client ixia_resource_helper.stop_collect() - mock_client.ix_stop_traffic.assert_called_once() + self.assertEqual(1, ixia_resource_helper._terminated.value) def test_run_traffic(self): mock_tprofile = mock.Mock() @@ -70,8 +69,7 @@ class TestIxiaResourceHelper(unittest.TestCase): self.assertEqual('fake_samples', ixia_rhelper._queue.get()) -@mock.patch( - "yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen") +@mock.patch.object(tg_rfc2544_ixia, 'ixnet_api') class TestIXIATrafficGen(unittest.TestCase): VNFD = {'vnfd:vnfd-catalog': {'vnfd': @@ -189,6 +187,7 @@ class TestIXIATrafficGen(unittest.TestCase): ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd) self.assertIsNone(ixnet_traffic_gen.listen_traffic({})) + @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context') def test_instantiate(self, *args): with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) @@ -215,6 +214,9 @@ class TestIXIATrafficGen(unittest.TestCase): 'lb_count': 1, 'worker_config': '1C/1T', 'worker_threads': 1}}}}) + scenario_cfg.update({ + 'nodes': {ixnet_traffic_gen.name: "mock"} + }) ixnet_traffic_gen.topology = "" ixnet_traffic_gen.get_ixobj = mock.MagicMock() ixnet_traffic_gen._ixia_traffic_gen = mock.MagicMock() @@ -223,17 +225,26 @@ class TestIXIATrafficGen(unittest.TestCase): IOError, ixnet_traffic_gen.instantiate(scenario_cfg, {})) + @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node') def test_collect_kpi(self, *args): with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock + vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd) + ixnet_traffic_gen.scenario_helper.scenario_cfg = { + 'nodes': {ixnet_traffic_gen.name: "mock"} + } ixnet_traffic_gen.data = {} restult = ixnet_traffic_gen.collect_kpi() - self.assertEqual({}, restult) + + expected = {'collect_stats': {}, + 'physical_node': 'mock_node'} + + self.assertEqual(expected, restult) def test_terminate(self, *args): with mock.patch("yardstick.ssh.SSH") as ssh: