summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ci/prepare_env.sh28
-rw-r--r--tests/unit/network_services/collector/test_publisher.py2
-rw-r--r--tests/unit/network_services/collector/test_subscriber.py2
-rw-r--r--tests/unit/network_services/helpers/test_cpu.py2
-rw-r--r--tests/unit/network_services/helpers/test_dpdkbindnic_helper.py2
-rw-r--r--tests/unit/network_services/helpers/test_samplevnf_helper.py405
-rw-r--r--tests/unit/network_services/libs/ixia_libs/test_IxNet.py4
-rw-r--r--tests/unit/network_services/nfvi/test_collectd.py54
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py5
-rw-r--r--tests/unit/network_services/traffic_profile/test_base.py2
-rw-r--r--tests/unit/network_services/traffic_profile/test_fixed.py4
-rw-r--r--tests/unit/network_services/traffic_profile/test_http.py10
-rw-r--r--tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py11
-rw-r--r--tests/unit/network_services/traffic_profile/test_rfc2544.py74
-rw-r--r--tests/unit/network_services/traffic_profile/test_trex_traffic_profile.py14
-rw-r--r--tests/unit/network_services/vnf_generic/test_vnfdgen.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py4
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_base.py4
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py7
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py4
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py6
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py6
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py2
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py2
32 files changed, 253 insertions, 419 deletions
diff --git a/tests/ci/prepare_env.sh b/tests/ci/prepare_env.sh
index caef8acce..37b72b369 100755
--- a/tests/ci/prepare_env.sh
+++ b/tests/ci/prepare_env.sh
@@ -28,34 +28,12 @@ OPENRC=/etc/yardstick/openstack.creds
INSTALLERS=(apex compass fuel joid)
RC_VAR_EXIST=false
-if [ "${OS_AUTH_URL}" -a "${OS_USERNAME}" -a "${OS_PASSWORD}" -a "${EXTERNAL_NETWORK}" ];then
+if [[ "${OS_AUTH_URL}" && "${OS_USERNAME}" && "${OS_PASSWORD}" && "${EXTERNAL_NETWORK}" ]];then
RC_VAR_EXIST=true
fi
-if [ "${RC_VAR_EXIST}" = false ]; then
- if [ ! -f $OPENRC ];then
- # credentials file is not given, check if environment variables are set
- # to get the creds using fetch_os_creds.sh later on
- echo "INFO: Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
- if [ -z ${INSTALLER_TYPE} ]; then
- echo "environment variable 'INSTALLER_TYPE' is not defined."
- exit 1
- elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
- echo "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
- else
- echo "Invalid env variable INSTALLER_TYPE=${INSTALLER_TYPE}"
- exit 1
- fi
-
- if [ "$DEPLOY_TYPE" == "virt" ]; then
- FETCH_CRED_ARG="-v -d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
- else
- FETCH_CRED_ARG="-d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
- fi
-
- $RELENG_REPO_DIR/utils/fetch_os_creds.sh $FETCH_CRED_ARG
- fi
- source $OPENRC
+if [[ "${RC_VAR_EXIST}" = false && -f ${OPENRC} ]]; then
+ . ${OPENRC}
fi
export EXTERNAL_NETWORK INSTALLER_TYPE DEPLOY_TYPE NODE_NAME
diff --git a/tests/unit/network_services/collector/test_publisher.py b/tests/unit/network_services/collector/test_publisher.py
index d1e56e114..4a175841d 100644
--- a/tests/unit/network_services/collector/test_publisher.py
+++ b/tests/unit/network_services/collector/test_publisher.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/collector/test_subscriber.py b/tests/unit/network_services/collector/test_subscriber.py
index f324f627d..d4b4ecf7a 100644
--- a/tests/unit/network_services/collector/test_subscriber.py
+++ b/tests/unit/network_services/collector/test_subscriber.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/helpers/test_cpu.py b/tests/unit/network_services/helpers/test_cpu.py
index 7ea6bd0fc..1f9d3f219 100644
--- a/tests/unit/network_services/helpers/test_cpu.py
+++ b/tests/unit/network_services/helpers/test_cpu.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
index cc980640c..367072e84 100644
--- a/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
+++ b/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/helpers/test_samplevnf_helper.py b/tests/unit/network_services/helpers/test_samplevnf_helper.py
index 05acdfaa9..3b6c89d3a 100644
--- a/tests/unit/network_services/helpers/test_samplevnf_helper.py
+++ b/tests/unit/network_services/helpers/test_samplevnf_helper.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,14 +13,12 @@
# limitations under the License.
#
-from __future__ import absolute_import
-from __future__ import division
-
-import unittest
-
import mock
+import os
+import six
+import unittest
-from yardstick.network_services.helpers.samplevnf_helper import MultiPortConfig, PortPairs
+from yardstick.network_services.helpers import samplevnf_helper
from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
@@ -30,31 +26,32 @@ class TestPortPairs(unittest.TestCase):
def test_port_pairs_list(self):
vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
interfaces = vnfd['vdu'][0]['external-interface']
- port_pairs = PortPairs(interfaces)
+ port_pairs = samplevnf_helper.PortPairs(interfaces)
self.assertEqual(port_pairs.port_pair_list, [("xe0", "xe1")])
def test_valid_networks(self):
vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
interfaces = vnfd['vdu'][0]['external-interface']
- port_pairs = PortPairs(interfaces)
- self.assertEqual(port_pairs.valid_networks, [("uplink_0", "downlink_0")])
+ port_pairs = samplevnf_helper.PortPairs(interfaces)
+ self.assertEqual(port_pairs.valid_networks, [
+ ("uplink_0", "downlink_0")])
def test_all_ports(self):
vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
interfaces = vnfd['vdu'][0]['external-interface']
- port_pairs = PortPairs(interfaces)
+ port_pairs = samplevnf_helper.PortPairs(interfaces)
self.assertEqual(set(port_pairs.all_ports), {"xe0", "xe1"})
def test_uplink_ports(self):
vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
interfaces = vnfd['vdu'][0]['external-interface']
- port_pairs = PortPairs(interfaces)
+ port_pairs = samplevnf_helper.PortPairs(interfaces)
self.assertEqual(port_pairs.uplink_ports, ["xe0"])
def test_downlink_ports(self):
vnfd = TestMultiPortConfig.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
interfaces = vnfd['vdu'][0]['external-interface']
- port_pairs = PortPairs(interfaces)
+ port_pairs = samplevnf_helper.PortPairs(interfaces)
self.assertEqual(port_pairs.downlink_ports, ["xe1"])
@@ -63,14 +60,14 @@ class TestMultiPortConfig(unittest.TestCase):
VNFD_0 = {'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'}],
+ [{'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':
@@ -121,7 +118,7 @@ class TestMultiPortConfig(unittest.TestCase):
},
'vnfd-connection-point-ref': 'xe1',
'name': 'xe1'}
- ]}],
+ ]}],
'description': 'Vpe approximation using DPDK',
'mgmt-interface':
{'vdu-id': 'vpevnf-baremetal',
@@ -143,67 +140,85 @@ class TestMultiPortConfig(unittest.TestCase):
}
}
+ def setUp(self):
+ self._mock_open = mock.patch.object(six.moves.builtins, 'open')
+ self.mock_open = self._mock_open.start()
+ self._mock_os = mock.patch.object(os, 'path')
+ self.mock_os = self._mock_os.start()
+ self._mock_config_parser = mock.patch.object(
+ samplevnf_helper, 'ConfigParser')
+ self.mock_config_parser = self._mock_config_parser.start()
+
+ self.addCleanup(self._cleanup)
+
+ def _cleanup(self):
+ self._mock_open.stop()
+ self._mock_os.stop()
+ self._mock_config_parser.stop()
+
def test_validate_ip_and_prefixlen(self):
- ip_addr, prefix_len = MultiPortConfig.validate_ip_and_prefixlen('10.20.30.40', '16')
+ ip_addr, prefix_len = (
+ samplevnf_helper.MultiPortConfig.validate_ip_and_prefixlen(
+ '10.20.30.40', '16'))
self.assertEqual(ip_addr, '10.20.30.40')
self.assertEqual(prefix_len, 16)
- ip_addr, prefix_len = MultiPortConfig.validate_ip_and_prefixlen('::1', '40')
+ ip_addr, prefix_len = (
+ samplevnf_helper.MultiPortConfig.validate_ip_and_prefixlen(
+ '::1', '40'))
self.assertEqual(ip_addr, '0000:0000:0000:0000:0000:0000:0000:0001')
self.assertEqual(prefix_len, 40)
def test_validate_ip_and_prefixlen_negative(self):
with self.assertRaises(AttributeError):
- MultiPortConfig.validate_ip_and_prefixlen('', '')
+ samplevnf_helper.MultiPortConfig.validate_ip_and_prefixlen('', '')
with self.assertRaises(AttributeError):
- MultiPortConfig.validate_ip_and_prefixlen('10.20.30.400', '16')
+ samplevnf_helper.MultiPortConfig.validate_ip_and_prefixlen(
+ '10.20.30.400', '16')
with self.assertRaises(AttributeError):
- MultiPortConfig.validate_ip_and_prefixlen('10.20.30.40', '33')
+ samplevnf_helper.MultiPortConfig.validate_ip_and_prefixlen(
+ '10.20.30.40', '33')
with self.assertRaises(AttributeError):
- MultiPortConfig.validate_ip_and_prefixlen('::1', '129')
+ samplevnf_helper.MultiPortConfig.validate_ip_and_prefixlen(
+ '::1', '129')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test___init__(self, mock_open, mock_os, ConfigParser):
+ def test___init__(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
self.assertEqual(0, opnfv_vnf.swq)
- mock_os.path = mock.MagicMock()
- mock_os.path.isfile = mock.Mock(return_value=False)
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ self.mock_os.path = mock.MagicMock()
+ self.mock_os.path.isfile = mock.Mock(return_value=False)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
self.assertEqual(0, opnfv_vnf.swq)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_update_timer(self, mock_open, mock_os, ConfigParser):
+ def test_update_timer(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.update_write_parser = mock.MagicMock()
- self.assertEqual(None, opnfv_vnf.update_timer())
+ self.assertIsNone(opnfv_vnf.update_timer())
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_script(self, mock_open, mock_os, ConfigParser):
+ def test_generate_script(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = VnfdHelper(self.VNFD_0)
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -218,15 +233,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.lb_config = 'HW'
self.assertIsNotNone(opnfv_vnf.generate_script(self.VNFD))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_script_data(self, mock_open, mock_os, ConfigParser):
+ def test_generate_script_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -240,15 +253,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.generate_rule_config = mock.Mock()
self.assertIsNotNone(opnfv_vnf.generate_script_data())
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_rule_config(self, mock_open, mock_os, ConfigParser):
+ def test_generate_rule_config(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -261,9 +272,11 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'ACL'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.get_ports_gateway6 = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway6 = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway6 = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
opnfv_vnf.interfaces = opnfv_vnf.vnfd['vdu'][0]['external-interface']
@@ -272,15 +285,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.rules = 'new'
self.assertIsNotNone(opnfv_vnf.generate_rule_config())
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_action_config(self, mock_open, mock_os, ConfigParser):
+ def test_generate_action_config(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -293,22 +304,22 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.get_ports_gateway6 = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway6 = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway6 = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
self.assertIsNotNone(opnfv_vnf.generate_action_config())
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_arp_config6(self, mock_open, mock_os, ConfigParser):
+ def test_generate_arp_config6(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -321,24 +332,24 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.get_ports_gateway6 = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway6 = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway6 = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.interfaces = mock.MagicMock()
opnfv_vnf.get_ports_gateway6 = mock.Mock()
self.assertIsNotNone(opnfv_vnf.generate_arp_config6())
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_arp_config(self, mock_open, mock_os, ConfigParser):
+ def test_generate_arp_config(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -351,24 +362,24 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.get_port_pairs = mock.Mock()
opnfv_vnf.vnf_type = 'VFW'
opnfv_vnf.get_ports_gateway = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.get_ports_gateway6 = mock.Mock(return_value=u'1.1.1.1')
- opnfv_vnf.get_netmask_gateway6 = mock.Mock(return_value=u'255.255.255.0')
+ opnfv_vnf.get_netmask_gateway6 = mock.Mock(
+ return_value=u'255.255.255.0')
opnfv_vnf.txrx_pipeline = ''
opnfv_vnf.rules = ''
opnfv_vnf.interfaces = mock.MagicMock()
opnfv_vnf.get_ports_gateway6 = mock.Mock()
self.assertIsNotNone(opnfv_vnf.generate_arp_config())
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_get_ports_gateway(self, mock_open, mock_os, ConfigParser):
+ def test_get_ports_gateway(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -387,15 +398,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
self.assertIsNotNone(opnfv_vnf.get_ports_gateway('xe0'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_get_ports_gateway6(self, mock_open, mock_os, ConfigParser):
+ def test_get_ports_gateway6(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -414,15 +423,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
self.assertIsNotNone(opnfv_vnf.get_ports_gateway6('xe0'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_get_netmask_gateway(self, mock_open, mock_os, ConfigParser):
+ def test_get_netmask_gateway(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -441,15 +448,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
self.assertIsNotNone(opnfv_vnf.get_netmask_gateway('xe0'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_get_netmask_gateway6(self, mock_open, mock_os, ConfigParser):
+ def test_get_netmask_gateway6(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -468,16 +473,14 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
self.assertIsNotNone(opnfv_vnf.get_netmask_gateway6('xe0'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_link_config(self, mock_open, mock_os, ConfigParser):
+ def test_generate_link_config(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -495,20 +498,19 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
opnfv_vnf.interfaces = opnfv_vnf.vnfd['vdu'][0]['external-interface']
opnfv_vnf.all_ports = ['32', '1', '987']
- opnfv_vnf.validate_ip_and_prefixlen = mock.Mock(return_value=('10.20.30.40', 16))
+ opnfv_vnf.validate_ip_and_prefixlen = mock.Mock(
+ return_value=('10.20.30.40', 16))
result = opnfv_vnf.generate_link_config()
self.assertEqual(len(result.splitlines()), 9)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_config(self, mock_open, mock_os, ConfigParser):
+ def test_generate_config(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.get_config_tpl_data = mock.MagicMock()
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
@@ -531,17 +533,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.is_openstack = False
self.assertIsNone(opnfv_vnf.generate_config())
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_get_config_tpl_data(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_get_config_tpl_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -555,17 +553,13 @@ class TestMultiPortConfig(unittest.TestCase):
self.assertIsNotNone(opnfv_vnf.get_config_tpl_data('filename'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_get_txrx_tpl_data(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_get_txrx_tpl_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -579,17 +573,13 @@ class TestMultiPortConfig(unittest.TestCase):
self.assertIsNotNone(opnfv_vnf.get_txrx_tpl_data('filename'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_init_write_parser_template(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_init_write_parser_template(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -608,17 +598,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.write_parser.set = mock.Mock()
self.assertIsNone(opnfv_vnf.init_write_parser_template('filename'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_init_write_parser_template_2(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_init_write_parser_template_2(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -632,17 +618,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.read_parser.items = mock.MagicMock()
self.assertIsNone(opnfv_vnf.init_write_parser_template('filename'))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_update_write_parser(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_update_write_parser(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -658,17 +640,13 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.pipeline_counter = 0
self.assertIsNone(opnfv_vnf.update_write_parser({'filename': 1}))
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_get_worker_threads(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_get_worker_threads(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -692,17 +670,14 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.get_worker_threads(3)
self.assertEqual(2, result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_next_core_id(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ # TODO(elfoley): Split this test into smaller tests
+ def test_generate_next_core_id(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -719,26 +694,22 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.worker_config = '1t'
opnfv_vnf.start_core = 0
result = opnfv_vnf.generate_next_core_id()
- self.assertEqual(None, result)
+ self.assertIsNone(result)
opnfv_vnf.worker_config = '2t'
opnfv_vnf.start_core = 'a'
self.assertRaises(ValueError, opnfv_vnf.generate_next_core_id)
opnfv_vnf.worker_config = '2t'
opnfv_vnf.start_core = 1
result = opnfv_vnf.generate_next_core_id()
- self.assertEqual(None, result)
+ self.assertIsNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_lb_to_port_pair_mapping(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_generate_lb_to_port_pair_mapping(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = VnfdHelper(self.VNFD_0)
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.txrx_pipeline = ''
@@ -754,24 +725,20 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.worker_config = '1t'
opnfv_vnf.start_core = 0
opnfv_vnf.lb_count = 1
- opnfv_vnf._port_pairs = PortPairs(vnfd_mock.interfaces)
+ opnfv_vnf._port_pairs = samplevnf_helper.PortPairs(vnfd_mock.interfaces)
opnfv_vnf.port_pair_list = opnfv_vnf._port_pairs.port_pair_list
result = opnfv_vnf.generate_lb_to_port_pair_mapping()
- self.assertEqual(None, result)
+ self.assertIsNone(result)
result = opnfv_vnf.set_priv_to_pub_mapping()
self.assertEqual('(0,1)', result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_set_priv_que_handler(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_set_priv_que_handler(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = VnfdHelper(self.VNFD_0)
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -790,11 +757,10 @@ class TestMultiPortConfig(unittest.TestCase):
opnfv_vnf.start_core = 0
opnfv_vnf.lb_count = 1
result = opnfv_vnf.set_priv_que_handler()
- self.assertEqual(None, result)
+ self.assertIsNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- def test_generate_arp_route_tbl(self, *_):
+ def test_generate_arp_route_tbl(self):
+ # ELF: could n=do this in setup
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = ""
@@ -821,7 +787,8 @@ class TestMultiPortConfig(unittest.TestCase):
},
]
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.all_ports = [3, 2, 5]
expected = 'routeadd net 32 10.20.30.40 0xfffff000\n' \
@@ -830,17 +797,13 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.generate_arp_route_tbl()
self.assertEqual(result, expected)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_arpicmp_data(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_generate_arpicmp_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -875,17 +838,13 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.generate_arpicmp_data()
self.assertIsNotNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_final_txrx_data(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_generate_final_txrx_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -917,17 +876,13 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.generate_final_txrx_data()
self.assertIsNotNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_initial_txrx_data(self, mock_open, mock_os,
- ConfigParser, OrderedDict):
+ def test_generate_initial_txrx_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -971,17 +926,13 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.generate_initial_txrx_data()
self.assertIsNotNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_lb_data(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_generate_lb_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -1008,17 +959,13 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.generate_lb_data()
self.assertIsNotNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_vnf_data(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_generate_vnf_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -1057,17 +1004,13 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.generate_vnf_data()
self.assertIsNotNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_generate_config_data(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_generate_config_data(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = VnfdHelper(self.VNFD_0)
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
@@ -1123,17 +1066,13 @@ class TestMultiPortConfig(unittest.TestCase):
result = opnfv_vnf.generate_config_data()
self.assertIsNone(result)
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.open')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.os')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.ConfigParser')
- @mock.patch('yardstick.network_services.helpers.samplevnf_helper.OrderedDict')
- def test_init_eal(self, mock_open, mock_os, ConfigParser,
- OrderedDict):
+ def test_init_eal(self):
topology_file = mock.Mock()
config_tpl = mock.Mock()
tmp_file = mock.Mock()
vnfd_mock = mock.MagicMock()
- opnfv_vnf = MultiPortConfig(topology_file, config_tpl, tmp_file, vnfd_mock)
+ opnfv_vnf = samplevnf_helper.MultiPortConfig(
+ topology_file, config_tpl, tmp_file, vnfd_mock)
opnfv_vnf.socket = 0
opnfv_vnf.start_core = 0
opnfv_vnf.port_pair_list = [("xe0", "xe1")]
diff --git a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py b/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
index 3f374fb50..2a97048aa 100644
--- a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
+++ b/tests/unit/network_services/libs/ixia_libs/test_IxNet.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,7 +34,7 @@ class TestIxNextgen(unittest.TestCase):
self.assertIsNone(ixnet_gen._bidir)
@mock.patch("yardstick.network_services.libs.ixia_libs.IxNet.IxNet.sys")
- def test_connect(self, mock_sys):
+ def test_connect(self, *args):
ixnet_gen = IxNextgen()
ixnet_gen.get_config = mock.MagicMock()
diff --git a/tests/unit/network_services/nfvi/test_collectd.py b/tests/unit/network_services/nfvi/test_collectd.py
index 866c31d32..0ae175624 100644
--- a/tests/unit/network_services/nfvi/test_collectd.py
+++ b/tests/unit/network_services/nfvi/test_collectd.py
@@ -34,7 +34,7 @@ class TestAmqpConsumer(unittest.TestCase):
self.amqp_consumer._connection.add_on_close_callback = \
mock.Mock(return_value=0)
self.amqp_consumer._connection.channel = mock.Mock(return_value=0)
- self.assertEqual(None, self.amqp_consumer.on_connection_open(10))
+ self.assertIsNone(self.amqp_consumer.on_connection_open(10))
def test_on_connection_closed(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
@@ -42,13 +42,11 @@ class TestAmqpConsumer(unittest.TestCase):
self.amqp_consumer._connection.ioloop.stop = mock.Mock(return_value=0)
self.amqp_consumer._connection.add_timeout = mock.Mock(return_value=0)
self.amqp_consumer._closing = True
- self.assertEqual(None,
- self.amqp_consumer.on_connection_closed("", 404,
- "Not Found"))
+ self.assertIsNone(
+ self.amqp_consumer.on_connection_closed("", 404, "Not Found"))
self.amqp_consumer._closing = False
- self.assertEqual(None,
- self.amqp_consumer.on_connection_closed("", 404,
- "Not Found"))
+ self.assertIsNone(
+ self.amqp_consumer.on_connection_closed("", 404, "Not Found"))
def test_reconnect(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
@@ -56,7 +54,7 @@ class TestAmqpConsumer(unittest.TestCase):
self.amqp_consumer._connection.ioloop.stop = mock.Mock(return_value=0)
self.amqp_consumer.connect = mock.Mock(return_value=0)
self.amqp_consumer._closing = True
- self.assertEqual(None, self.amqp_consumer.reconnect())
+ self.assertIsNone(self.amqp_consumer.reconnect())
def test_on_channel_open(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
@@ -66,9 +64,8 @@ class TestAmqpConsumer(unittest.TestCase):
self.amqp_consumer.add_on_channel_close_callback = mock.Mock()
self.amqp_consumer._channel.exchange_declare = \
mock.Mock(return_value=0)
- self.assertEqual(None,
- self.amqp_consumer.on_channel_open(
- self.amqp_consumer._channel))
+ self.assertIsNone(
+ self.amqp_consumer.on_channel_open(self.amqp_consumer._channel))
def test_add_on_channel_close_callback(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
@@ -76,46 +73,44 @@ class TestAmqpConsumer(unittest.TestCase):
mock.Mock(return_value=0)
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.add_on_close_callback = mock.Mock()
- self.assertEqual(None,
- self.amqp_consumer.add_on_channel_close_callback())
+ self.assertIsNone(self.amqp_consumer.add_on_channel_close_callback())
def test_on_channel_closed(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
self.amqp_consumer._connection.close = mock.Mock(return_value=0)
_channel = mock.Mock()
- self.assertEqual(None,
- self.amqp_consumer.on_channel_closed(_channel,
- "", ""))
+ self.assertIsNone(
+ self.amqp_consumer.on_channel_closed(_channel, "", ""))
def test_ion_exchange_declareok(self):
self.amqp_consumer.setup_queue = mock.Mock(return_value=0)
- self.assertEqual(None, self.amqp_consumer.on_exchange_declareok(10))
+ self.assertIsNone(self.amqp_consumer.on_exchange_declareok(10))
def test_setup_queue(self):
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.add_on_close_callback = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.setup_queue("collectd"))
+ self.assertIsNone(self.amqp_consumer.setup_queue("collectd"))
def test_on_queue_declareok(self):
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.queue_bind = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.on_queue_declareok(10))
+ self.assertIsNone(self.amqp_consumer.on_queue_declareok(10))
def test__on_bindok(self):
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.basic_consume = mock.Mock()
self.amqp_consumer.add_on_cancel_callback = mock.Mock()
- self.assertEqual(None, self.amqp_consumer._on_bindok(10))
+ self.assertIsNone(self.amqp_consumer._on_bindok(10))
def test_add_on_cancel_callback(self):
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.add_on_cancel_callback = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.add_on_cancel_callback())
+ self.assertIsNone(self.amqp_consumer.add_on_cancel_callback())
def test_on_consumer_cancelled(self):
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.close = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.on_consumer_cancelled(10))
+ self.assertIsNone(self.amqp_consumer.on_consumer_cancelled(10))
def test_on_message(self):
body = "msg {} cpu/cpu-0/ipc 101010:10"
@@ -123,25 +118,24 @@ class TestAmqpConsumer(unittest.TestCase):
basic_deliver = mock.Mock()
basic_deliver.delivery_tag = mock.Mock(return_value=0)
self.amqp_consumer.ack_message = mock.Mock()
- self.assertEqual(None,
- self.amqp_consumer.on_message(10, basic_deliver,
- properties, body))
+ self.assertIsNone(
+ self.amqp_consumer.on_message(10, basic_deliver, properties, body))
def test_ack_message(self):
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.basic_ack = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.ack_message(10))
+ self.assertIsNone(self.amqp_consumer.ack_message(10))
def test_on_cancelok(self):
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.close = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.on_cancelok(10))
+ self.assertIsNone(self.amqp_consumer.on_cancelok(10))
def test_run(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
self.amqp_consumer.connect = mock.Mock()
self.amqp_consumer._connection.ioloop.start = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.run())
+ self.assertIsNone(self.amqp_consumer.run())
def test_stop(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
@@ -149,9 +143,9 @@ class TestAmqpConsumer(unittest.TestCase):
self.amqp_consumer._connection.ioloop.start = mock.Mock()
self.amqp_consumer._channel = mock.Mock()
self.amqp_consumer._channel.basic_cancel = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.stop())
+ self.assertIsNone(self.amqp_consumer.stop())
def test_close_connection(self):
self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
self.amqp_consumer._connection.close = mock.Mock()
- self.assertEqual(None, self.amqp_consumer.close_connection())
+ self.assertIsNone(self.amqp_consumer.close_connection())
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index 7ad166249..f5f7f0fe7 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -245,7 +245,7 @@ class TestResourceProfile(unittest.TestCase):
self.resource_profile.run_collectd_amqp = \
mock.Mock(return_value=0)
res = self.resource_profile.amqp_process_for_nfvi_kpi()
- self.assertEqual(None, res)
+ self.assertIsNone(res)
def test_amqp_collect_nfvi_kpi(self):
self.resource_profile.amqp_client = \
@@ -271,6 +271,3 @@ class TestResourceProfile(unittest.TestCase):
# TODO(efoley): Fix this incorrect test.
# Should check that we don't try to stop amqp when it's not running
self.assertIsNone(self.resource_profile.stop())
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/unit/network_services/traffic_profile/test_base.py b/tests/unit/network_services/traffic_profile/test_base.py
index 33f803286..3b8804976 100644
--- a/tests/unit/network_services/traffic_profile/test_base.py
+++ b/tests/unit/network_services/traffic_profile/test_base.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/traffic_profile/test_fixed.py b/tests/unit/network_services/traffic_profile/test_fixed.py
index eb182a2fb..dec94964b 100644
--- a/tests/unit/network_services/traffic_profile/test_fixed.py
+++ b/tests/unit/network_services/traffic_profile/test_fixed.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -119,4 +117,4 @@ class TestFixedProfile(unittest.TestCase):
fixed_profile = FixedProfile(self.TRAFFIC_PROFILE)
fixed_profile.params = self.TRAFFIC_PROFILE
fixed_profile.first_run = True
- self.assertEqual(None, fixed_profile.execute(traffic_generator))
+ self.assertIsNone(fixed_profile.execute(traffic_generator))
diff --git a/tests/unit/network_services/traffic_profile/test_http.py b/tests/unit/network_services/traffic_profile/test_http.py
index e818a0528..5d8029ea0 100644
--- a/tests/unit/network_services/traffic_profile/test_http.py
+++ b/tests/unit/network_services/traffic_profile/test_http.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,13 +31,11 @@ class TestTrafficProfileGenericHTTP(unittest.TestCase):
traffic_profile_generic_htt_p = \
TrafficProfileGenericHTTP(TrafficProfile)
traffic_generator = {}
- self.assertEqual(None,
- traffic_profile_generic_htt_p.execute(
- traffic_generator))
+ self.assertIsNone(
+ traffic_profile_generic_htt_p.execute(traffic_generator))
def test__send_http_request(self):
traffic_profile_generic_htt_p = \
TrafficProfileGenericHTTP(TrafficProfile)
- self.assertEqual(None,
- traffic_profile_generic_htt_p._send_http_request(
+ self.assertIsNone(traffic_profile_generic_htt_p._send_http_request(
"10.1.1.1", "250", "/req"))
diff --git a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
index f83d3341d..e8910d62b 100644
--- a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
+++ b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -474,7 +472,7 @@ class TestIXIARFC2544Profile(unittest.TestCase):
r_f_c2544_profile.get_multiplier = mock.Mock()
r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
ixia_obj = mock.MagicMock()
- self.assertEqual(None, r_f_c2544_profile.execute_traffic(traffic_generator, ixia_obj))
+ self.assertIsNone(r_f_c2544_profile.execute_traffic(traffic_generator, ixia_obj))
def test_update_traffic_profile(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
@@ -609,10 +607,5 @@ class TestIXIARFC2544Profile(unittest.TestCase):
mock.Mock(return_value={})
r_f_c2544_profile.full_profile = {}
r_f_c2544_profile._ixia_traffic_generate = mock.Mock()
- self.assertEqual(
- None,
+ self.assertIsNone(
r_f_c2544_profile.start_ixia_latency(traffic_generator, ixia_obj))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/unit/network_services/traffic_profile/test_rfc2544.py b/tests/unit/network_services/traffic_profile/test_rfc2544.py
index fe563e9fd..21c8f6d5b 100644
--- a/tests/unit/network_services/traffic_profile/test_rfc2544.py
+++ b/tests/unit/network_services/traffic_profile/test_rfc2544.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,9 +13,6 @@
# limitations under the License.
#
-from __future__ import absolute_import
-from __future__ import division
-
import unittest
import mock
@@ -51,29 +46,29 @@ class TestRFC2544Profile(unittest.TestCase):
'traffic_profile': {'traffic_type': 'RFC2544Profile',
'frame_rate': 100},
'downlink_0': {'ipv4':
- {'outer_l2': {'framesize':
- {'64B': '100', '1518B': '0',
- '128B': '0', '1400B': '0',
- '256B': '0', '373b': '0',
- '570B': '0'}},
- 'outer_l3v4': {'dstip4': '1.1.1.1-1.15.255.255',
- 'proto': 'udp',
- 'srcip4': '90.90.1.1-90.105.255.255',
- 'dscp': 0, 'ttl': 32, 'count': 1},
- 'outer_l4': {'srcport': '2001',
- 'dsrport': '1234', 'count': 1}}},
+ {'outer_l2': {'framesize':
+ {'64B': '100', '1518B': '0',
+ '128B': '0', '1400B': '0',
+ '256B': '0', '373b': '0',
+ '570B': '0'}},
+ 'outer_l3v4': {'dstip4': '1.1.1.1-1.15.255.255',
+ 'proto': 'udp',
+ 'srcip4': '90.90.1.1-90.105.255.255',
+ 'dscp': 0, 'ttl': 32, 'count': 1},
+ 'outer_l4': {'srcport': '2001',
+ 'dsrport': '1234', 'count': 1}}},
'uplink_0': {'ipv4':
- {'outer_l2': {'framesize':
- {'64B': '100', '1518B': '0',
- '128B': '0', '1400B': '0',
- '256B': '0', '373b': '0',
- '570B': '0'}},
- 'outer_l3v4': {'dstip4': '9.9.1.1-90.105.255.255',
- 'proto': 'udp',
- 'srcip4': '1.1.1.1-1.15.255.255',
- 'dscp': 0, 'ttl': 32, 'count': 1},
- 'outer_l4': {'dstport': '2001',
- 'srcport': '1234', 'count': 1}}},
+ {'outer_l2': {'framesize':
+ {'64B': '100', '1518B': '0',
+ '128B': '0', '1400B': '0',
+ '256B': '0', '373b': '0',
+ '570B': '0'}},
+ 'outer_l3v4': {'dstip4': '9.9.1.1-90.105.255.255',
+ 'proto': 'udp',
+ 'srcip4': '1.1.1.1-1.15.255.255',
+ 'dscp': 0, 'ttl': 32, 'count': 1},
+ 'outer_l4': {'dstport': '2001',
+ 'srcport': '1234', 'count': 1}}},
'schema': 'isb:traffic_profile:0.1'}
def test___init__(self):
@@ -86,12 +81,11 @@ class TestRFC2544Profile(unittest.TestCase):
"uplink_0": ["xe0"],
"downlink_0": ["xe1"],
}
- traffic_generator.client = \
- mock.Mock(return_value=True)
+ traffic_generator.client.return_value = True
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
r_f_c2544_profile.first_run = True
- self.assertEqual(None, r_f_c2544_profile.execute_traffic(traffic_generator))
+ self.assertIsNone(r_f_c2544_profile.execute_traffic(traffic_generator))
def test_get_drop_percentage(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
@@ -99,7 +93,7 @@ class TestRFC2544Profile(unittest.TestCase):
"uplink_0": ["xe0"],
"downlink_0": ["xe1"],
}
- traffic_generator.client = mock.Mock(return_value=True)
+ traffic_generator.client.return_value = True
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
@@ -133,7 +127,7 @@ class TestRFC2544Profile(unittest.TestCase):
'rx_throughput_fps': 20,
},
}
- traffic_generator.generate_samples = mock.MagicMock(return_value=samples)
+ traffic_generator.generate_samples.return_value = samples
traffic_generator.RUN_DURATION = 30
traffic_generator.rfc2544_helper.tolerance_low = 0.0001
traffic_generator.rfc2544_helper.tolerance_high = 0.0001
@@ -179,7 +173,8 @@ class TestRFC2544Profile(unittest.TestCase):
'rx_throughput_fps': 20,
},
}
- traffic_generator.generate_samples = mock.MagicMock(return_value=samples)
+ traffic_generator.generate_samples = mock.MagicMock(
+ return_value=samples)
traffic_generator.RUN_DURATION = 30
traffic_generator.rfc2544_helper.tolerance_low = 0.0001
traffic_generator.rfc2544_helper.tolerance_high = 0.0001
@@ -196,7 +191,7 @@ class TestRFC2544Profile(unittest.TestCase):
mock.Mock(return_value=True)
r_f_c2544_profile = RFC2544Profile(self.TRAFFIC_PROFILE)
r_f_c2544_profile.params = self.PROFILE
- self.assertEqual(None, r_f_c2544_profile.execute_traffic(traffic_generator))
+ self.assertIsNone(r_f_c2544_profile.execute_traffic(traffic_generator))
samples = {}
for ifname in range(1):
name = "xe{}".format(ifname)
@@ -217,7 +212,7 @@ class TestRFC2544Profile(unittest.TestCase):
'tx_throughput_mbps': 10, 'rx_throughput_fps': 20
}
}
- traffic_generator.generate_samples = mock.MagicMock(return_value=samples)
+ traffic_generator.generate_samples = mock.Mock(return_value=samples)
traffic_generator.RUN_DURATION = 30
traffic_generator.rfc2544_helper.tolerance_low = 0.0001
traffic_generator.rfc2544_helper.tolerance_high = 0.0001
@@ -277,10 +272,5 @@ class TestRFC2544Profile(unittest.TestCase):
r_f_c2544_profile.calculate_pps = mock.Mock(return_value=[2274546.67,
1.0])
- self.assertEqual(None,
- r_f_c2544_profile.execute_latency(traffic_generator,
- samples))
-
-
-if __name__ == '__main__':
- unittest.main()
+ self.assertIsNone(r_f_c2544_profile.execute_latency(traffic_generator,
+ samples))
diff --git a/tests/unit/network_services/traffic_profile/test_trex_traffic_profile.py b/tests/unit/network_services/traffic_profile/test_trex_traffic_profile.py
index c34b97531..d1009a5e8 100644
--- a/tests/unit/network_services/traffic_profile/test_trex_traffic_profile.py
+++ b/tests/unit/network_services/traffic_profile/test_trex_traffic_profile.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -153,11 +151,11 @@ class TestTrexProfile(unittest.TestCase):
trex_profile = \
TrexProfile(TrafficProfile)
- self.assertEqual(None, trex_profile.set_qinq(qinq))
+ self.assertIsNone(trex_profile.set_qinq(qinq))
qinq = {"S-VLAN": {"id": "128-130", "priority": 0, "cfi": 0},
"C-VLAN": {"id": "512-515", "priority": 0, "cfi": 0}}
- self.assertEqual(None, trex_profile.set_qinq(qinq))
+ self.assertIsNone(trex_profile.set_qinq(qinq))
def test__set_outer_l2_fields(self):
trex_profile = \
@@ -166,14 +164,14 @@ class TestTrexProfile(unittest.TestCase):
"C-VLAN": {"id": 512, "priority": 0, "cfi": 0}}
outer_l2 = self.PROFILE[TrafficProfile.UPLINK]['ipv4']['outer_l2']
outer_l2['QinQ'] = qinq
- self.assertEqual(None, trex_profile._set_outer_l2_fields(outer_l2))
+ self.assertIsNone(trex_profile._set_outer_l2_fields(outer_l2))
def test__set_outer_l3v4_fields(self):
trex_profile = \
TrexProfile(TrafficProfile)
outer_l3v4 = self.PROFILE[TrafficProfile.UPLINK]['ipv4']['outer_l3v4']
outer_l3v4['proto'] = 'tcp'
- self.assertEqual(None, trex_profile._set_outer_l3v4_fields(outer_l3v4))
+ self.assertIsNone(trex_profile._set_outer_l3v4_fields(outer_l3v4))
def test__set_outer_l3v6_fields(self):
trex_profile = \
@@ -182,13 +180,13 @@ class TestTrexProfile(unittest.TestCase):
outer_l3v6['proto'] = 'tcp'
outer_l3v6['tc'] = 1
outer_l3v6['hlim'] = 10
- self.assertEqual(None, trex_profile._set_outer_l3v6_fields(outer_l3v6))
+ self.assertIsNone(trex_profile._set_outer_l3v6_fields(outer_l3v6))
def test__set_outer_l4_fields(self):
trex_profile = \
TrexProfile(TrafficProfile)
outer_l4 = self.PROFILE[TrafficProfile.UPLINK]['ipv4']['outer_l4']
- self.assertEqual(None, trex_profile._set_outer_l4_fields(outer_l4))
+ self.assertIsNone(trex_profile._set_outer_l4_fields(outer_l4))
def test_get_streams(self):
trex_profile = \
diff --git a/tests/unit/network_services/vnf_generic/test_vnfdgen.py b/tests/unit/network_services/vnf_generic/test_vnfdgen.py
index ee881c963..2ab14129b 100644
--- a/tests/unit/network_services/vnf_generic/test_vnfdgen.py
+++ b/tests/unit/network_services/vnf_generic/test_vnfdgen.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
index a4055bf02..2971b55eb 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -346,4 +344,4 @@ class TestAclApproxVnf(unittest.TestCase):
acl_approx_vnf.vnf_execute = mock.MagicMock()
acl_approx_vnf.dpdk_devbind = "dpdk-devbind.py"
acl_approx_vnf._resource_collect_stop = mock.Mock()
- self.assertEqual(None, acl_approx_vnf.terminate())
+ self.assertIsNone(acl_approx_vnf.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_base.py b/tests/unit/network_services/vnf_generic/vnf/test_base.py
index e9488f76f..664373f8f 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_base.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_base.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -195,7 +193,7 @@ class TestQueueFileWrapper(unittest.TestCase):
def test_close(self):
queue_file_wrapper = \
base.QueueFileWrapper(self.q_in, self.q_out, self.prompt)
- self.assertEqual(None, queue_file_wrapper.close())
+ self.assertIsNone(queue_file_wrapper.close())
def test_read(self):
queue_file_wrapper = \
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 62b3c7440..edaa0ad7e 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
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
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 ce905182c..faceeb695 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
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
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 46786a304..159b1f718 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
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py
index 9ed6fd5b3..c6292f258 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -261,7 +259,4 @@ class TestRouterVNF(unittest.TestCase):
router_vnf = RouterVNF(name, vnfd)
router_vnf._vnf_process = mock.MagicMock()
router_vnf._vnf_process.terminate = mock.Mock()
- self.assertEqual(None, router_vnf.terminate())
-
-if __name__ == '__main__':
- unittest.main()
+ self.assertIsNone(router_vnf.terminate())
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 b2e3fd85b..c7d2abcd5 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
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
index b93f9aad3..d831ddd3d 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
@@ -145,7 +145,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
ssh.from_node.return_value = ssh_mock
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
- self.assertEqual(None, ixload_traffic_gen.listen_traffic({}))
+ self.assertIsNone(ixload_traffic_gen.listen_traffic({}))
@mock.patch.object(utils, 'find_relative_file')
@mock.patch.object(utils, 'makedirs')
@@ -249,7 +249,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
def test_terminate(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
- self.assertEqual(None, ixload_traffic_gen.terminate())
+ self.assertIsNone(ixload_traffic_gen.terminate())
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
@mock.patch.object(ssh, 'SSH')
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
index ed2274e79..91a353d0d 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
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 0104e7f63..2151a3284 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
@@ -423,4 +423,4 @@ class TestProxTrafficGen(unittest.TestCase):
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())
+ self.assertIsNone(prox_traffic_gen.terminate())
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index aeabc367a..61fc012bc 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -172,7 +170,7 @@ class TestIXIATrafficGen(unittest.TestCase):
ssh.from_node.return_value = ssh_mock
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
ixnet_traffic_gen = IxiaTrafficGen(NAME, vnfd)
- self.assertEqual(None, ixnet_traffic_gen.listen_traffic({}))
+ self.assertIsNone(ixnet_traffic_gen.listen_traffic({}))
def test_instantiate(self, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
@@ -230,7 +228,7 @@ class TestIXIATrafficGen(unittest.TestCase):
ixnet_traffic_gen._ixia_traffic_gen.ix_stop_traffic = mock.Mock()
ixnet_traffic_gen._traffic_process = mock.MagicMock()
ixnet_traffic_gen._traffic_process.terminate = mock.Mock()
- self.assertEqual(None, ixnet_traffic_gen.terminate())
+ self.assertIsNone(ixnet_traffic_gen.terminate())
def _get_file_abspath(self, filename):
curr_path = os.path.dirname(os.path.abspath(__file__))
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
index 7342cfcdc..b9a95a945 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
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 618071507..f80d1f948 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
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -483,7 +481,3 @@ class TestTrexTrafficGen(unittest.TestCase):
client = mock.Mock(autospec=STLClient)
client.connect = mock.Mock(return_value=0)
self.assertIsNotNone(trex_traffic_gen.resource_helper._connect(client))
-
-
-if __name__ == '__main__':
- unittest.main()
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 472052b0a..4cf4320f9 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
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
index f2eca196f..48fc87ed4 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
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 c074dfb4c..8c45d973e 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
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");