summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml8
-rw-r--r--tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml4
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py1
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_util.py4
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vnf_generic.py52
-rw-r--r--tests/unit/common/test_process.py46
-rw-r--r--tests/unit/common/test_utils.py16
-rw-r--r--tests/unit/network_services/collector/test_subscriber.py1
-rw-r--r--tests/unit/network_services/helpers/test_dpdkbindnic_helper.py51
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py36
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py26
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py9
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py7
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py27
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py5
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py12
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py4
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py5
18 files changed, 231 insertions, 83 deletions
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
index 322e2bd76..28aa0b6bd 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc057.yaml
@@ -81,7 +81,7 @@ scenarios:
action_parameter:
vip_name: {{vip_mgmt}}
return_parameter:
- all: "$vip_mgmt_host"
+ all: "@vip_mgmt_host"
-
operation_type: "general-operation"
@@ -91,7 +91,7 @@ scenarios:
action_parameter:
vip_name: {{vip_vrouter}}
return_parameter:
- all: "$vip_router_host"
+ all: "@vip_router_host"
resultCheckers:
-
@@ -101,7 +101,7 @@ scenarios:
host: {{check_host}}
parameter:
resource_name: "p_rabbitmq-server"
- resource_host: "$vip_mgmt_host"
+ resource_host: "@vip_mgmt_host"
expectedValue: "Masters"
condition: "in"
@@ -112,7 +112,7 @@ scenarios:
host: {{check_host}}
parameter:
resource_name: "p_conntrackd"
- resource_host: "$vip_router_host"
+ resource_host: "@vip_router_host"
expectedValue: "Masters"
condition: "in"
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
index dc0675bec..7fb7daf62 100644
--- a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
+++ b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
@@ -48,7 +48,7 @@ scenarios:
sla:
max_outage_time: 5
parameter:
- ip_address: "$floating_ip"
+ ip_address: "@floating_ip"
operations:
-
@@ -58,7 +58,7 @@ scenarios:
action_parameter:
server_name: "tc058"
return_parameter:
- all: "$floating_ip"
+ all: "@floating_ip"
steps:
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index 2e546805d..223d64060 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -201,6 +201,7 @@ class HeatContextTestCase(unittest.TestCase):
"subnet_cidr": '10.20.0.0/15',
"network": '10.20.0.0',
"netmask": '255.254.0.0',
+ "name": "port_a",
"gateway_ip": '10.20.30.1',
"mac_address": '00:01',
"device_id": 'dev21',
diff --git a/tests/unit/benchmark/scenarios/availability/test_util.py b/tests/unit/benchmark/scenarios/availability/test_util.py
index 2e4fff417..0974f385a 100644
--- a/tests/unit/benchmark/scenarios/availability/test_util.py
+++ b/tests/unit/benchmark/scenarios/availability/test_util.py
@@ -20,8 +20,8 @@ from yardstick.benchmark.scenarios.availability import util
class ExecuteShellTestCase(unittest.TestCase):
def setUp(self):
- self.param_config = {'serviceName': '$serviceName', 'value': 1}
- self.intermediate_variables = {'$serviceName': 'nova-api'}
+ self.param_config = {'serviceName': '@serviceName', 'value': 1}
+ self.intermediate_variables = {'@serviceName': 'nova-api'}
self.std_output = '| id | 1 |'
self.cmd_config = {'cmd':'ls','param':'-a'}
diff --git a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
index 5b15daca4..016608a21 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
+++ b/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
@@ -445,6 +445,13 @@ class TestNetworkServiceTestCase(unittest.TestCase):
self.assertIsNotNone(
self.s.load_vnf_models(self.scenario_cfg, self.context_cfg))
+ def test_load_vnf_models_no_model(self):
+ vnf = mock.Mock(autospec=GenericVNF)
+ self.s.get_vnf_impl = mock.Mock(return_value=vnf)
+
+ self.assertIsNotNone(
+ self.s.load_vnf_models(self.scenario_cfg, self.context_cfg))
+
def test_map_topology_to_infrastructure(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -568,6 +575,35 @@ class TestNetworkServiceTestCase(unittest.TestCase):
mock.Mock(return_value=TRAFFIC_PROFILE)
self.assertEqual(None, self.s.setup())
+ def test_setup_exception(self):
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, SYS_CLASS_NET + IP_ADDR_SHOW, ""))
+ ssh.from_node.return_value = ssh_mock
+
+ tgen = mock.Mock(autospec=GenericTrafficGen)
+ tgen.traffic_finished = True
+ verified_dict = {"verified": True}
+ tgen.verify_traffic = lambda x: verified_dict
+ tgen.terminate = mock.Mock(return_value=True)
+ tgen.name = "tgen__1"
+ vnf = mock.Mock(autospec=GenericVNF)
+ vnf.runs_traffic = False
+ vnf.instantiate.side_effect = RuntimeError("error during instantiate")
+ vnf.terminate = mock.Mock(return_value=True)
+ self.s.vnfs = [tgen, vnf]
+ self.s.traffic_profile = mock.Mock()
+ self.s.collector = mock.Mock(autospec=Collector)
+ self.s.collector.get_kpi = \
+ mock.Mock(return_value={tgen.name: verified_dict})
+ self.s.map_topology_to_infrastructure = mock.Mock(return_value=0)
+ self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs)
+ self.s._fill_traffic_profile = \
+ mock.Mock(return_value=TRAFFIC_PROFILE)
+ with self.assertRaises(RuntimeError):
+ self.s.setup()
+
def test__get_traffic_profile(self):
self.scenario_cfg["traffic_profile"] = \
self._get_file_abspath("ipv4_throughput_vpe.yaml")
@@ -594,8 +630,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
def test_teardown(self):
vnf = mock.Mock(autospec=GenericVNF)
- vnf.terminate = \
- mock.Mock(return_value=True)
+ vnf.terminate = mock.Mock(return_value=True)
+ vnf.name = str(vnf)
self.s.vnfs = [vnf]
self.s.traffic_profile = mock.Mock()
self.s.collector = mock.Mock(autospec=Collector)
@@ -603,6 +639,18 @@ class TestNetworkServiceTestCase(unittest.TestCase):
mock.Mock(return_value=True)
self.assertIsNone(self.s.teardown())
+ def test_teardown_exception(self):
+ vnf = mock.Mock(autospec=GenericVNF)
+ vnf.terminate = mock.Mock(side_effect=RuntimeError("error duing terminate"))
+ vnf.name = str(vnf)
+ self.s.vnfs = [vnf]
+ self.s.traffic_profile = mock.Mock()
+ self.s.collector = mock.Mock(autospec=Collector)
+ self.s.collector.stop = \
+ mock.Mock(return_value=True)
+ with self.assertRaises(RuntimeError):
+ self.s.teardown()
+
SAMPLE_NETDEVS = {
'enp11s0': {
'address': '0a:de:ad:be:ef:f5',
diff --git a/tests/unit/common/test_process.py b/tests/unit/common/test_process.py
new file mode 100644
index 000000000..5eee55bcc
--- /dev/null
+++ b/tests/unit/common/test_process.py
@@ -0,0 +1,46 @@
+# Copyright (c) 2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import unittest
+
+import mock
+
+from yardstick.common import process
+
+
+class ProcessTestcase(unittest.TestCase):
+ def test_check_if_procces_failed_None(self):
+ p = mock.MagicMock(**{"exitcode": None, "name": "debug"})
+ process.check_if_process_failed(p)
+
+ def test_check_if_procces_failed_0(self):
+ p = mock.MagicMock(**{"exitcode": 0, "name": "debug"})
+ process.check_if_process_failed(p)
+
+ def test_check_if_procces_failed_1(self):
+ p = mock.MagicMock(**{"exitcode": 1, "name": "debug"})
+ with self.assertRaises(RuntimeError):
+ process.check_if_process_failed(p)
+
+
+@mock.patch("yardstick.common.process.multiprocessing")
+class TerminateChildrenTestcase(unittest.TestCase):
+ def test_some_children(self, mock_multiprocessing):
+ p1 = mock.MagicMock()
+ p2 = mock.MagicMock()
+ mock_multiprocessing.active_children.return_value = [p1, p2]
+ process.terminate_children()
+
+ def test_no_children(self, mock_multiprocessing):
+ mock_multiprocessing.active_children.return_value = []
+ process.terminate_children()
diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py
index 923ec4aaa..42b75d1f0 100644
--- a/tests/unit/common/test_utils.py
+++ b/tests/unit/common/test_utils.py
@@ -17,6 +17,7 @@ import unittest
from copy import deepcopy
from itertools import product, chain
+import errno
import mock
from six.moves import configparser
@@ -780,6 +781,21 @@ class RemoveFileTestCase(unittest.TestCase):
class TestUtils(unittest.TestCase):
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs(self, *_):
+ self.assertIsNone(utils.makedirs('a/b/c/d'))
+
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs_exists(self, mock_os_makedirs):
+ mock_os_makedirs.side_effect = OSError(errno.EEXIST, 'exists')
+ self.assertIsNone(utils.makedirs('a/b/c/d'))
+
+ @mock.patch('yardstick.common.utils.os.makedirs')
+ def test_makedirs_busy(self, mock_os_makedirs):
+ mock_os_makedirs.side_effect = OSError(errno.EBUSY, 'busy')
+ with self.assertRaises(OSError):
+ utils.makedirs('a/b/c/d')
+
@mock.patch('yardstick.common.utils.jsonify')
def test_result_handler(self, mock_jsonify):
mock_jsonify.return_value = 432
diff --git a/tests/unit/network_services/collector/test_subscriber.py b/tests/unit/network_services/collector/test_subscriber.py
index 260f0bb27..f324f627d 100644
--- a/tests/unit/network_services/collector/test_subscriber.py
+++ b/tests/unit/network_services/collector/test_subscriber.py
@@ -45,6 +45,7 @@ class CollectorTestCase(unittest.TestCase):
NODES = {
'node1': {},
'node2': {
+ 'ip': '1.2.3.4',
'collectd': {
'plugins': {'abc': 12, 'def': 34},
'interval': 987,
diff --git a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
index dbd8396c8..0f1cf7d92 100644
--- a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
+++ b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
@@ -16,19 +16,19 @@
import mock
import unittest
-from yardstick.network_services.helpers.dpdknicbind_helper import DpdkBindHelper
-from yardstick.network_services.helpers.dpdknicbind_helper import DpdkBindHelperException
-from yardstick.network_services.helpers.dpdknicbind_helper import NETWORK_KERNEL
-from yardstick.network_services.helpers.dpdknicbind_helper import NETWORK_DPDK
-from yardstick.network_services.helpers.dpdknicbind_helper import CRYPTO_KERNEL
-from yardstick.network_services.helpers.dpdknicbind_helper import CRYPTO_DPDK
-from yardstick.network_services.helpers.dpdknicbind_helper import NETWORK_OTHER
-from yardstick.network_services.helpers.dpdknicbind_helper import CRYPTO_OTHER
+from yardstick.network_services.helpers.dpdkbindnic_helper import DpdkBindHelper
+from yardstick.network_services.helpers.dpdkbindnic_helper import DpdkBindHelperException
+from yardstick.network_services.helpers.dpdkbindnic_helper import NETWORK_KERNEL
+from yardstick.network_services.helpers.dpdkbindnic_helper import NETWORK_DPDK
+from yardstick.network_services.helpers.dpdkbindnic_helper import CRYPTO_KERNEL
+from yardstick.network_services.helpers.dpdkbindnic_helper import CRYPTO_DPDK
+from yardstick.network_services.helpers.dpdkbindnic_helper import NETWORK_OTHER
+from yardstick.network_services.helpers.dpdkbindnic_helper import CRYPTO_OTHER
pass
-class MyTestDpdkBindHelper(unittest.TestCase):
+class TestDpdkBindHelper(unittest.TestCase):
EXAMPLE_OUTPUT = """
Network devices using DPDK-compatible driver
@@ -204,17 +204,31 @@ Other crypto devices
def test_bind(self):
conn = mock.Mock()
conn.execute = mock.Mock(return_value=(0, '', ''))
- conn.provision_tool = mock.Mock(return_value='/opt/nsb_bin/dpdk_nic_bind.py')
+ conn.provision_tool = mock.Mock(return_value='/opt/nsb_bin/dpdk-devbind.py')
dpdk_bind_helper = DpdkBindHelper(conn)
dpdk_bind_helper.read_status = mock.Mock()
dpdk_bind_helper.bind(['0000:00:03.0', '0000:00:04.0'], 'my_driver')
- conn.execute.assert_called_with('sudo /opt/nsb_bin/dpdk_nic_bind.py --force '
+ conn.execute.assert_called_with('sudo /opt/nsb_bin/dpdk-devbind.py --force '
'-b my_driver 0000:00:03.0 0000:00:04.0')
dpdk_bind_helper.read_status.assert_called_once()
+ def test_bind_single_pci(self):
+ conn = mock.Mock()
+ conn.execute = mock.Mock(return_value=(0, '', ''))
+ conn.provision_tool = mock.Mock(return_value='/opt/nsb_bin/dpdk-devbind.py')
+
+ dpdk_bind_helper = DpdkBindHelper(conn)
+ dpdk_bind_helper.read_status = mock.Mock()
+
+ dpdk_bind_helper.bind('0000:00:03.0', 'my_driver')
+
+ conn.execute.assert_called_with('sudo /opt/nsb_bin/dpdk-devbind.py --force '
+ '-b my_driver 0000:00:03.0')
+ dpdk_bind_helper.read_status.assert_called_once()
+
def test_rebind_drivers(self):
conn = mock.Mock()
@@ -222,14 +236,14 @@ Other crypto devices
dpdk_bind_helper.bind = mock.Mock()
dpdk_bind_helper.used_drivers = {
- '0000:05:00.0': 'd1',
- '0000:05:01.0': 'd3',
+ 'd1': ['0000:05:00.0'],
+ 'd3': ['0000:05:01.0', '0000:05:02.0'],
}
dpdk_bind_helper.rebind_drivers()
- dpdk_bind_helper.bind.assert_any_call('0000:05:00.0', 'd1', True)
- dpdk_bind_helper.bind.assert_any_call('0000:05:01.0', 'd3', True)
+ dpdk_bind_helper.bind.assert_any_call(['0000:05:00.0'], 'd1', True)
+ dpdk_bind_helper.bind.assert_any_call(['0000:05:01.0', '0000:05:02.0'], 'd3', True)
def test_save_used_drivers(self):
conn = mock.Mock()
@@ -239,9 +253,8 @@ Other crypto devices
dpdk_bind_helper.save_used_drivers()
expected = {
- '0000:00:04.0': 'igb_uio',
- '0000:00:05.0': 'igb_uio',
- '0000:00:03.0': 'virtio-pci',
+ 'igb_uio': ['0000:00:04.0', '0000:00:05.0'],
+ 'virtio-pci': ['0000:00:03.0'],
}
- self.assertEqual(expected, dpdk_bind_helper.used_drivers)
+ self.assertDictEqual(expected, dpdk_bind_helper.used_drivers)
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index 4fc6d7773..799cc202b 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -14,6 +14,8 @@
from __future__ import absolute_import
import unittest
+
+import errno
import mock
from yardstick.network_services.nfvi.resource import ResourceProfile
@@ -88,7 +90,7 @@ class TestResourceProfile(unittest.TestCase):
with mock.patch("yardstick.ssh.AutoConnectSSH") as ssh:
self.ssh_mock = mock.Mock(autospec=ssh.SSH)
self.ssh_mock.execute = \
- mock.Mock(return_value=(0, {}, ""))
+ mock.Mock(return_value=(0, "", ""))
ssh.from_node.return_value = self.ssh_mock
mgmt = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]['mgmt-interface']
@@ -105,7 +107,12 @@ class TestResourceProfile(unittest.TestCase):
def test_check_if_sa_running(self):
self.assertEqual(self.resource_profile.check_if_sa_running("collectd"),
- (True, {}))
+ (0, ""))
+
+ def test_check_if_sa_running_excetion(self):
+ with mock.patch.object(self.resource_profile.connection, "execute") as mock_execute:
+ mock_execute.side_effect = OSError(errno.ECONNRESET, "error")
+ self.assertEqual(self.resource_profile.check_if_sa_running("collectd"), (1, None))
def test_get_cpu_data(self):
reskey = ["", "cpufreq", "cpufreq-0"]
@@ -127,7 +134,6 @@ class TestResourceProfile(unittest.TestCase):
self.assertIsNone(
self.resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
-
@mock.patch("yardstick.network_services.nfvi.resource.open")
@mock.patch("yardstick.network_services.nfvi.resource.os")
def test__provide_config_file(self, mock_open, mock_os):
@@ -141,13 +147,18 @@ class TestResourceProfile(unittest.TestCase):
self.resource_profile._provide_config_file("/opt/nsb_bin", "collectd.conf", kwargs)
self.ssh_mock.execute.assert_called_once()
-
@mock.patch("yardstick.network_services.nfvi.resource.open")
def test_initiate_systemagent(self, mock_open):
self.resource_profile._start_collectd = mock.Mock()
self.assertIsNone(
self.resource_profile.initiate_systemagent("/opt/nsb_bin"))
+ @mock.patch("yardstick.network_services.nfvi.resource.open")
+ def test_initiate_systemagent_raise(self, mock_open):
+ self.resource_profile._start_collectd = mock.Mock(side_effect=RuntimeError)
+ with self.assertRaises(RuntimeError):
+ self.resource_profile.initiate_systemagent("/opt/nsb_bin")
+
def test__parse_hugepages(self):
reskey = ["cpu", "cpuFreq"]
value = "timestamp:12345"
@@ -173,7 +184,7 @@ class TestResourceProfile(unittest.TestCase):
self.assertEqual({'ovs/stats': '45'}, res)
def test_parse_collectd_result(self):
- res = self.resource_profile.parse_collectd_result({}, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result({})
expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {},
'memory': {}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
@@ -186,7 +197,7 @@ class TestResourceProfile(unittest.TestCase):
"ipc",
"1234",
""])
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result(metric)
expected_result = {'cpu': {1: {'ipc': '1234'}}, 'dpdkstat': {}, 'hugepages': {},
'memory': {}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
@@ -195,7 +206,7 @@ class TestResourceProfile(unittest.TestCase):
def test_parse_collectd_result_memory(self):
metric = {"nsb_stats/memory/bw": "101"}
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result(metric)
expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {},
'memory': {'bw': '101'}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
@@ -205,9 +216,8 @@ class TestResourceProfile(unittest.TestCase):
def test_parse_collectd_result_hugepage(self):
# amqp returns bytes
metric = {b"nsb_stats/hugepages/free": b"101"}
- self.resource_profile.parse_hugepages = \
- mock.Mock(return_value={"free": "101"})
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
+ self.resource_profile.parse_hugepages = mock.Mock(return_value={"free": "101"})
+ res = self.resource_profile.parse_collectd_result(metric)
expected_result = {'cpu': {}, 'dpdkstat': {}, 'hugepages': {'free': '101'},
'memory': {}, 'ovs_stats': {}, 'timestamp': '',
'intel_pmu': {},
@@ -224,7 +234,7 @@ class TestResourceProfile(unittest.TestCase):
mock.Mock(return_value={"memory": "101"})
self.resource_profile.parse_ovs_stats = \
mock.Mock(return_value={"tx": "101"})
- res = self.resource_profile.parse_collectd_result(metric, [0, 1, 2])
+ res = self.resource_profile.parse_collectd_result(metric)
expected_result = {'cpu': {}, 'dpdkstat': {'tx': '101'}, 'hugepages': {},
'memory': {}, 'ovs_stats': {'tx': '101'}, 'timestamp': '',
'intel_pmu': {},
@@ -258,5 +268,9 @@ class TestResourceProfile(unittest.TestCase):
def test_stop(self):
self.assertIsNone(self.resource_profile.stop())
+ def test_stop(self):
+ self.resource_profile.amqp_client = mock.MagicMock()
+ self.assertIsNone(self.resource_profile.stop())
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
index 0a4c12446..b0ef1da91 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
@@ -41,7 +41,7 @@ TEST_FILE_YAML = 'nsb_test_case.yaml'
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
-name = 'vnf__1'
+name = 'vnf__0'
class TestCgnaptApproxSetupEnvHelper(unittest.TestCase):
@@ -162,7 +162,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'rfc2544': {
'allowed_drop_rate': '0.8 - 1',
},
- 'vnf__1': {
+ 'vnf__0': {
'napt': 'dynamic',
'vnf_config': {
'lb_config': 'SW',
@@ -172,6 +172,10 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'worker_threads': 1,
},
},
+ 'flow': {'count': 1,
+ 'dst_ip': [{'tg__1': 'xe0'}],
+ 'public_ip': [''],
+ 'src_ip': [{'tg__0': 'xe0'}]},
},
'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7',
'task_path': '/tmp',
@@ -185,15 +189,11 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'type': 'Duration',
},
'traffic_profile': 'ipv4_throughput_acl.yaml',
- 'traffic_options': {
- 'flow': 'ipv4_Packets_acl.yaml',
- 'imix': 'imix_voice.yaml',
- },
- 'type': 'ISB',
+ 'type': 'NSPerf',
'nodes': {
- 'tg__2': 'trafficgen_2.yardstick',
'tg__1': 'trafficgen_1.yardstick',
- 'vnf__1': 'vnf.yardstick',
+ 'tg__0': 'trafficgen_0.yardstick',
+ 'vnf__0': 'vnf.yardstick',
},
'topology': 'vpe-tg-topology-baremetal.yaml',
}
@@ -253,9 +253,9 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'password': 'r00t',
'VNF model': 'tg_rfc2544_tpl.yaml',
'user': 'root'},
- 'vnf__1':
+ 'vnf__0':
{'name': 'vnf.yardstick',
- 'vnfd-id-ref': 'vnf__1',
+ 'vnfd-id-ref': 'vnf__0',
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens786f0',
@@ -318,6 +318,8 @@ class TestCgnaptApproxVnf(unittest.TestCase):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
+ cgnapt_approx_vnf._vnf_process = mock.MagicMock(
+ **{"is_alive.return_value": True, "exitcode": None})
cgnapt_approx_vnf.q_in = mock.MagicMock()
cgnapt_approx_vnf.q_out = mock.MagicMock()
cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
@@ -388,7 +390,7 @@ class TestCgnaptApproxVnf(unittest.TestCase):
'rules': ""}}
cgnapt_approx_vnf.q_out.put("pipeline>")
cgnapt_vnf.WAIT_TIME = 3
- self.scenario_cfg.update({"nodes": {"vnf__1": ""}})
+ self.scenario_cfg.update({"nodes": {"vnf__0": ""}})
self.assertIsNone(cgnapt_approx_vnf.instantiate(self.scenario_cfg,
self.context_cfg))
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
index e4319d602..54540ada1 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
@@ -17,12 +17,10 @@
from __future__ import absolute_import
-import copy
import os
import socket
import unittest
from itertools import repeat, chain
-from contextlib import contextmanager
import mock
from tests.unit import STL_MOCKS
@@ -1501,7 +1499,9 @@ class TestProxResourceHelper(unittest.TestCase):
helper = ProxResourceHelper(mock.MagicMock())
helper.resource = resource = mock.MagicMock()
+ resource.check_if_sa_running.return_value = 0, '1234'
resource.amqp_collect_nfvi_kpi.return_value = 543
+ resource.check_if_sa_running.return_value = (0, None)
expected = {'core': 543}
result = helper.collect_collectd_kpi()
@@ -1513,7 +1513,9 @@ class TestProxResourceHelper(unittest.TestCase):
helper._result = {'z': 123}
helper.resource = resource = mock.MagicMock()
+ resource.check_if_sa_running.return_value = 0, '1234'
resource.amqp_collect_nfvi_kpi.return_value = 543
+ resource.check_if_sa_running.return_value = (0, None)
queue.empty.return_value = False
queue.get.return_value = {'a': 789}
@@ -1800,7 +1802,7 @@ class TestProxProfileHelper(unittest.TestCase):
def test_latency_cores(self):
resource_helper = mock.MagicMock()
- resource_helper.setup_helper.prox_config_data= []
+ resource_helper.setup_helper.prox_config_data = []
helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = []
@@ -1977,7 +1979,6 @@ class TestProxProfileHelper(unittest.TestCase):
]),
]
-
client = mock.MagicMock()
client.hz.return_value = 2
client.port_stats.return_value = tuple(range(12))
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
index c88b1528c..09060ff57 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
@@ -85,7 +85,7 @@ class TestProxApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'local_ip': '152.16.100.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
+ 'vld_id': 'downlink_0',
'ifname': 'xe1',
'netmask': '255.255.255.0',
'dpdk_port_num': 0,
@@ -104,8 +104,8 @@ class TestProxApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.1',
'local_ip': '152.16.40.19',
'type': 'PCI-PASSTHROUGH',
- 'vld_id': '',
- 'ifname': 'xe3',
+ 'vld_id': 'uplink_0',
+ 'ifname': 'xe1',
'driver': "i40e",
'netmask': '255.255.255.0',
'dpdk_port_num': 1,
@@ -365,6 +365,7 @@ class TestProxApproxVnf(unittest.TestCase):
prox_approx_vnf = ProxApproxVnf(NAME, deepcopy(self.VNFD0))
prox_approx_vnf.resource_helper = resource_helper
prox_approx_vnf.vnfd_helper['vdu'][0]['external-interface'] = []
+ prox_approx_vnf.vnfd_helper.port_pairs.interfaces = []
with self.assertRaises(RuntimeError):
prox_approx_vnf.collect_kpi()
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
index d0c4b6f42..1e6bc1a13 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
@@ -833,13 +833,13 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
dpdk_setup_helper.dpdk_bind_helper.bind = mock.Mock()
dpdk_setup_helper.dpdk_bind_helper.used_drivers = {
- '0000:05:00.0': 'd1',
- '0000:05:01.0': 'd3',
+ 'd1': ['0000:05:00.0'],
+ 'd3': ['0000:05:01.0'],
}
self.assertIsNone(dpdk_setup_helper.tear_down())
- dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call('0000:05:00.0', 'd1', True)
- dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call('0000:05:01.0', 'd3', True)
+ dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call(['0000:05:00.0'], 'd1', True)
+ dpdk_setup_helper.dpdk_bind_helper.bind.assert_any_call(['0000:05:01.0'], 'd3', True)
class TestResourceHelper(unittest.TestCase):
@@ -1136,11 +1136,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- '0000:05:00.2',
- ]
client_resource_helper.client.get_stats.return_value = {
0: {
'rx_pps': 5.5,
@@ -1186,10 +1181,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- ]
client_resource_helper.client.get_stats.return_value = {
'key_name': 'key_value',
0: {
@@ -1238,10 +1229,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- ]
client_resource_helper.client.get_stats.return_value = {
0: {
'rx_pps': 5.5,
@@ -1529,8 +1516,9 @@ class TestSampleVNFDeployHelper(unittest.TestCase):
sample_vnf_deploy_helper = SampleVNFDeployHelper(vnfd_helper, ssh_helper)
self.assertIsNone(sample_vnf_deploy_helper.deploy_vnfs('name1'))
- self.assertEqual(ssh_helper.execute.call_count, 0)
- self.assertEqual(ssh_helper.put.call_count, 0)
+ sample_vnf_deploy_helper.DISABLE_DEPLOY = True
+ self.assertEqual(ssh_helper.execute.call_count, 5)
+ self.assertEqual(ssh_helper.put.call_count, 1)
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch('subprocess.check_output')
@@ -2143,6 +2131,7 @@ class TestSampleVNFTrafficGen(unittest.TestCase):
def test_terminate(self):
sample_vnf_tg = SampleVNFTrafficGen('tg1', self.VNFD_0)
sample_vnf_tg._traffic_process = mock.Mock()
+ sample_vnf_tg._tg_process = mock.Mock()
sample_vnf_tg.terminate()
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
index eb569cfe6..23d448c5e 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
@@ -395,7 +395,6 @@ class TestProxTrafficGen(unittest.TestCase):
sut.ssh_helper = mock.Mock()
sut.ssh_helper.run = mock.Mock()
sut.setup_helper.prox_config_dict = {}
- sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"]
sut._connect_client = mock.Mock(autospec=STLClient)
sut._connect_client.get_stats = mock.Mock(return_value="0")
sut._traffic_runner(mock_traffic_profile)
@@ -427,6 +426,8 @@ class TestProxTrafficGen(unittest.TestCase):
prox_traffic_gen._traffic_process.terminate = mock.Mock()
prox_traffic_gen.ssh_helper = mock.MagicMock()
prox_traffic_gen.setup_helper = mock.MagicMock()
- prox_traffic_gen._vnf_wrapper.setup_helper = mock.MagicMock()
prox_traffic_gen.resource_helper = mock.MagicMock()
+ prox_traffic_gen._vnf_wrapper.setup_helper = mock.MagicMock()
+ prox_traffic_gen._vnf_wrapper._vnf_process = mock.MagicMock()
+ prox_traffic_gen._vnf_wrapper.resource_helper = mock.MagicMock()
self.assertEqual(None, prox_traffic_gen.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
index eb9f0525b..d08c62e0b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
@@ -356,6 +356,17 @@ 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 = {}
+ self.assertIsNone(trex_traffic_gen._start_server())
+
+ @mock.patch(SSH_HELPER)
+ def test__start_server_multiple_queues(self, ssh):
+ mock_ssh(ssh)
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ 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}}}
self.assertIsNone(trex_traffic_gen._start_server())
@mock.patch(SSH_HELPER)
@@ -371,7 +382,6 @@ class TestTrexTrafficGen(unittest.TestCase):
self.sut = TrexTrafficGen(NAME, vnfd)
self.sut.ssh_helper = mock.Mock()
self.sut.ssh_helper.run = mock.Mock()
- self.sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"]
self.sut._connect_client = mock.Mock(autospec=STLClient)
self.sut._connect_client.get_stats = mock.Mock(return_value="0")
self.sut.resource_helper.RUN_DURATION = 0
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
index b75ed6764..d4d3439f3 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
@@ -426,6 +426,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
udp_replay_approx_vnf._build_config = mock.MagicMock()
udp_replay_approx_vnf.queue_wrapper = mock.MagicMock()
+ udp_replay_approx_vnf.scenario_helper = mock.MagicMock()
udp_replay_approx_vnf._run()
@@ -443,6 +444,8 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf.WAIT_TIME = 0
udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock()
+ udp_replay_approx_vnf.deploy_helper = mock.MagicMock()
+ udp_replay_approx_vnf.deploy_vnfs = mock.MagicMock()
self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
udp_replay_approx_vnf._vnf_process.is_alive = mock.Mock(return_value=1)
@@ -459,6 +462,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf.q_out.put("some text PANIC some text")
udp_replay_approx_vnf.setup_helper.setup_vnf_environment = mock.Mock()
+ udp_replay_approx_vnf.deploy_helper = mock.MagicMock()
self.assertIsNone(udp_replay_approx_vnf.instantiate(self.SCENARIO_CFG, self.CONTEXT_CFG))
with self.assertRaises(RuntimeError):
udp_replay_approx_vnf.wait_for_instantiate()
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
index 3813aaa21..4103d7825 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
@@ -565,8 +565,9 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
- resource.check_if_sa_running.return_value = False, 'error'
+ resource.check_if_sa_running.return_value = 1, ''
resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}
+ resource.check_if_sa_running.return_value = (1, None)
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.q_in = mock.MagicMock()
@@ -588,7 +589,7 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
- resource.check_if_sa_running.return_value = True, 'good'
+ resource.check_if_sa_running.return_value = 0, '1234'
resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)