diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-06-27 16:48:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-06-27 16:48:33 +0000 |
commit | e3df6a30f7953810e97d65b9aa51f069ce9d4007 (patch) | |
tree | bee48b31cbbf4303ba24c6825fdc55d374102cd5 | |
parent | 2ab8157726c651c44be4d2f3ba54157ce778a536 (diff) | |
parent | 193f7ae18298574cba4698859a27e2a3cdcf3534 (diff) |
Merge "Change IxNextgen library load" into stable/fraser
-rw-r--r-- | yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py | 18 | ||||
-rw-r--r-- | yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py | 13 |
2 files changed, 8 insertions, 23 deletions
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py index 2010546e7..a1f9fbeb4 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py @@ -12,12 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import logging -import sys -from yardstick.common import exceptions from yardstick.common import utils +from yardstick.network_services.libs.ixia_libs.ixnet import ixnet_api from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNFTrafficGen from yardstick.network_services.vnf_generic.vnf.sample_vnf import ClientResourceHelper from yardstick.network_services.vnf_generic.vnf.sample_vnf import Rfc2544ResourceHelper @@ -27,14 +25,6 @@ LOG = logging.getLogger(__name__) WAIT_AFTER_CFG_LOAD = 10 WAIT_FOR_TRAFFIC = 30 -IXIA_LIB = os.path.dirname(os.path.realpath(__file__)) -IXNET_LIB = os.path.join(IXIA_LIB, "../../libs/ixia_libs/IxNet") -sys.path.append(IXNET_LIB) - -try: - from IxNet import IxNextgen -except ImportError: - IxNextgen = exceptions.ErrorClass class IxiaRfc2544Helper(Rfc2544ResourceHelper): @@ -51,7 +41,7 @@ class IxiaResourceHelper(ClientResourceHelper): super(IxiaResourceHelper, self).__init__(setup_helper) self.scenario_helper = setup_helper.scenario_helper - self.client = IxNextgen() + self.client = ixnet_api.IxNextgen() if rfc_helper_type is None: rfc_helper_type = IxiaRfc2544Helper @@ -69,10 +59,8 @@ class IxiaResourceHelper(ClientResourceHelper): def stop_collect(self): self._terminated.value = 1 - if self.client: - self.client.ix_stop_traffic() - def generate_samples(self, ports, key=None, default=None): + def generate_samples(self, ports, key=None): stats = self.get_stats() samples = {} 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 956c192aa..dca8098fa 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,9 @@ 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 TEST_FILE_YAML = 'nsb_test_case.yaml' @@ -30,8 +31,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 +48,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() - self.assertEqual(mock_client.ix_stop_traffic.call_count, 1) + self.assertEqual(1, ixia_resource_helper._terminated.value) def test_run_traffic(self): mock_tprofile = mock.Mock() @@ -70,8 +68,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': |