Change IxNextgen library load 71/58971/2
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Mon, 25 Jun 2018 07:47:00 +0000 (08:47 +0100)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Mon, 25 Jun 2018 09:10:15 +0000 (10:10 +0100)
Changed IxNextgen library load in IXIA RFC2544 traffic generator call.

JIRA: YARDSTICK-1116

Change-Id: Icbdc5f1255dd2676584f3a1be767287e55e71f4a
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py

index 2010546..a1f9fbe 100644 (file)
 # 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 = {}
index 8cc118a..dca8098 100644 (file)
@@ -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()
-        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 +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':