summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-05-16 08:40:48 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-05-16 08:40:48 +0000
commit74db27b3fc0447cceda2f60e3bf05420d5bad8b9 (patch)
treea2900d49de6ef2069e78c235353765a9bc84c3d3
parent66917569097cdbe8cf2716c4d31f5ab6234ae2ff (diff)
parent065c00d3147d12c692d43179d9c1c9afadb97825 (diff)
Merge "Move tests: unit/network_services/helpers"
-rw-r--r--yardstick/tests/unit/network_services/helpers/__init__.py (renamed from tests/unit/network_services/helpers/__init__.py)0
-rw-r--r--yardstick/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml (renamed from tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml)0
-rw-r--r--yardstick/tests/unit/network_services/helpers/test_cpu.py (renamed from tests/unit/network_services/helpers/test_cpu.py)36
-rw-r--r--yardstick/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py (renamed from tests/unit/network_services/helpers/test_dpdkbindnic_helper.py)0
-rw-r--r--yardstick/tests/unit/network_services/helpers/test_iniparser.py (renamed from tests/unit/network_services/helpers/test_iniparser.py)8
-rw-r--r--yardstick/tests/unit/network_services/helpers/test_samplevnf_helper.py (renamed from tests/unit/network_services/helpers/test_samplevnf_helper.py)1
6 files changed, 23 insertions, 22 deletions
diff --git a/tests/unit/network_services/helpers/__init__.py b/yardstick/tests/unit/network_services/helpers/__init__.py
index e69de29bb..e69de29bb 100644
--- a/tests/unit/network_services/helpers/__init__.py
+++ b/yardstick/tests/unit/network_services/helpers/__init__.py
diff --git a/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml b/yardstick/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml
index f60834fbd..f60834fbd 100644
--- a/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml
+++ b/yardstick/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml
diff --git a/tests/unit/network_services/helpers/test_cpu.py b/yardstick/tests/unit/network_services/helpers/test_cpu.py
index 1f9d3f219..871fbf8c9 100644
--- a/tests/unit/network_services/helpers/test_cpu.py
+++ b/yardstick/tests/unit/network_services/helpers/test_cpu.py
@@ -13,7 +13,6 @@
# limitations under the License.
#
-from __future__ import absolute_import
from __future__ import division
import unittest
import mock
@@ -25,15 +24,20 @@ from yardstick.network_services.helpers.cpu import \
class TestCpuSysCores(unittest.TestCase):
+ def setUp(self):
+ self._mock_ssh = mock.patch("yardstick.ssh.SSH")
+ self.mock_ssh = self._mock_ssh.start()
+
+ self.addCleanup(self._cleanup)
+
+ def _cleanup(self):
+ self._mock_ssh.stop()
+
def test___init__(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "", ""))
- ssh_mock.put = \
- mock.Mock(return_value=(1, "", ""))
- cpu_topo = CpuSysCores(ssh_mock)
- self.assertIsNotNone(cpu_topo.connection)
+ self.mock_ssh.execute.return_value = 1, "", ""
+ self.mock_ssh.put.return_value = 1, "", ""
+ cpu_topo = CpuSysCores(self.mock_ssh)
+ self.assertIsNotNone(cpu_topo.connection)
def test__get_core_details(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
@@ -52,7 +56,7 @@ class TestCpuSysCores(unittest.TestCase):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+ mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
ssh_mock.put = \
mock.Mock(return_value=(1, "", ""))
cpu_topo = CpuSysCores(ssh_mock)
@@ -68,7 +72,7 @@ class TestCpuSysCores(unittest.TestCase):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+ mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
ssh_mock.put = \
mock.Mock(return_value=(1, "", ""))
cpu_topo = CpuSysCores(ssh_mock)
@@ -77,14 +81,14 @@ class TestCpuSysCores(unittest.TestCase):
mock.Mock(side_effect=[[{'Core(s) per socket': '2', 'Thread(s) per core': '1'}],
[{'physical id': '2', 'processor': '1'}]])
cpu_topo.core_map = \
- {'thread_per_core': '1', '2':['1'], 'cores_per_socket': '2'}
+ {'thread_per_core': '1', '2': ['1'], 'cores_per_socket': '2'}
self.assertEqual(-1, cpu_topo.validate_cpu_cfg())
def test_validate_cpu_cfg_2t(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+ mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
ssh_mock.put = \
mock.Mock(return_value=(1, "", ""))
cpu_topo = CpuSysCores(ssh_mock)
@@ -93,7 +97,7 @@ class TestCpuSysCores(unittest.TestCase):
mock.Mock(side_effect=[[{'Core(s) per socket': '2', 'Thread(s) per core': '1'}],
[{'physical id': '2', 'processor': '1'}]])
cpu_topo.core_map = \
- {'thread_per_core': 1, '2':['1'], 'cores_per_socket': '2'}
+ {'thread_per_core': 1, '2': ['1'], 'cores_per_socket': '2'}
vnf_cfg = {'lb_config': 'SW', 'lb_count': 1, 'worker_config':
'1C/2T', 'worker_threads': 1}
self.assertEqual(-1, cpu_topo.validate_cpu_cfg(vnf_cfg))
@@ -102,7 +106,7 @@ class TestCpuSysCores(unittest.TestCase):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
- mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+ mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
ssh_mock.put = \
mock.Mock(return_value=(1, "", ""))
cpu_topo = CpuSysCores(ssh_mock)
@@ -111,7 +115,7 @@ class TestCpuSysCores(unittest.TestCase):
mock.Mock(side_effect=[[{'Core(s) per socket': '2', 'Thread(s) per core': '1'}],
[{'physical id': '2', 'processor': '1'}]])
cpu_topo.core_map = \
- {'thread_per_core': 1, '2':[1], 'cores_per_socket': 2}
+ {'thread_per_core': 1, '2': [1], 'cores_per_socket': 2}
vnf_cfg = {'lb_config': 'SW', 'lb_count': 1, 'worker_config':
'1C/1T', 'worker_threads': 1}
self.assertEqual(-1, cpu_topo.validate_cpu_cfg(vnf_cfg))
diff --git a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py b/yardstick/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
index 367072e84..367072e84 100644
--- a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
+++ b/yardstick/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
diff --git a/tests/unit/network_services/helpers/test_iniparser.py b/yardstick/tests/unit/network_services/helpers/test_iniparser.py
index bd27b497e..1a09f0761 100644
--- a/tests/unit/network_services/helpers/test_iniparser.py
+++ b/yardstick/tests/unit/network_services/helpers/test_iniparser.py
@@ -13,13 +13,11 @@
# limitations under the License.
#
-from __future__ import absolute_import
-
import unittest
from contextlib import contextmanager
import mock
-from tests.unit import STL_MOCKS
+from yardstick.tests import STL_MOCKS
STLClient = mock.MagicMock()
@@ -105,7 +103,7 @@ class TestBaseParser(unittest.TestCase):
@staticmethod
def make_open(text_blob):
@contextmanager
- def internal_open(*args, **kwargs):
+ def internal_open(*args):
yield text_blob.split('\n')
return internal_open
@@ -136,7 +134,7 @@ class TestConfigParser(unittest.TestCase):
@staticmethod
def make_open(text_blob):
@contextmanager
- def internal_open(*args, **kwargs):
+ def internal_open(*args):
yield text_blob.split('\n')
return internal_open
diff --git a/tests/unit/network_services/helpers/test_samplevnf_helper.py b/yardstick/tests/unit/network_services/helpers/test_samplevnf_helper.py
index dc74b1859..6d5e1da60 100644
--- a/tests/unit/network_services/helpers/test_samplevnf_helper.py
+++ b/yardstick/tests/unit/network_services/helpers/test_samplevnf_helper.py
@@ -756,7 +756,6 @@ class TestMultiPortConfig(unittest.TestCase):
self.assertIsNone(result)
def test_generate_arp_route_tbl(self):
- # ELF: could n=do this in setup
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = ""