summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ansible/roles/install_yardstick/tasks/main.yml37
-rw-r--r--ansible/roles/install_yardstick/tasks/regular_install.yml23
-rw-r--r--ansible/roles/install_yardstick/tasks/virtual_install.yml25
-rw-r--r--docker/Dockerfile2
-rw-r--r--docker/Dockerfile.aarch64.patch2
-rwxr-xr-xnsb_setup.sh2
-rw-r--r--requirements.txt2
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_ixload.py8
-rw-r--r--yardstick/tests/unit/apiserver/utils/test_influx.py8
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_node.py4
-rw-r--r--yardstick/tests/unit/benchmark/core/test_plugin.py10
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py22
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py9
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py228
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py176
15 files changed, 251 insertions, 307 deletions
diff --git a/ansible/roles/install_yardstick/tasks/main.yml b/ansible/roles/install_yardstick/tasks/main.yml
index ee1b83756..973b2b027 100644
--- a/ansible/roles/install_yardstick/tasks/main.yml
+++ b/ansible/roles/install_yardstick/tasks/main.yml
@@ -37,10 +37,39 @@
# name: pip
# state: latest
-- name: install yardstick without virtual environment
- include_tasks: regular_install.yml
+- name: Install Yardstick requirements (venv)
+ pip:
+ requirements: "{{ yardstick_dir }}/requirements.txt"
+ virtualenv: "{{ yardstick_dir }}/virtualenv"
+ async: 300
+ poll: 0
+ register: pip_installer
+ when: virtual_environment == True
+
+- name: Install Yardstick requirements
+ pip:
+ requirements: "{{ yardstick_dir }}/requirements.txt"
+ async: 300
+ poll: 0
+ register: pip_installer
when: virtual_environment == False
-- name: install yardstick with virtual environment
- include_tasks: virtual_install.yml
+- name: Check install Yardstick requirements
+ async_status:
+ jid: "{{ pip_installer.ansible_job_id }}"
+ register: job_result
+ until: job_result.finished
+ retries: 100
+
+- name: Install Yardstick code (venv)
+ pip:
+ name: "{{ yardstick_dir }}/"
+ editable: True
+ virtualenv: "{{ yardstick_dir }}/virtualenv"
when: virtual_environment == True
+
+- name: Install Yardstick code
+ pip:
+ name: "{{ yardstick_dir }}/"
+ editable: True
+ when: virtual_environment == False
diff --git a/ansible/roles/install_yardstick/tasks/regular_install.yml b/ansible/roles/install_yardstick/tasks/regular_install.yml
deleted file mode 100644
index cd0e86fb9..000000000
--- a/ansible/roles/install_yardstick/tasks/regular_install.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (c) 2018 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.
----
-- name: Install Yardstick requirements
- pip:
- requirements: "{{ yardstick_dir }}/requirements.txt"
-
-- name: Install Yardstick code
- pip:
- name: "."
- extra_args: -e
- chdir: "{{ yardstick_dir }}/"
diff --git a/ansible/roles/install_yardstick/tasks/virtual_install.yml b/ansible/roles/install_yardstick/tasks/virtual_install.yml
deleted file mode 100644
index 8545acbcb..000000000
--- a/ansible/roles/install_yardstick/tasks/virtual_install.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (c) 2018 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.
----
-- name: Install Yardstick requirements
- pip:
- requirements: "{{ yardstick_dir }}/requirements.txt"
- virtualenv: "{{ yardstick_dir }}/virtualenv"
-
-- name: Install Yardstick code
- pip:
- name: "{{ yardstick_dir }}/."
- extra_args: -e
- virtualenv: "{{ yardstick_dir }}/virtualenv"
-
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 4aa7237a5..be9156685 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -26,7 +26,7 @@ ENV YARDSTICK_REPO_DIR="${REPOS_DIR}/yardstick/" \
RUN apt-get update && apt-get install -y git python python-setuptools python-pip iputils-ping && apt-get -y autoremove && apt-get clean
RUN easy_install -U setuptools==30.0.0
-RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 python-openstackclient==3.11.0 python-heatclient==1.11.0 ansible==2.4.2
+RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 python-openstackclient==3.11.0 python-heatclient==1.11.0 ansible==2.5.5
RUN mkdir -p ${REPOS_DIR}
diff --git a/docker/Dockerfile.aarch64.patch b/docker/Dockerfile.aarch64.patch
index 21095cbe3..712718426 100644
--- a/docker/Dockerfile.aarch64.patch
+++ b/docker/Dockerfile.aarch64.patch
@@ -31,7 +31,7 @@ index 62ea0d0..f2f41771 100644
+RUN apt-get update && apt-get install -y git python python-setuptools python-pip iputils-ping && apt-get -y autoremove && \
+ apt-get install -y libssl-dev && apt-get -y install libffi-dev && apt-get clean
RUN easy_install -U setuptools==30.0.0
- RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 python-openstackclient==3.11.0 python-heatclient==1.11.0 ansible==2.4.2
+ RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 python-openstackclient==3.11.0 python-heatclient==1.11.0 ansible==2.5.5
@@ -48,8 +49,8 @@ RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# nginx=5000, rabbitmq=5672
diff --git a/nsb_setup.sh b/nsb_setup.sh
index 3396b82d1..1f5344980 100755
--- a/nsb_setup.sh
+++ b/nsb_setup.sh
@@ -63,7 +63,7 @@ for i in "${pkg[@]}"; do
fi
done
-pip install ansible==2.4.2 shade==1.22.2 docker-py==1.10.6
+pip install ansible==2.5.5 shade==1.22.2 docker-py==1.10.6
ANSIBLE_SCRIPTS="ansible"
diff --git a/requirements.txt b/requirements.txt
index 60014d75e..a7a7e68b1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,7 +11,7 @@ Babel==2.3.4 # BSD; OSI Approved BSD License
Jinja2==2.9.6 # BSD; OSI Approved BSD License
SQLAlchemy==1.1.12 # MIT License; OSI Approved MIT License
PTable==0.9.2 # BSD (3 clause); OSI Approved BSD License
-ansible==2.4.2 # GPLv3; OSI Approved GNU General Public License v3 or later (GPLv3+)
+ansible==2.5.5 # GPLv3; OSI Approved GNU General Public License v3 or later (GPLv3+)
backport-ipaddress==0.1; python_version <= "2.7" # OSI Approved Python Software Foundation License
chainmap==1.0.2 # Python Software Foundation License; OSI Approved Python Software Foundation License
cmd2==0.8.6 # MIT License; OSI Approved MIT License
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_ixload.py b/yardstick/network_services/vnf_generic/vnf/tg_ixload.py
index 02e7803f7..102c66f78 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_ixload.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_ixload.py
@@ -20,7 +20,7 @@ import os
import shutil
from collections import OrderedDict
-from subprocess import call
+import subprocess
from yardstick.common import utils
from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNFTrafficGen
@@ -101,7 +101,7 @@ class IxLoadResourceHelper(ClientResourceHelper):
LOG.debug(cmd)
if not os.path.ismount(self.RESULTS_MOUNT):
- call(cmd, shell=True)
+ subprocess.call(cmd, shell=True)
shutil.rmtree(self.RESULTS_MOUNT, ignore_errors=True)
utils.makedirs(self.RESULTS_MOUNT)
@@ -157,7 +157,7 @@ class IxLoadTrafficGen(SampleVNFTrafficGen):
args="'%s'" % ixload_config)
LOG.debug(cmd)
- call(cmd, shell=True)
+ subprocess.call(cmd, shell=True)
with open(self.ssh_helper.join_bin_path("ixLoad_HTTP_Client.csv")) as csv_file:
lines = csv_file.readlines()[10:]
@@ -172,5 +172,5 @@ class IxLoadTrafficGen(SampleVNFTrafficGen):
self.resource_helper.data = self.resource_helper.make_aggregates()
def terminate(self):
- call(["pkill", "-9", "http_ixload.py"])
+ subprocess.call(["pkill", "-9", "http_ixload.py"])
super(IxLoadTrafficGen, self).terminate()
diff --git a/yardstick/tests/unit/apiserver/utils/test_influx.py b/yardstick/tests/unit/apiserver/utils/test_influx.py
index 95105d8ae..6021d35df 100644
--- a/yardstick/tests/unit/apiserver/utils/test_influx.py
+++ b/yardstick/tests/unit/apiserver/utils/test_influx.py
@@ -31,15 +31,17 @@ class GetDataDbClientTestCase(base.BaseUnitTestCase):
_mock_parser.read.assert_called_once_with(constants.CONF_FILE)
mock_get_client.assert_called_once_with(_mock_parser)
+ @mock.patch.object(influx.logger, 'error')
@mock.patch.object(influx, '_get_influxdb_client',
return_value='fake_client')
@mock.patch.object(influx.ConfigParser, 'ConfigParser')
- def test_get_data_db_client_parsing_error(self, mock_parser,
- mock_get_client):
+ def test_get_data_db_client_parsing_error(
+ self, mock_parser, mock_get_client, *args):
_mock_parser = mock.Mock()
mock_parser.return_value = _mock_parser
mock_parser.NoOptionError = configparser.NoOptionError
- mock_get_client.side_effect = configparser.NoOptionError('option', 'section')
+ mock_get_client.side_effect = configparser.NoOptionError('option',
+ 'section')
with self.assertRaises(configparser.NoOptionError):
influx.get_data_db_client()
diff --git a/yardstick/tests/unit/benchmark/contexts/test_node.py b/yardstick/tests/unit/benchmark/contexts/test_node.py
index 5d7b24c3d..7fd13a406 100644
--- a/yardstick/tests/unit/benchmark/contexts/test_node.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_node.py
@@ -170,7 +170,7 @@ class NodeContextTestCase(unittest.TestCase):
def test__get_physical_nodes(self):
self.test_context.init(self.attrs)
nodes = self.test_context._get_physical_nodes()
- self.assertEquals(nodes, self.test_context.nodes)
+ self.assertEqual(nodes, self.test_context.nodes)
def test__get_physical_node_for_server(self):
self.test_context.init(self.attrs)
@@ -198,7 +198,7 @@ class NodeContextTestCase(unittest.TestCase):
node_collectd_options = [node for node in self.test_context.nodes
if node['name'] == 'node1'][0]['collectd']
- self.assertEquals(node_collectd_options, options)
+ self.assertEqual(node_collectd_options, options)
@mock.patch('{}.NodeContext._dispatch_script'.format(PREFIX))
def test_deploy(self, dispatch_script_mock):
diff --git a/yardstick/tests/unit/benchmark/core/test_plugin.py b/yardstick/tests/unit/benchmark/core/test_plugin.py
index 0d14e4e86..53621316b 100644
--- a/yardstick/tests/unit/benchmark/core/test_plugin.py
+++ b/yardstick/tests/unit/benchmark/core/test_plugin.py
@@ -12,6 +12,7 @@ import os
import pkg_resources
import mock
+import six
import testtools
from yardstick import ssh
@@ -48,13 +49,17 @@ deployment:
self.mock_ssh_from_node.return_value = self.mock_ssh_obj
self.mock_ssh_obj.wait = mock.Mock()
self.mock_ssh_obj._put_file_shell = mock.Mock()
+ self._mock_log_info = mock.patch.object(plugin.LOG, 'info')
+ self.mock_log_info = self._mock_log_info.start()
self.addCleanup(self._cleanup)
def _cleanup(self):
self._mock_ssh_from_node.stop()
+ self._mock_log_info.stop()
- def test_install(self):
+ @mock.patch.object(six.moves.builtins, 'print')
+ def test_install(self, *args):
args = mock.Mock()
args.input_file = [mock.Mock()]
with mock.patch.object(self.plugin, '_install_setup') as \
@@ -65,7 +70,8 @@ deployment:
PluginTestCase.DEPLOYMENT)
mock_run.assert_called_once_with(PluginTestCase.NAME)
- def test_remove(self):
+ @mock.patch.object(six.moves.builtins, 'print')
+ def test_remove(self, *args):
args = mock.Mock()
args.input_file = [mock.Mock()]
with mock.patch.object(self.plugin, '_remove_setup') as \
diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py
index 2190e9337..5f342df7d 100644
--- a/yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_iperf3.py
@@ -7,10 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.networking.iperf3.Iperf
-
-from __future__ import absolute_import
-
import os
import unittest
@@ -22,7 +18,7 @@ from yardstick.benchmark.scenarios.networking import iperf3
from yardstick.common import exceptions as y_exc
-@mock.patch('yardstick.benchmark.scenarios.networking.iperf3.ssh')
+@mock.patch.object(iperf3, 'ssh')
class IperfTestCase(unittest.TestCase):
output_name_tcp = 'iperf3_sample_output.json'
output_name_udp = 'iperf3_sample_output_udp.json'
@@ -41,9 +37,14 @@ class IperfTestCase(unittest.TestCase):
'ipaddr': '172.16.0.138',
}
}
+ self._mock_log_info = mock.patch.object(iperf3.LOG, 'info')
+ self.mock_log_info = self._mock_log_info.start()
+ self.addCleanup(self._stop_mocks)
- def test_iperf_successful_setup(self, mock_ssh):
+ def _stop_mocks(self):
+ self._mock_log_info.stop()
+ def test_iperf_successful_setup(self, mock_ssh):
p = iperf3.Iperf({}, self.ctx)
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
@@ -53,13 +54,11 @@ class IperfTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.assert_called_with("iperf3 -s -D")
def test_iperf_unsuccessful_setup(self, mock_ssh):
-
p = iperf3.Iperf({}, self.ctx)
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.setup)
def test_iperf_successful_teardown(self, mock_ssh):
-
p = iperf3.Iperf({}, self.ctx)
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
p.host = mock_ssh.SSH.from_node()
@@ -70,7 +69,6 @@ class IperfTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.assert_called_with("pkill iperf3")
def test_iperf_successful_no_sla(self, mock_ssh):
-
options = {}
args = {'options': options}
result = {}
@@ -86,7 +84,6 @@ class IperfTestCase(unittest.TestCase):
self.assertEqual(result, expected_result)
def test_iperf_successful_sla(self, mock_ssh):
-
options = {}
args = {
'options': options,
@@ -105,7 +102,6 @@ class IperfTestCase(unittest.TestCase):
self.assertEqual(result, expected_result)
def test_iperf_unsuccessful_sla(self, mock_ssh):
-
options = {}
args = {
'options': options,
@@ -174,7 +170,6 @@ class IperfTestCase(unittest.TestCase):
self.assertEqual(result, expected_result)
def test_iperf_unsuccessful_script_error(self, mock_ssh):
-
options = {}
args = {'options': options}
result = {}
@@ -186,7 +181,8 @@ class IperfTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.run, result)
- def _read_sample_output(self, filename):
+ @staticmethod
+ def _read_sample_output(filename):
curr_path = os.path.dirname(os.path.abspath(__file__))
output = os.path.join(curr_path, filename)
with open(output) as f:
diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
index c05d2ced2..db6f9cc89 100644
--- a/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
@@ -18,8 +18,8 @@ import time
import mock
import unittest
-from yardstick.benchmark.scenarios.networking import vsperf_dpdk
from yardstick import exceptions as y_exc
+from yardstick.benchmark.scenarios.networking import vsperf_dpdk
class VsperfDPDKTestCase(unittest.TestCase):
@@ -59,17 +59,18 @@ class VsperfDPDKTestCase(unittest.TestCase):
self.scenario = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
- self._mock_ssh = mock.patch(
- 'yardstick.benchmark.scenarios.networking.vsperf_dpdk.ssh')
+ self._mock_ssh = mock.patch.object(vsperf_dpdk, 'ssh')
self.mock_ssh = self._mock_ssh.start()
self._mock_subprocess_call = mock.patch.object(subprocess, 'call')
self.mock_subprocess_call = self._mock_subprocess_call.start()
-
+ self._mock_log_info = mock.patch.object(vsperf_dpdk.LOG, 'info')
+ self.mock_log_info = self._mock_log_info.start()
self.addCleanup(self._cleanup)
def _cleanup(self):
self._mock_ssh.stop()
self._mock_subprocess_call.stop()
+ self._mock_log_info.stop()
def test_setup(self):
# setup() specific mocks
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
index 6858cf70a..66f9e93ae 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
@@ -11,7 +11,6 @@
# 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 subprocess
@@ -20,19 +19,10 @@ import six
import unittest
from yardstick import ssh
-from yardstick.common import utils
-from yardstick.tests import STL_MOCKS
from yardstick.benchmark.contexts import base as ctx_base
-
-
-STLClient = mock.MagicMock()
-stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
-stl_patch.start()
-
-if stl_patch:
- from yardstick.network_services.vnf_generic.vnf.tg_ixload import IxLoadTrafficGen
- from yardstick.network_services.vnf_generic.vnf.tg_ixload import IxLoadResourceHelper
- from yardstick.network_services.traffic_profile.base import TrafficProfile
+from yardstick.common import utils
+from yardstick.network_services.vnf_generic.vnf import tg_ixload
+from yardstick.network_services.traffic_profile.base import TrafficProfile
NAME = "tg__1"
@@ -119,167 +109,128 @@ class TestIxLoadTrafficGen(unittest.TestCase):
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 = mock.patch.object(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)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
- self.assertIsNone(ixload_traffic_gen.resource_helper.data)
+ @mock.patch.object(ssh, 'SSH')
+ def test___init__(self, *args):
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
+ self.assertIsNone(ixload_traffic_gen.resource_helper.data)
- @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server',
+ return_value='mock_node')
+ @mock.patch.object(ssh, 'SSH')
def test_collect_kpi(self, *args):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
+ ixload_traffic_gen.scenario_helper.scenario_cfg = {
+ 'nodes': {ixload_traffic_gen.name: "mock"}
+ }
+ ixload_traffic_gen.data = {}
+ result = ixload_traffic_gen.collect_kpi()
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
- ixload_traffic_gen.scenario_helper.scenario_cfg = {
- 'nodes': {ixload_traffic_gen.name: "mock"}
- }
- ixload_traffic_gen.data = {}
- restult = ixload_traffic_gen.collect_kpi()
- expected = {
- 'physical_node': 'mock_node',
- 'collect_stats': {},
- }
- self.assertEqual(expected, restult)
+ expected = {
+ 'physical_node': 'mock_node',
+ 'collect_stats': {}}
+ self.assertEqual(expected, result)
- def test_listen_traffic(self):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
- self.assertIsNone(ixload_traffic_gen.listen_traffic({}))
+ @mock.patch.object(ssh, 'SSH')
+ def test_listen_traffic(self, *args):
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
+ self.assertIsNone(ixload_traffic_gen.listen_traffic({}))
@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.object(ctx_base.Context, 'get_context_from_server')
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
- def test_instantiate(self, shutil, *args):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh_mock.run = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
- scenario_cfg = {'tc': "nsb_test_case",
- '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',
- 'vnf_config': {'lb_config': 'SW',
- 'lb_count': 1,
- 'worker_config':
- '1C/1T',
- 'worker_threads': 1}}
- }})
- scenario_cfg.update({
- 'nodes': {ixload_traffic_gen.name: "mock"}
- })
- with mock.patch.object(six.moves.builtins, 'open',
- create=True) as mock_open:
- mock_open.return_value = mock.MagicMock()
- ixload_traffic_gen.instantiate(scenario_cfg, {})
+ @mock.patch.object(ssh, 'SSH')
+ def test_instantiate(self, mock_shutil, *args):
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
+ scenario_cfg = {'tc': "nsb_test_case",
+ 'ixia_profile': "ixload.cfg",
+ 'task_path': "/path/to/task"}
+ ixload_traffic_gen.RESULTS_MOUNT = "/tmp/result"
+ mock_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',
+ 'vnf_config': {'lb_config': 'SW',
+ 'lb_count': 1,
+ 'worker_config':
+ '1C/1T',
+ 'worker_threads': 1}}
+ }})
+ scenario_cfg.update({
+ 'nodes': {ixload_traffic_gen.name: "mock"}
+ })
+ with mock.patch.object(six.moves.builtins, 'open',
+ create=True) as mock_open:
+ 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):
+ @mock.patch.object(ssh, 'SSH')
+ 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
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh_mock.run = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- vnfd["mgmt-interface"].update({"tg-config": {}})
- vnfd["mgmt-interface"]["tg-config"].update({"ixchassis":
- "1.1.1.1"})
- vnfd["mgmt-interface"]["tg-config"].update({"py_bin_path":
- "/root"})
- sut = IxLoadTrafficGen(NAME, vnfd)
- 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)
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ vnfd["mgmt-interface"].update({"tg-config": {}})
+ vnfd["mgmt-interface"]["tg-config"].update({"ixchassis":
+ "1.1.1.1"})
+ vnfd["mgmt-interface"]["tg-config"].update({"py_bin_path":
+ "/root"})
+ sut = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
+ sut.connection = mock.Mock()
+ sut.connection.run = mock.Mock()
+ sut._traffic_runner = mock.Mock(return_value=0)
+ 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):
+ @mock.patch.object(ssh, 'SSH')
+ 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
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "", ""))
- ssh_mock.run = \
- mock.Mock(return_value=(0, "", ""))
- ssh.from_node.return_value = ssh_mock
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- vnfd["mgmt-interface"].update({"tg-config": {}})
- vnfd["mgmt-interface"]["tg-config"].update({"ixchassis":
- "1.1.1.1"})
- vnfd["mgmt-interface"]["tg-config"].update({"py_bin_path":
- "/root"})
- sut = IxLoadTrafficGen(NAME, vnfd)
- 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)
- self.assertIsNone(result)
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ vnfd["mgmt-interface"].update({"tg-config": {}})
+ vnfd["mgmt-interface"]["tg-config"].update({"ixchassis":
+ "1.1.1.1"})
+ vnfd["mgmt-interface"]["tg-config"].update({"py_bin_path":
+ "/root"})
+ sut = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
+ sut.connection = mock.Mock()
+ sut.connection.run = mock.Mock()
+ sut._traffic_runner = mock.Mock(return_value=0)
+ sut.rel_bin_path = mock.Mock(return_value="/tmp/*.csv")
+ result = sut.run_traffic(mock_traffic_profile)
+ self.assertIsNone(result)
- @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
@mock.patch.object(ssh, 'SSH')
def test_terminate(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
+ ixload_traffic_gen = tg_ixload.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):
+ def test_parse_csv_read(self, mock_ssh):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
kpi_data = {
'HTTP Total Throughput (Kbps)': 1,
@@ -294,14 +245,14 @@ class TestIxLoadTrafficGen(unittest.TestCase):
mock_ssh_type.execute.return_value = 0, "", ""
mock_ssh.from_node.return_value = mock_ssh_type
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
+ ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
result = ixload_traffic_gen.resource_helper.result
ixload_traffic_gen.resource_helper.parse_csv_read(http_reader)
- for key_left, key_right in IxLoadResourceHelper.KPI_LIST.items():
+ for key_left, key_right in (
+ tg_ixload.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):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@ -317,13 +268,12 @@ class TestIxLoadTrafficGen(unittest.TestCase):
mock_ssh_type.execute.return_value = 0, "", ""
mock_ssh.from_node.return_value = mock_ssh_type
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
+ ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
init_value = ixload_traffic_gen.resource_helper.result
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):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@ -338,7 +288,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
mock_ssh_type.execute.return_value = 0, "", ""
mock_ssh.from_node.return_value = mock_ssh_type
- ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
+ ixload_traffic_gen = tg_ixload.IxLoadTrafficGen(NAME, vnfd)
with self.assertRaises(KeyError):
ixload_traffic_gen.resource_helper.parse_csv_read(http_reader)
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
index f91852f74..c1664f2f0 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
@@ -11,35 +11,20 @@
# 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.
-#
from multiprocessing import Process, Queue
-import os
import time
import mock
from six.moves import configparser
import unittest
-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
from yardstick.benchmark.contexts import base as ctx_base
-
-
-SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
-
-STLClient = mock.MagicMock()
-stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
-stl_patch.start()
-
-if stl_patch:
- from yardstick.network_services.vnf_generic.vnf.vpe_vnf import ConfigCreate
- from yardstick.network_services.nfvi.resource import ResourceProfile
- from yardstick.network_services.vnf_generic.vnf.vpe_vnf import \
- VpeApproxVnf, VpeApproxSetupEnvHelper
+from yardstick.network_services.nfvi.resource import ResourceProfile
+from yardstick.network_services.vnf_generic.vnf import base as vnf_base
+from yardstick.network_services.vnf_generic.vnf import sample_vnf
+from yardstick.network_services.vnf_generic.vnf import vpe_vnf
+from yardstick.tests.unit.network_services.vnf_generic.vnf import test_base
TEST_FILE_YAML = 'nsb_test_case.yaml'
@@ -48,7 +33,7 @@ NAME = 'vnf_1'
PING_OUTPUT_1 = "Pkts in: 101\r\n\tPkts dropped by AH: 100\r\n\tPkts dropped by other: 100"
-MODULE_PATH = FileAbsPath(__file__)
+MODULE_PATH = test_base.FileAbsPath(__file__)
get_file_abspath = MODULE_PATH.get_path
@@ -156,20 +141,20 @@ class TestConfigCreate(unittest.TestCase):
}
def test___init__(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- config_create = ConfigCreate(vnfd_helper, 2)
+ vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
+ config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
self.assertEqual(config_create.uplink_ports, ['xe0'])
self.assertEqual(config_create.downlink_ports, ['xe1'])
self.assertEqual(config_create.socket, 2)
def test_dpdk_port_to_link_id(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- config_create = ConfigCreate(vnfd_helper, 2)
+ vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
+ config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
self.assertEqual(config_create.dpdk_port_to_link_id_map, {'xe0': 0, 'xe1': 1})
def test_vpe_initialize(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- config_create = ConfigCreate(vnfd_helper, 2)
+ vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
+ config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
config_create.vpe_initialize(config)
self.assertEqual(config.get('EAL', 'log_level'), '0')
@@ -179,16 +164,16 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config.get('MEMPOOL1', 'pool_size'), '2M')
def test_vpe_rxq(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- config_create = ConfigCreate(vnfd_helper, 2)
+ vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
+ config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
config_create.downlink_ports = ['xe0']
config_create.vpe_rxq(config)
self.assertEqual(config.get('RXQ0.0', 'mempool'), 'MEMPOOL1')
def test_get_sink_swq(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- config_create = ConfigCreate(vnfd_helper, 2)
+ vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
+ config_create = vpe_vnf.ConfigCreate(vnfd_helper, 2)
config = configparser.ConfigParser()
config.add_section('PIPELINE0')
config.set('PIPELINE0', 'key1', 'value1')
@@ -205,8 +190,8 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config_create.get_sink_swq(config, 'PIPELINE0', 'key5', 5), 'SWQ0 SINK1')
def test_generate_vpe_script(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- vpe_config_vnf = ConfigCreate(vnfd_helper, 2)
+ vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
+ vpe_config_vnf = vpe_vnf.ConfigCreate(vnfd_helper, 2)
intf = [
{
"name": 'xe1',
@@ -230,15 +215,34 @@ class TestConfigCreate(unittest.TestCase):
self.assertNotEqual(result, '')
def test_create_vpe_config(self):
- vnfd_helper = VnfdHelper(self.VNFD_0)
- config_create = ConfigCreate(vnfd_helper, 23)
- config_create.downlink_ports = ['xe1']
+ vnfd_helper = vnf_base.VnfdHelper(self.VNFD_0)
+ config_create = vpe_vnf.ConfigCreate(vnfd_helper, 23)
config_create.uplink_ports = ['xe1']
- curr_path = os.path.dirname(os.path.abspath(__file__))
- vpe_cfg = "samples/vnf_samples/nsut/vpe/vpe_config"
- vnf_cfg = os.path.join(curr_path, "../../../../..", vpe_cfg)
- config_create.create_vpe_config(vnf_cfg)
- os.system("git checkout -- %s" % vnf_cfg)
+ with mock.patch.object(config_create, 'vpe_upstream') as mock_up, \
+ mock.patch.object(config_create, 'vpe_downstream') as \
+ mock_down, \
+ mock.patch.object(config_create, 'vpe_tmq') as mock_tmq, \
+ mock.patch.object(config_create, 'vpe_initialize') as \
+ mock_ini, \
+ mock.patch.object(config_create, 'vpe_rxq') as mock_rxq:
+ mock_ini_obj = mock.Mock()
+ mock_rxq_obj = mock.Mock()
+ mock_up_obj = mock.Mock()
+ mock_down_obj = mock.Mock()
+ mock_tmq_obj = mock.Mock()
+ mock_ini.return_value = mock_ini_obj
+ mock_rxq.return_value = mock_rxq_obj
+ mock_up.return_value = mock_up_obj
+ mock_down.return_value = mock_down_obj
+ mock_tmq.return_value = mock_tmq_obj
+ config_create.create_vpe_config('fake_config_file')
+
+ mock_rxq.assert_called_once_with(mock_ini_obj)
+ mock_up.assert_called_once_with('fake_config_file', 0)
+ mock_down.assert_called_once_with('fake_config_file', 0)
+ mock_tmq.assert_called_once_with(mock_down_obj, 0)
+ mock_up_obj.write.assert_called_once()
+ mock_tmq_obj.write.assert_called_once()
class TestVpeApproxVnf(unittest.TestCase):
@@ -410,7 +414,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens513f0',
- 'vld_id': VpeApproxVnf.DOWNLINK,
+ 'vld_id': vpe_vnf.VpeApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -444,7 +448,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens785f0',
- 'vld_id': VpeApproxVnf.UPLINK,
+ 'vld_id': vpe_vnf.VpeApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -475,7 +479,7 @@ class TestVpeApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens786f0',
- 'vld_id': VpeApproxVnf.UPLINK,
+ 'vld_id': vpe_vnf.VpeApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -487,7 +491,7 @@ class TestVpeApproxVnf(unittest.TestCase):
},
'xe1': {
'local_iface_name': 'ens786f1',
- 'vld_id': VpeApproxVnf.DOWNLINK,
+ 'vld_id': vpe_vnf.VpeApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -545,20 +549,21 @@ class TestVpeApproxVnf(unittest.TestCase):
self._mock_time_sleep.stop()
def test___init__(self):
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
self.assertIsNone(vpe_approx_vnf._vnf_process)
- @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server',
+ return_value='mock_node')
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_collect_kpi_sa_not_running(self, ssh, *args):
- mock_ssh(ssh)
+ test_base.mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
resource.check_if_system_agent_running.return_value = 1, ''
resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}
resource.check_if_system_agent_running.return_value = (1, None)
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.scenario_helper.scenario_cfg = {
'nodes': {vpe_approx_vnf.name: "mock"}
}
@@ -577,16 +582,17 @@ class TestVpeApproxVnf(unittest.TestCase):
}
self.assertEqual(vpe_approx_vnf.collect_kpi(), expected)
- @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server',
+ return_value='mock_node')
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_collect_kpi_sa_running(self, ssh, *args):
- mock_ssh(ssh)
+ test_base.mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
resource.check_if_system_agent_running.return_value = 0, '1234'
resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.scenario_helper.scenario_cfg = {
'nodes': {vpe_approx_vnf.name: "mock"}
}
@@ -605,20 +611,20 @@ class TestVpeApproxVnf(unittest.TestCase):
}
self.assertEqual(vpe_approx_vnf.collect_kpi(), expected)
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_vnf_execute(self, ssh):
- mock_ssh(ssh)
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ test_base.mock_ssh(ssh)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.q_in = mock.MagicMock()
vpe_approx_vnf.q_out = mock.MagicMock()
vpe_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
self.assertEqual(vpe_approx_vnf.vnf_execute("quit", 0), '')
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_run_vpe(self, ssh):
- mock_ssh(ssh)
+ test_base.mock_ssh(ssh)
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML)
vpe_approx_vnf.vnf_cfg = {
'lb_config': 'SW',
@@ -647,11 +653,11 @@ class TestVpeApproxVnf(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig")
@mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.ConfigCreate")
@mock.patch("six.moves.builtins.open")
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_build_config(self, ssh, *args):
- mock_ssh(ssh)
- vpe_approx_vnf = VpeApproxSetupEnvHelper(mock.MagicMock(),
- mock.MagicMock(), mock.MagicMock())
+ test_base.mock_ssh(ssh)
+ vpe_approx_vnf = vpe_vnf.VpeApproxSetupEnvHelper(
+ mock.MagicMock(), mock.MagicMock(), mock.MagicMock())
vpe_approx_vnf.tc_file_name = get_file_abspath(TEST_FILE_YAML)
vpe_approx_vnf.generate_port_pairs = mock.Mock()
vpe_approx_vnf.vnf_cfg = {
@@ -687,9 +693,9 @@ class TestVpeApproxVnf(unittest.TestCase):
expected = 'sudo tool_path -p 0x3 -f /tmp/vpe_config -s /tmp/vpe_script --hwlb 3'
self.assertEqual(vpe_approx_vnf.build_config(), expected)
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_wait_for_instantiate(self, ssh):
- mock_ssh(ssh)
+ test_base.mock_ssh(ssh)
mock_process = mock.Mock(autospec=Process)
mock_process.is_alive.return_value = True
@@ -701,18 +707,19 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_resource = mock.MagicMock()
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf._vnf_process = mock_process
vpe_approx_vnf.q_out = mock_q_out
- vpe_approx_vnf.queue_wrapper = mock.Mock(autospec=QueueFileWrapper)
+ vpe_approx_vnf.queue_wrapper = mock.Mock(
+ autospec=vnf_base.QueueFileWrapper)
vpe_approx_vnf.resource_helper.resource = mock_resource
vpe_approx_vnf.q_out.put("pipeline>")
self.assertEqual(vpe_approx_vnf.wait_for_instantiate(), 432)
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_wait_for_instantiate_fragmented(self, ssh):
- mock_ssh(ssh)
+ test_base.mock_ssh(ssh)
mock_process = mock.Mock(autospec=Process)
mock_process.is_alive.return_value = True
@@ -725,17 +732,18 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_resource = mock.MagicMock()
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf._vnf_process = mock_process
vpe_approx_vnf.q_out = mock_q_out
- vpe_approx_vnf.queue_wrapper = mock.Mock(autospec=QueueFileWrapper)
+ vpe_approx_vnf.queue_wrapper = mock.Mock(
+ autospec=vnf_base.QueueFileWrapper)
vpe_approx_vnf.resource_helper.resource = mock_resource
self.assertEqual(vpe_approx_vnf.wait_for_instantiate(), 432)
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_wait_for_instantiate_crash(self, ssh):
- mock_ssh(ssh, exec_result=(1, "", ""))
+ test_base.mock_ssh(ssh, exec_result=(1, "", ""))
mock_process = mock.Mock(autospec=Process)
mock_process.is_alive.return_value = False
@@ -743,7 +751,7 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_resource = mock.MagicMock()
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf._vnf_process = mock_process
vpe_approx_vnf.resource_helper.resource = mock_resource
@@ -752,9 +760,9 @@ class TestVpeApproxVnf(unittest.TestCase):
self.assertIn('VNF process died', str(raised.exception))
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_wait_for_instantiate_panic(self, ssh):
- mock_ssh(ssh, exec_result=(1, "", ""))
+ test_base.mock_ssh(ssh, exec_result=(1, "", ""))
mock_process = mock.Mock(autospec=Process)
mock_process.is_alive.return_value = True
@@ -762,7 +770,7 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_resource = mock.MagicMock()
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf._vnf_process = mock_process
vpe_approx_vnf.resource_helper.resource = mock_resource
@@ -772,9 +780,9 @@ class TestVpeApproxVnf(unittest.TestCase):
self.assertIn('Error starting', str(raised.exception))
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_wait_for_instantiate_panic_fragmented(self, ssh):
- mock_ssh(ssh, exec_result=(1, "", ""))
+ test_base.mock_ssh(ssh, exec_result=(1, "", ""))
mock_process = mock.Mock(autospec=Process)
mock_process.is_alive.return_value = True
@@ -787,7 +795,7 @@ class TestVpeApproxVnf(unittest.TestCase):
mock_resource = mock.MagicMock()
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf._vnf_process = mock_process
vpe_approx_vnf.q_out = mock_q_out
vpe_approx_vnf.resource_helper.resource = mock_resource
@@ -797,11 +805,11 @@ class TestVpeApproxVnf(unittest.TestCase):
self.assertIn('Error starting', str(raised.exception))
- @mock.patch(SSH_HELPER)
+ @mock.patch.object(sample_vnf, 'VnfSshHelper')
def test_terminate(self, ssh):
- mock_ssh(ssh)
+ test_base.mock_ssh(ssh)
- vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf = vpe_vnf.VpeApproxVnf(NAME, self.VNFD_0)
vpe_approx_vnf._vnf_process = mock.MagicMock()
vpe_approx_vnf._resource_collect_stop = mock.Mock()
vpe_approx_vnf.resource_helper = mock.MagicMock()