Move tests: unit/network_services/vnf_generic 71/56771/8
authorEmma Foley <emma.l.foley@intel.com>
Fri, 27 Apr 2018 10:30:20 +0000 (10:30 +0000)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Mon, 11 Jun 2018 07:30:17 +0000 (08:30 +0100)
* Fix pylint errors
* Add TODOs

Some errors are ignored locally, as they were a symptom of other problems.
These issues have been flagged with a TODO, and should be fixed later.

JIRA: YARDSTICK-837

Signed-off-by: Emma Foley <emma.l.foley@intel.com>
Change-Id: I3d95537a64bde923703421510d27bac0d6dd92bd

29 files changed:
yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
yardstick/tests/unit/benchmark/contexts/test_dummy.py
yardstick/tests/unit/benchmark/contexts/test_heat.py
yardstick/tests/unit/benchmark/contexts/test_kubernetes.py
yardstick/tests/unit/benchmark/contexts/test_node.py
yardstick/tests/unit/benchmark/core/test_task.py
yardstick/tests/unit/network_services/vnf_generic/__init__.py [moved from tests/unit/network_services/vnf_generic/__init__.py with 100% similarity]
yardstick/tests/unit/network_services/vnf_generic/test_vnfdgen.py [moved from tests/unit/network_services/vnf_generic/test_vnfdgen.py with 95% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/__init__.py [moved from tests/unit/network_services/vnf_generic/vnf/__init__.py with 100% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/acl_1rule.yaml [moved from tests/unit/network_services/vnf_generic/vnf/acl_1rule.yaml with 100% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/tc_baremetal_rfc2544_ipv4_1flow_64B.yaml [moved from tests/unit/network_services/vnf_generic/vnf/tc_baremetal_rfc2544_ipv4_1flow_64B.yaml with 100% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py [moved from tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py with 98% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_base.py [moved from tests/unit/network_services/vnf_generic/vnf/test_base.py with 99% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py [moved from tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py with 94% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py [moved from tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py with 99% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py [moved from tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py with 99% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py [moved from tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py with 98% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py [moved from tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py with 99% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py [moved from tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py with 93% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py [moved from tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py with 98% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py [moved from tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py with 99% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py [moved from tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py with 75% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py [moved from tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py with 98% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py [moved from tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py with 77% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py [moved from tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py with 97% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py [moved from tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py with 99% similarity]
yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py [moved from tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py with 99% similarity]

index 0067f6b..9deef5c 100644 (file)
@@ -115,7 +115,8 @@ class ConfigCreate(object):
         pktq = "SWQ{0}{1}".format(self.sw_q, sink)
         return pktq
 
-    def vpe_upstream(self, vnf_cfg, index=0):
+    def vpe_upstream(self, vnf_cfg, index=0):  # pragma: no cover
+        # NOTE(ralonsoh): this function must be covered in UTs.
         parser = configparser.ConfigParser()
         parser.read(os.path.join(vnf_cfg, 'vpe_upstream'))
 
@@ -147,7 +148,8 @@ class ConfigCreate(object):
             self.n_pipeline += 1
         return parser
 
-    def vpe_downstream(self, vnf_cfg, index):
+    def vpe_downstream(self, vnf_cfg, index):  # pragma: no cover
+        # NOTE(ralonsoh): this function must be covered in UTs.
         parser = configparser.ConfigParser()
         parser.read(os.path.join(vnf_cfg, 'vpe_downstream'))
         for pipeline in parser.sections():
index bc3bb73..6eb438c 100644 (file)
@@ -19,6 +19,7 @@ import mock
 import six
 import unittest
 
+from yardstick.benchmark.contexts import base
 from yardstick.benchmark.contexts.standalone import model
 from yardstick.benchmark.contexts.standalone import ovs_dpdk
 from yardstick.common import exceptions
@@ -59,9 +60,11 @@ class OvsDpdkContextTestCase(unittest.TestCase):
         self.ovs_dpdk = ovs_dpdk.OvsDpdkContext()
         self.addCleanup(self._remove_contexts)
 
-    def _remove_contexts(self):
-        if self.ovs_dpdk in self.ovs_dpdk.list:
-            self.ovs_dpdk._delete_context()
+    @staticmethod
+    def _remove_contexts():
+        for context in base.Context.list:
+            context._delete_context()
+        base.Context.list = []
 
     @mock.patch('yardstick.benchmark.contexts.standalone.model.Server')
     @mock.patch('yardstick.benchmark.contexts.standalone.model.StandaloneContextHelper')
index b426985..de748e2 100644 (file)
@@ -18,6 +18,7 @@ import mock
 import unittest
 
 from yardstick import ssh
+from yardstick.benchmark.contexts import base
 from yardstick.benchmark.contexts.standalone import model
 from yardstick.benchmark.contexts.standalone import sriov
 
@@ -66,9 +67,11 @@ class SriovContextTestCase(unittest.TestCase):
         self.sriov = sriov.SriovContext()
         self.addCleanup(self._remove_contexts)
 
-    def _remove_contexts(self):
-        if self.sriov in self.sriov.list:
-            self.sriov._delete_context()
+    @staticmethod
+    def _remove_contexts():
+        for context in base.Context.list:
+            context._delete_context()
+        base.Context.list = []
 
     @mock.patch.object(model, 'StandaloneContextHelper')
     @mock.patch.object(model, 'Libvirt')
index e393001..c4113be 100644 (file)
@@ -9,6 +9,7 @@
 
 import unittest
 
+from yardstick.benchmark.contexts import base
 from yardstick.benchmark.contexts import dummy
 
 
@@ -20,7 +21,12 @@ class DummyContextTestCase(unittest.TestCase):
             'task_id': '1234567890',
         }
         self.test_context = dummy.DummyContext()
-        self.addCleanup(self.test_context._delete_context)
+        self.addCleanup(self._delete_contexts)
+
+    @staticmethod
+    def _delete_contexts():
+        for context in base.Context.list:
+            context._delete_context()
 
     def test___init__(self):
         self.assertFalse(self.test_context._flags.no_setup)
index 947e6fe..9c822b3 100644 (file)
@@ -8,7 +8,6 @@
 ##############################################################################
 
 from collections import OrderedDict
-from itertools import count
 import logging
 import os
 
@@ -31,12 +30,12 @@ class HeatContextTestCase(ut_base.BaseUnitTestCase):
     def setUp(self):
         self.test_context = heat.HeatContext()
         self.addCleanup(self._remove_contexts)
-        self.mock_context = mock.Mock(spec=heat.HeatContext())
-        self.name_iter = ('vnf{:03}'.format(x) for x in count(0, step=3))
 
-    def _remove_contexts(self):
-        if self.test_context in self.test_context.list:
-            self.test_context._delete_context()
+    @staticmethod
+    def _remove_contexts():
+        for context in base.Context.list:
+            context._delete_context()
+        base.Context.list = []
 
     def test___init__(self):
         self.assertIsNone(self.test_context._name)
@@ -655,6 +654,7 @@ class HeatContextTestCase(ut_base.BaseUnitTestCase):
         baz3_server.public_ip = None
         baz3_server.context.user = 'zab'
 
+        self.mock_context = mock.Mock(spec=heat.HeatContext())
         self.mock_context._name = 'bar1'
         self.test_context.stack = mock.Mock()
         self.mock_context.stack.outputs = {
index 4dd9d40..0e11a53 100644 (file)
@@ -10,6 +10,7 @@
 import mock
 import unittest
 
+from yardstick.benchmark.contexts import base
 from yardstick.benchmark.contexts import kubernetes
 
 
@@ -43,9 +44,11 @@ class KubernetesTestCase(unittest.TestCase):
         self.addCleanup(self._remove_contexts)
         self.k8s_context.init(context_cfg)
 
-    def _remove_contexts(self):
-        if self.k8s_context in self.k8s_context.list:
-            self.k8s_context._delete_context()
+    @staticmethod
+    def _remove_contexts():
+        for context in base.Context.list:
+            context._delete_context()
+        base.Context.list = []
 
     @mock.patch.object(kubernetes.KubernetesContext, '_delete_services')
     @mock.patch.object(kubernetes.KubernetesContext, '_delete_ssh_key')
index 8b23248..b67be37 100644 (file)
@@ -13,6 +13,7 @@ import errno
 import mock
 
 from yardstick.common import constants as consts
+from yardstick.benchmark.contexts import base
 from yardstick.benchmark.contexts import node
 
 
@@ -33,9 +34,11 @@ class NodeContextTestCase(unittest.TestCase):
             'file': self._get_file_abspath(self.NODES_SAMPLE)
         }
 
-    def _remove_contexts(self):
-        if self.test_context in self.test_context.list:
-            self.test_context._delete_context()
+    @staticmethod
+    def _remove_contexts():
+        for context in base.Context.list:
+            context._delete_context()
+        base.Context.list = []
 
     def _get_file_abspath(self, filename):
         curr_path = os.path.dirname(os.path.abspath(__file__))
index e7d2c70..7468368 100644 (file)
@@ -17,6 +17,7 @@ import six
 import unittest
 import uuid
 
+from yardstick.benchmark.contexts import base
 from yardstick.benchmark.contexts import dummy
 from yardstick.benchmark.core import task
 from yardstick.common import constants as consts
@@ -358,9 +359,10 @@ key2:
             }
 
     @staticmethod
-    def _remove_context(context):
-        if context:
+    def _remove_contexts():
+        for context in base.Context.list:
             context._delete_context()
+        base.Context.list = []
 
     def test__change_node_names(self):
 
@@ -376,7 +378,7 @@ key2:
             }
 
         my_context = dummy.DummyContext()
-        self.addCleanup(self._remove_context, my_context)
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
 
         expected_scenario = {
@@ -419,7 +421,7 @@ key2:
             }
 
         my_context = dummy.DummyContext()
-        self.addCleanup(self._remove_context, my_context)
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
 
         scenario = copy.deepcopy(self.scenario)
@@ -435,7 +437,7 @@ key2:
         }
 
         my_context = dummy.DummyContext()
-        self.addCleanup(self._remove_context, my_context)
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
         scenario = copy.deepcopy(self.scenario)
         scenario['options'] = None
@@ -450,7 +452,7 @@ key2:
         }
 
         my_context = dummy.DummyContext()
-        self.addCleanup(self._remove_context, my_context)
+        self.addCleanup(self._remove_contexts)
         my_context.init(ctx_attrs)
         scenario = copy.deepcopy(self.scenario)
         scenario['options']['server_name'] = None
 # limitations under the License.
 #
 
-# Unittest for yardstick.network_services.vnf_generic.vnfdgen
-
-from __future__ import absolute_import
-import unittest
 from six.moves import range
+import unittest
 
 from yardstick.common.yaml_loader import yaml_load
 from yardstick.network_services.vnf_generic import vnfdgen
@@ -202,10 +199,10 @@ TRAFFIC_PROFILE_TPL = """
 
 TRAFFIC_PROFILE = {
     UPLINK: [{"ipv4": {"outer_l2":
-                          {"framesize": {"64B": '10', "128B": '10',
-                                         "256B": '10', "373B": '10',
-                                         "570B": '10', "1400B": '10',
-                                         "1518B": '40'}}}}]}
+                       {"framesize": {"64B": '10', "128B": '10',
+                                      "256B": '10', "373B": '10',
+                                      "570B": '10', "1400B": '10',
+                                      "1518B": '40'}}}}]}
 
 
 class TestRender(unittest.TestCase):
@@ -214,12 +211,14 @@ class TestRender(unittest.TestCase):
 
         tmpl = "{{ routing_table }}"
         self.assertEqual(vnfdgen.render(tmpl, routing_table=None), u'~')
-        self.assertEqual(yaml_load(vnfdgen.render(tmpl, routing_table=None)), None)
+        self.assertIsNone(
+            yaml_load(vnfdgen.render(tmpl, routing_table=None)))
 
     def test_render_unicode_dict(self):
 
         tmpl = "{{ routing_table }}"
-        self.assertEqual(yaml_load(vnfdgen.render(tmpl, **NODE_CFG)), NODE_CFG["routing_table"])
+        self.assertEqual(yaml_load(vnfdgen.render(
+            tmpl, **NODE_CFG)), NODE_CFG["routing_table"])
 
 
 class TestVnfdGen(unittest.TestCase):
@@ -266,7 +265,6 @@ class TestVnfdGen(unittest.TestCase):
         d = {'0': 1, 0: 24, 'b': 2}
         self.assertRaises(AttributeError, vnfdgen.deepgetitem, d, 0)
 
-
     def test_generate_tp_single_var(self):
         """ Function to verify traffic profile generation with imix """
 
@@ -17,8 +17,8 @@ import unittest
 import mock
 import os
 
-from tests.unit import STL_MOCKS
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 from yardstick.common import utils
 
 
@@ -324,7 +324,7 @@ class TestAclApproxVnf(unittest.TestCase):
         acl_approx_vnf.resource_helper = mock.MagicMock()
         acl_approx_vnf._build_config = mock.MagicMock()
         self.scenario_cfg['vnf_options'] = {'acl': {'cfg': "",
-                                                        'rules': ""}}
+                                                    'rules': ""}}
         acl_approx_vnf.q_out.put("pipeline>")
         acl_approx_vnf.WAIT_TIME = 0
         self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
@@ -13,8 +13,6 @@
 # limitations under the License.
 #
 
-# Unittest for yardstick.network_services.vnf_generic.vnf.test_base
-
 import multiprocessing
 import os
 
 
 from copy import deepcopy
 import os
-import unittest
+
 import mock
+import unittest
+
 
-from tests.unit import STL_MOCKS
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 from yardstick.common import utils
 
-STLClient = mock.MagicMock()
-stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
-stl_patch.start()
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+
 
-if stl_patch:
-    from yardstick.network_services.vnf_generic.vnf.cgnapt_vnf import CgnaptApproxVnf, \
-        CgnaptApproxSetupEnvHelper
-    from yardstick.network_services.vnf_generic.vnf import cgnapt_vnf
-    from yardstick.network_services.nfvi.resource import ResourceProfile
+
+from yardstick.network_services.vnf_generic.vnf.cgnapt_vnf import CgnaptApproxVnf, \
+    CgnaptApproxSetupEnvHelper
+from yardstick.network_services.vnf_generic.vnf import cgnapt_vnf
+from yardstick.network_services.nfvi.resource import ResourceProfile
 
 TEST_FILE_YAML = 'nsb_test_case.yaml'
 SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -409,6 +408,22 @@ class TestCgnaptApproxVnf(unittest.TestCase):
         self.assertIsNone(cgnapt_approx_vnf.instantiate(self.scenario_cfg,
                                                         self.context_cfg))
 
+    @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+    @mock.patch(SSH_HELPER)
+    def test_terminate(self, ssh, *args):
+        mock_ssh(ssh)
+
+        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+        cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
+        cgnapt_approx_vnf._vnf_process = mock.MagicMock()
+        cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
+        cgnapt_approx_vnf.used_drivers = {"01:01.0": "i40e",
+                                          "01:01.1": "i40e"}
+        cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
+        cgnapt_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
+        cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
+        self.assertIsNone(cgnapt_approx_vnf.terminate())
+
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
     @mock.patch(SSH_HELPER)
     def test__vnf_up_post(self, ssh, *args):
@@ -22,7 +22,7 @@ import time
 import mock
 import unittest
 
-from tests.unit import STL_MOCKS
+from yardstick.tests import STL_MOCKS
 from yardstick.common import utils
 from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
 from yardstick.network_services import constants
@@ -314,6 +314,7 @@ class TestProxSocketHelper(unittest.TestCase):
         result = prox.get_socket()
         self.assertIs(result, mock_sock)
 
+    # TODO(elfoley): Split this into three tests
     @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.select')
     def test_get_data(self, mock_select):
         mock_select.select.side_effect = [[1], [0]]
@@ -910,6 +911,7 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
         result = ProxDpdkVnfSetupEnvHelper._get_tx_port('section1', input_data)
         self.assertEqual(result, expected)
 
+    # TODO(elfoley): Split this into several smaller tests
     def test_write_prox_config(self):
         input_data = {}
         expected = ''
@@ -1523,6 +1525,7 @@ class TestProxResourceHelper(unittest.TestCase):
         result = helper.execute('my_command')
         self.assertEqual(result, expected)
 
+        # TODO(elfoley): Make this a separate test: test_execute_no_client
         helper.client = object()
 
         result = helper.execute('my_command')
@@ -1684,6 +1687,7 @@ class TestProxProfileHelper(unittest.TestCase):
         self.assertIs(result, helper._cpu_topology)
         self.assertIs(result, helper.cpu_topology)
 
+    # TODO(elfoley): Split this test; there are two sets of inputs/outputs
     def test_test_cores(self):
         resource_helper = mock.MagicMock()
         resource_helper.setup_helper.prox_config_data = []
@@ -1741,6 +1745,7 @@ class TestProxProfileHelper(unittest.TestCase):
         self.assertIs(result, helper._test_cores)
         self.assertIs(result, helper.test_cores)
 
+    # TODO(elfoley): Split this test; there are two sets of inputs/outputs
     def test_latency_cores(self):
         resource_helper = mock.MagicMock()
         resource_helper.setup_helper.prox_config_data = []
@@ -19,7 +19,7 @@ import unittest
 import mock
 from copy import deepcopy
 
-from tests.unit import STL_MOCKS
+from yardstick.tests import STL_MOCKS
 
 
 SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -30,7 +30,7 @@ stl_patch.start()
 
 if stl_patch:
     from yardstick.network_services.vnf_generic.vnf.prox_vnf import ProxApproxVnf
-    from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+    from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 
 
 NAME = "vnf__1"
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-
 import unittest
 import mock
 
-from tests.unit import STL_MOCKS
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 
 
 STLClient = mock.MagicMock()
@@ -19,8 +19,8 @@ import unittest
 import mock
 import six
 
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
-from tests.unit import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
 from yardstick.benchmark.contexts.base import Context
 from yardstick.common import exceptions as y_exceptions
 from yardstick.common import utils
@@ -19,7 +19,7 @@ import mock
 import unittest
 import six
 
-from tests.unit import STL_MOCKS
+from yardstick.tests import STL_MOCKS
 from yardstick import ssh
 from yardstick.common import utils
 
@@ -115,6 +115,18 @@ class TestIxLoadTrafficGen(unittest.TestCase):
             "flow_number": 10,
             "frame_size": 64}}
 
+    def setUp(self):
+        self._mock_call = mock.patch.object(subprocess, "call")
+        self.mock_call = self._mock_call.start()
+        self._mock_open = mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.open")
+        self.mock_open = self._mock_open.start()
+
+        self.addCleanup(self._stop_mock)
+
+    def _stop_mock(self):
+        self._mock_call.stop()
+        self._mock_open.stop()
+
     def test___init__(self):
         with mock.patch("yardstick.ssh.SSH") as ssh:
             ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -149,9 +161,8 @@ class TestIxLoadTrafficGen(unittest.TestCase):
 
     @mock.patch.object(utils, 'find_relative_file')
     @mock.patch.object(utils, 'makedirs')
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
-    def test_instantiate(self, shutil, *args):
+    def test_instantiate(self, *args):
         with mock.patch("yardstick.ssh.SSH") as ssh:
             ssh_mock = mock.Mock(autospec=ssh.SSH)
             ssh_mock.execute = \
@@ -165,7 +176,6 @@ class TestIxLoadTrafficGen(unittest.TestCase):
                             'ixia_profile': "ixload.cfg",
                             'task_path': "/path/to/task"}
             ixload_traffic_gen.RESULTS_MOUNT = "/tmp/result"
-            shutil.copy = mock.Mock()
             scenario_cfg.update({'options': {'packetsize': 64, 'traffic_type': 4,
                                              'rfc2544': {'allowed_drop_rate': '0.8 - 1'},
                                              'vnf__1': {'rules': 'acl_1rule.yaml',
@@ -180,13 +190,12 @@ class TestIxLoadTrafficGen(unittest.TestCase):
                 mock_open.return_value = mock.MagicMock()
                 ixload_traffic_gen.instantiate(scenario_cfg, {})
 
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.open")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.min")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.max")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.len")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
-    def test_run_traffic(self, shutil, *args):
+    def test_run_traffic(self, *args):
         mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
         mock_traffic_profile.get_traffic_definition.return_value = "64"
         mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -207,17 +216,15 @@ class TestIxLoadTrafficGen(unittest.TestCase):
             sut.connection = mock.Mock()
             sut.connection.run = mock.Mock()
             sut._traffic_runner = mock.Mock(return_value=0)
-            shutil.copy = mock.Mock()
             result = sut.run_traffic(mock_traffic_profile)
             self.assertIsNone(result)
 
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.open")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.min")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.max")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.len")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
-    def test_run_traffic_csv(self, shutil, *args):
+    def test_run_traffic_csv(self, *args):
         mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
         mock_traffic_profile.get_traffic_definition.return_value = "64"
         mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -238,7 +245,6 @@ class TestIxLoadTrafficGen(unittest.TestCase):
             sut.connection = mock.Mock()
             sut.connection.run = mock.Mock()
             sut._traffic_runner = mock.Mock(return_value=0)
-            shutil.copy = mock.Mock()
             subprocess.call(["touch", "/tmp/1.csv"])
             sut.rel_bin_path = mock.Mock(return_value="/tmp/*.csv")
             result = sut.run_traffic(mock_traffic_profile)
@@ -251,9 +257,8 @@ class TestIxLoadTrafficGen(unittest.TestCase):
         ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
         self.assertIsNone(ixload_traffic_gen.terminate())
 
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
-    @mock.patch.object(ssh, 'SSH')
-    def test_parse_csv_read(self, mock_ssh, *args):
+    @mock.patch("yardstick.ssh.SSH")
+    def test_parse_csv_read(self, mock_ssh):
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         kpi_data = {
             'HTTP Total Throughput (Kbps)': 1,
@@ -275,9 +280,8 @@ class TestIxLoadTrafficGen(unittest.TestCase):
         for key_left, key_right in IxLoadResourceHelper.KPI_LIST.items():
             self.assertEqual(result[key_left][-1], int(kpi_data[key_right]))
 
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
-    @mock.patch.object(ssh, 'SSH')
-    def test_parse_csv_read_value_error(self, mock_ssh, *args):
+    @mock.patch("yardstick.ssh.SSH")
+    def test_parse_csv_read_value_error(self, mock_ssh):
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         http_reader = [{
             'HTTP Total Throughput (Kbps)': 1,
@@ -297,9 +301,8 @@ class TestIxLoadTrafficGen(unittest.TestCase):
         ixload_traffic_gen.resource_helper.parse_csv_read(http_reader)
         self.assertDictEqual(ixload_traffic_gen.resource_helper.result, init_value)
 
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
     @mock.patch.object(ssh, 'SSH')
-    def test_parse_csv_read_error(self, mock_ssh, *args):
+    def test_parse_csv_read_error(self, mock_ssh):
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         http_reader = [{
             'HTTP Total Throughput (Kbps)': 1,
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-
-import unittest
-import mock
 from multiprocessing import Queue
 import multiprocessing
 
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
-from tests.unit import STL_MOCKS
+import mock
+import unittest
+
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
 
 SSH_HELPER = "yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper"
 
@@ -16,8 +16,8 @@
 import unittest
 import mock
 
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
-from tests.unit import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
 
 
 SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -19,7 +19,7 @@ import mock
 import six
 import unittest
 
-from tests.unit import STL_MOCKS
+from yardstick.tests import STL_MOCKS
 
 STLClient = mock.MagicMock()
 stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -36,7 +36,8 @@ TEST_FILE_YAML = 'nsb_test_case.yaml'
 NAME = "tg__1"
 
 
-@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
+@mock.patch(
+    "yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
 class TestIxiaResourceHelper(unittest.TestCase):
     def test___init___with_custom_rfc_helper(self, *args):
         class MyRfcHelper(IxiaRfc2544Helper):
@@ -55,21 +56,22 @@ class TestIxiaResourceHelper(unittest.TestCase):
         self.assertEqual(mock_client.ix_stop_traffic.call_count, 1)
 
 
-@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
+@mock.patch(
+    "yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
 class TestIXIATrafficGen(unittest.TestCase):
     VNFD = {'vnfd:vnfd-catalog':
-                {'vnfd':
-                     [{'short-name': 'VpeVnf',
-                       'vdu':
-                           [{'routing_table':
-                                 [{'network': '152.16.100.20',
-                                   'netmask': '255.255.255.0',
-                                   'gateway': '152.16.100.20',
-                                   'if': 'xe0'},
-                                  {'network': '152.16.40.20',
-                                   'netmask': '255.255.255.0',
-                                   'gateway': '152.16.40.20',
-                                   'if': 'xe1'}],
+            {'vnfd':
+             [{'short-name': 'VpeVnf',
+               'vdu':
+               [{'routing_table':
+                             [{'network': '152.16.100.20',
+                               'netmask': '255.255.255.0',
+                               'gateway': '152.16.100.20',
+                               'if': 'xe0'},
+                              {'network': '152.16.40.20',
+                               'netmask': '255.255.255.0',
+                               'gateway': '152.16.40.20',
+                               'if': 'xe1'}],
                              'description': 'VPE approximation using DPDK',
                              'name': 'vpevnf-baremetal',
                              'nd_route_tbl':
@@ -84,45 +86,46 @@ class TestIXIATrafficGen(unittest.TestCase):
                              'id': 'vpevnf-baremetal',
                              'external-interface':
                                  [{'virtual-interface':
-                                       {'dst_mac': '00:00:00:00:00:04',
-                                        'vpci': '0000:05:00.0',
-                                        'local_ip': '152.16.100.19',
-                                        'type': 'PCI-PASSTHROUGH',
-                                        'netmask': '255.255.255.0',
-                                        'dpdk_port_num': 0,
-                                        'bandwidth': '10 Gbps',
-                                        'driver': "i40e",
-                                        'dst_ip': '152.16.100.20',
-                                        'local_iface_name': 'xe0',
-                                        'local_mac': '00:00:00:00:00:02'},
+                                   {'dst_mac': '00:00:00:00:00:04',
+                                    'vpci': '0000:05:00.0',
+                                    'local_ip': '152.16.100.19',
+                                    'type': 'PCI-PASSTHROUGH',
+                                    'netmask': '255.255.255.0',
+                                    'dpdk_port_num': 0,
+                                    'bandwidth': '10 Gbps',
+                                    'driver': "i40e",
+                                    'dst_ip': '152.16.100.20',
+                                    'local_iface_name': 'xe0',
+                                    'local_mac': '00:00:00:00:00:02'},
                                    'vnfd-connection-point-ref': 'xe0',
                                    'name': 'xe0'},
                                   {'virtual-interface':
-                                       {'dst_mac': '00:00:00:00:00:03',
-                                        'vpci': '0000:05:00.1',
-                                        'local_ip': '152.16.40.19',
-                                        'type': 'PCI-PASSTHROUGH',
-                                        'driver': "i40e",
-                                        'netmask': '255.255.255.0',
-                                        'dpdk_port_num': 1,
-                                        'bandwidth': '10 Gbps',
-                                        'dst_ip': '152.16.40.20',
-                                        'local_iface_name': 'xe1',
-                                        'local_mac': '00:00:00:00:00:01'},
+                                   {'dst_mac': '00:00:00:00:00:03',
+                                    'vpci': '0000:05:00.1',
+                                    'local_ip': '152.16.40.19',
+                                    'type': 'PCI-PASSTHROUGH',
+                                    'driver': "i40e",
+                                    'netmask': '255.255.255.0',
+                                    'dpdk_port_num': 1,
+                                    'bandwidth': '10 Gbps',
+                                    'dst_ip': '152.16.40.20',
+                                    'local_iface_name': 'xe1',
+                                    'local_mac': '00:00:00:00:00:01'},
                                    'vnfd-connection-point-ref': 'xe1',
                                    'name': 'xe1'}]}],
-                       'description': 'Vpe approximation using DPDK',
-                       'mgmt-interface':
-                           {'vdu-id': 'vpevnf-baremetal',
-                            'host': '1.1.1.1',
-                            'password': 'r00t',
+               'description': 'Vpe approximation using DPDK',
+               'mgmt-interface':
+               {'vdu-id': 'vpevnf-baremetal',
+                'host': '1.1.1.1',
+                'password': 'r00t',
                             'user': 'root',
                             'ip': '1.1.1.1'},
-                       'benchmark':
-                           {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
-                       'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
-                                            {'type': 'VPORT', 'name': 'xe1'}],
-                       'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
+               'benchmark':
+               {'kpi': ['packets_in', 'packets_fwd',
+                        'packets_dropped']},
+               'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
+                                    {'type': 'VPORT', 'name': 'xe1'}],
+               'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
 
     TRAFFIC_PROFILE = {
         "schema": "isb:traffic_profile:0.1",
@@ -135,7 +138,7 @@ class TestIXIATrafficGen(unittest.TestCase):
             "frame_size": 64}}
 
     TC_YAML = {'scenarios': [{'tc_options':
-                                  {'rfc2544': {'allowed_drop_rate': '0.8 - 1'}},
+                              {'rfc2544': {'allowed_drop_rate': '0.8 - 1'}},
                               'runner': {'duration': 400,
                                          'interval': 35, 'type': 'Duration'},
                               'traffic_options':
@@ -184,16 +187,20 @@ class TestIXIATrafficGen(unittest.TestCase):
             ixnet_traffic_gen = IxiaTrafficGen(NAME, vnfd)
             scenario_cfg = {'tc': "nsb_test_case", "topology": "",
                             'ixia_profile': "ixload.cfg"}
-            scenario_cfg.update({'options': {'packetsize': 64,
-                                             'traffic_type': 4,
-                                             'rfc2544': {'allowed_drop_rate': '0.8 - 1'},
-                                             'vnf__1': {'rules': 'acl_1rule.yaml',
-                                                        'vnf_config': {'lb_config': 'SW',
-                                                                       'lb_count': 1,
-                                                                       'worker_config':
-                                                                           '1C/1T',
-                                                                       'worker_threads': 1}}
-                                             }})
+            scenario_cfg.update(
+                {
+                    'options': {
+                        'packetsize': 64,
+                        'traffic_type': 4,
+                        'rfc2544': {
+                            'allowed_drop_rate': '0.8 - 1'},
+                        'vnf__1': {
+                            'rules': 'acl_1rule.yaml',
+                            'vnf_config': {
+                                'lb_config': 'SW',
+                                'lb_count': 1,
+                                'worker_config': '1C/1T',
+                                'worker_threads': 1}}}})
             ixnet_traffic_gen.topology = ""
             ixnet_traffic_gen.get_ixobj = mock.MagicMock()
             ixnet_traffic_gen._ixia_traffic_gen = mock.MagicMock()
@@ -240,7 +247,8 @@ class TestIXIATrafficGen(unittest.TestCase):
         sut = IxiaTrafficGen('vnf1', vnfd)
         sut._check_status()
 
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.time")
+    @mock.patch(
+        "yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.time")
     @mock.patch("yardstick.ssh.SSH")
     def test_traffic_runner(self, mock_ssh, *args):
         mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
@@ -299,8 +307,10 @@ class TestIXIATrafficGen(unittest.TestCase):
             },
         ]
 
-        mock_traffic_profile.execute_traffic.return_value = ['Completed', samples]
-        mock_traffic_profile.get_drop_percentage.return_value = ['Completed', samples]
+        mock_traffic_profile.execute_traffic.return_value = [
+            'Completed', samples]
+        mock_traffic_profile.get_drop_percentage.return_value = [
+            'Completed', samples]
 
         sut = IxiaTrafficGen(name, vnfd)
         sut.vnf_port_pairs = [[[0], [1]]]
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-
 import unittest
 import mock
 
-from tests.unit import STL_MOCKS
+from yardstick.tests import STL_MOCKS
 SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
 
 
@@ -31,7 +29,8 @@ if stl_patch:
         TrexRfcResourceHelper
     from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_trex
     from yardstick.network_services.traffic_profile.base import TrafficProfile
-    from tests.unit.network_services.vnf_generic.vnf.test_base import FileAbsPath, mock_ssh
+    from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base \
+        import FileAbsPath, mock_ssh
 
 MODULE_PATH = FileAbsPath(__file__)
 get_file_abspath = MODULE_PATH.get_path
 #
 
 import copy
-import mock
 
+import mock
 import unittest
 
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
-from tests.unit import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
 
 
 SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -37,18 +37,18 @@ if stl_patch:
 
 class TestTrexTrafficGen(unittest.TestCase):
     VNFD = {'vnfd:vnfd-catalog':
-                {'vnfd':
-                     [{'short-name': 'VpeVnf',
-                       'vdu':
-                           [{'routing_table':
-                                 [{'network': '152.16.100.20',
-                                   'netmask': '255.255.255.0',
-                                   'gateway': '152.16.100.20',
-                                   'if': 'xe0'},
-                                  {'network': '152.16.40.20',
-                                   'netmask': '255.255.255.0',
-                                   'gateway': '152.16.40.20',
-                                   'if': 'xe1'}],
+            {'vnfd':
+             [{'short-name': 'VpeVnf',
+               'vdu':
+               [{'routing_table':
+                             [{'network': '152.16.100.20',
+                               'netmask': '255.255.255.0',
+                               'gateway': '152.16.100.20',
+                               'if': 'xe0'},
+                              {'network': '152.16.40.20',
+                               'netmask': '255.255.255.0',
+                               'gateway': '152.16.40.20',
+                               'if': 'xe1'}],
                              'description': 'VPE approximation using DPDK',
                              'name': 'vpevnf-baremetal',
                              'nd_route_tbl':
@@ -63,49 +63,50 @@ class TestTrexTrafficGen(unittest.TestCase):
                              'id': 'vpevnf-baremetal',
                              'external-interface':
                                  [{'virtual-interface':
-                                       {'dst_mac': '00:00:00:00:00:04',
-                                        'vpci': '0000:05:00.0',
-                                        'local_ip': '152.16.100.19',
-                                        'type': 'PCI-PASSTHROUGH',
-                                        'netmask': '255.255.255.0',
-                                        'dpdk_port_num': 0,
-                                        'bandwidth': '10 Gbps',
-                                        'driver': "i40e",
-                                        'dst_ip': '152.16.100.20',
-                                        'local_iface_name': 'xe0',
-                                        'vld_id': 'downlink_0',
-                                        'ifname': 'xe0',
-                                        'local_mac': '00:00:00:00:00:02'},
+                                   {'dst_mac': '00:00:00:00:00:04',
+                                    'vpci': '0000:05:00.0',
+                                    'local_ip': '152.16.100.19',
+                                    'type': 'PCI-PASSTHROUGH',
+                                    'netmask': '255.255.255.0',
+                                    'dpdk_port_num': 0,
+                                    'bandwidth': '10 Gbps',
+                                    'driver': "i40e",
+                                    'dst_ip': '152.16.100.20',
+                                    'local_iface_name': 'xe0',
+                                    'vld_id': 'downlink_0',
+                                    'ifname': 'xe0',
+                                    'local_mac': '00:00:00:00:00:02'},
                                    'vnfd-connection-point-ref': 'xe0',
                                    'name': 'xe0'},
                                   {'virtual-interface':
-                                       {'dst_mac': '00:00:00:00:00:03',
-                                        'vpci': '0000:05:00.1',
-                                        'local_ip': '152.16.40.19',
-                                        'type': 'PCI-PASSTHROUGH',
-                                        'driver': "i40e",
-                                        'netmask': '255.255.255.0',
-                                        'dpdk_port_num': 1,
-                                        'bandwidth': '10 Gbps',
-                                        'dst_ip': '152.16.40.20',
-                                        'local_iface_name': 'xe1',
-                                        'vld_id': 'uplink_0',
-                                        'ifname': 'xe1',
-                                        'local_mac': '00:00:00:00:00:01'},
+                                   {'dst_mac': '00:00:00:00:00:03',
+                                    'vpci': '0000:05:00.1',
+                                    'local_ip': '152.16.40.19',
+                                    'type': 'PCI-PASSTHROUGH',
+                                    'driver': "i40e",
+                                    'netmask': '255.255.255.0',
+                                    'dpdk_port_num': 1,
+                                    'bandwidth': '10 Gbps',
+                                    'dst_ip': '152.16.40.20',
+                                    'local_iface_name': 'xe1',
+                                    'vld_id': 'uplink_0',
+                                    'ifname': 'xe1',
+                                    'local_mac': '00:00:00:00:00:01'},
                                    'vnfd-connection-point-ref': 'xe1',
                                    'name': 'xe1'}]}],
-                       'description': 'Vpe approximation using DPDK',
-                       'mgmt-interface':
-                           {'vdu-id': 'vpevnf-baremetal',
-                            'host': '1.1.1.1',
-                            'password': 'r00t',
+               'description': 'Vpe approximation using DPDK',
+               'mgmt-interface':
+               {'vdu-id': 'vpevnf-baremetal',
+                'host': '1.1.1.1',
+                'password': 'r00t',
                             'user': 'root',
                             'ip': '1.1.1.1'},
-                       'benchmark':
-                           {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
-                       'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
-                                            {'type': 'VPORT', 'name': 'xe1'}],
-                       'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
+               'benchmark':
+               {'kpi': ['packets_in', 'packets_fwd',
+                        'packets_dropped']},
+               'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
+                                    {'type': 'VPORT', 'name': 'xe1'}],
+               'id': 'VpeApproxVnf', 'name': 'VPEVnfSsh'}]}}
 
     TRAFFIC_PROFILE = {
         "schema": "isb:traffic_profile:0.1",
@@ -301,7 +302,8 @@ class TestTrexTrafficGen(unittest.TestCase):
         mock_ssh(ssh)
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         trex_traffic_gen = TrexTrafficGen(NAME, vnfd)
-        self.assertIsInstance(trex_traffic_gen.resource_helper, TrexResourceHelper)
+        self.assertIsInstance(
+            trex_traffic_gen.resource_helper, TrexResourceHelper)
 
     @mock.patch(SSH_HELPER)
     def test_collect_kpi(self, ssh):
@@ -334,7 +336,8 @@ class TestTrexTrafficGen(unittest.TestCase):
         trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
         trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock()
 
-        self.assertIsNone(trex_traffic_gen.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
+        self.assertIsNone(trex_traffic_gen.instantiate(
+            self.SCENARIO_CFG, self.CONTEXT_CFG))
 
     @mock.patch(SSH_HELPER)
     def test_instantiate_error(self, ssh):
@@ -349,7 +352,8 @@ class TestTrexTrafficGen(unittest.TestCase):
         trex_traffic_gen.ssh_helper = mock.MagicMock()
         trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
         trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock()
-        self.assertIsNone(trex_traffic_gen.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
+        self.assertIsNone(trex_traffic_gen.instantiate(
+            self.SCENARIO_CFG, self.CONTEXT_CFG))
 
     @mock.patch(SSH_HELPER)
     def test__start_server(self, ssh):
@@ -368,7 +372,8 @@ class TestTrexTrafficGen(unittest.TestCase):
         trex_traffic_gen = TrexTrafficGen(NAME, vnfd)
         trex_traffic_gen.ssh_helper = mock.MagicMock()
         trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
-        trex_traffic_gen.scenario_helper.scenario_cfg = {"options": {NAME: {"queues_per_port": 2}}}
+        trex_traffic_gen.scenario_helper.scenario_cfg = {
+            "options": {NAME: {"queues_per_port": 2}}}
         self.assertIsNone(trex_traffic_gen._start_server())
 
     @mock.patch(SSH_HELPER)
@@ -406,42 +411,43 @@ class TestTrexTrafficGen(unittest.TestCase):
         vnfd = copy.deepcopy(self.VNFD['vnfd:vnfd-catalog']['vnfd'][0])
         vnfd['vdu'][0]['external-interface'] = [
             {'virtual-interface':
-                 {'dst_mac': '00:00:00:00:00:04',
-                  'vpci': '0000:05:00.0',
-                  'local_ip': '152.16.100.19',
-                  'type': 'PCI-PASSTHROUGH',
-                  'netmask': '255.255.255.0',
-                  'dpdk_port_num': 2,
-                  'bandwidth': '10 Gbps',
-                  'driver': "i40e",
-                  'dst_ip': '152.16.100.20',
-                  'local_iface_name': 'xe0',
-                  'vld_id': 'downlink_0',
-                  'ifname': 'xe0',
-                  'local_mac': '00:00:00:00:00:02'},
+             {'dst_mac': '00:00:00:00:00:04',
+              'vpci': '0000:05:00.0',
+              'local_ip': '152.16.100.19',
+              'type': 'PCI-PASSTHROUGH',
+              'netmask': '255.255.255.0',
+              'dpdk_port_num': 2,
+              'bandwidth': '10 Gbps',
+              'driver': "i40e",
+              'dst_ip': '152.16.100.20',
+              'local_iface_name': 'xe0',
+              'vld_id': 'downlink_0',
+              'ifname': 'xe0',
+              'local_mac': '00:00:00:00:00:02'},
              'vnfd-connection-point-ref': 'xe0',
              'name': 'xe0'},
             {'virtual-interface':
-                 {'dst_mac': '00:00:00:00:00:03',
-                  'vpci': '0000:04:00.0',
-                  'local_ip': '152.16.40.19',
-                  'type': 'PCI-PASSTHROUGH',
-                  'driver': "i40e",
-                  'netmask': '255.255.255.0',
-                  'dpdk_port_num': 0,
-                  'bandwidth': '10 Gbps',
-                  'dst_ip': '152.16.40.20',
-                  'local_iface_name': 'xe1',
-                  'vld_id': 'uplink_0',
-                  'ifname': 'xe1',
-                  'local_mac': '00:00:00:00:00:01'},
+             {'dst_mac': '00:00:00:00:00:03',
+              'vpci': '0000:04:00.0',
+              'local_ip': '152.16.40.19',
+              'type': 'PCI-PASSTHROUGH',
+              'driver': "i40e",
+              'netmask': '255.255.255.0',
+              'dpdk_port_num': 0,
+              'bandwidth': '10 Gbps',
+              'dst_ip': '152.16.40.20',
+              'local_iface_name': 'xe1',
+              'vld_id': 'uplink_0',
+              'ifname': 'xe1',
+              'local_mac': '00:00:00:00:00:01'},
              'vnfd-connection-point-ref': 'xe1',
              'name': 'xe1'}]
         trex_traffic_gen = TrexTrafficGen(NAME, vnfd)
         trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
         trex_traffic_gen.resource_helper.generate_cfg()
         trex_traffic_gen.resource_helper._build_ports()
-        self.assertEqual(sorted(trex_traffic_gen.resource_helper.all_ports), [0, 1])
+        self.assertEqual(
+            sorted(trex_traffic_gen.resource_helper.all_ports), [0, 1])
         # there is a gap in ordering
         self.assertEqual(dict(trex_traffic_gen.resource_helper.dpdk_to_trex_port_map),
                          {0: 0, 2: 1})
@@ -17,8 +17,8 @@ import unittest
 import mock
 import os
 
-from tests.unit import STL_MOCKS
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 
 
 SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -335,16 +335,18 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
         mock_ssh(ssh)
 
         vnfd = self.VNFD_0
-        result = "stats\r\r\n\r\nUDP_Replay stats:\r\n--------------\r\n" \
-                 "Port\t\tRx Packet\t\tTx Packet\t\tRx Pkt Drop\t\tTx Pkt Drop \r\n"\
-                 "0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \
-                 "1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>"
+        get_stats_ret_val = \
+            "stats\r\r\n\r\nUDP_Replay stats:\r\n--------------\r\n" \
+            "Port\t\tRx Packet\t\tTx Packet\t\tRx Pkt Drop\t\tTx Pkt Drop \r\n"\
+            "0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \
+            "1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>"
         udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
         udp_replay_approx_vnf.q_in = mock.MagicMock()
         udp_replay_approx_vnf.q_out = mock.MagicMock()
         udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
         udp_replay_approx_vnf.all_ports = ["xe0", "xe1"]
-        udp_replay_approx_vnf.get_stats = mock.Mock(return_value=result)
+        udp_replay_approx_vnf.get_stats = mock.Mock(return_value=get_stats_ret_val)
+
         result = {'collect_stats': {}, 'packets_dropped': 0,
                   'packets_fwd': 14748451, 'packets_in': 14748472}
         self.assertEqual(result, udp_replay_approx_vnf.collect_kpi())
@@ -17,8 +17,8 @@ import unittest
 import mock
 import os
 
-from tests.unit import STL_MOCKS
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 
 from yardstick.common import utils
 
@@ -253,9 +253,9 @@ VFW TOTAL: pkts_received: 6007180, "pkts_fw_forwarded": 6007180, "pkts_drop_fw":
 "CT TOTAL: ct_packets_forwarded" : 6007180, " ct_packets_dropped" : 0, "ct_sessions" : {"active" : 130050, "open_attempt" : 130050, "re-open_attempt" : 0, "established" : 0, "closed" : 0, "timeout" : 0}, "ct_drops" : {"out_of_window" : 0, "invalid_conn" : 0, "invalid_state_transition" : 0 "RST" : 0}
 Action ID: 00, packetCount: 2954633, byteCount: 177277980
 Action ID: 01, packetCount: 3052547, byteCount: 183152820
-pipeline> 
+pipeline>
 
-pipeline> 
+pipeline>
 """  # noqa
 
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@@ -21,9 +21,9 @@ import mock
 from six.moves import configparser
 import unittest
 
-from tests.unit import STL_MOCKS
-from tests.unit.network_services.vnf_generic.vnf.test_base import FileAbsPath
-from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.tests import STL_MOCKS
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import FileAbsPath
+from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
 from yardstick.network_services.vnf_generic.vnf.base import QueueFileWrapper
 from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
 
@@ -631,7 +631,7 @@ class TestVpeApproxVnf(unittest.TestCase):
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
     @mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.ConfigCreate")
-    @mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.open")
+    @mock.patch("six.moves.builtins.open")
     @mock.patch(SSH_HELPER)
     def test_build_config(self, ssh, *args):
         mock_ssh(ssh)