summaryrefslogtreecommitdiffstats
path: root/tests/unit/network_services
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/network_services')
-rw-r--r--tests/unit/network_services/collector/test_subscriber.py88
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py2
-rw-r--r--tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py10
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_acl.py16
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_binsearch.py10
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_mpls.py6
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_profile.py14
-rw-r--r--tests/unit/network_services/traffic_profile/test_prox_ramp.py21
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py812
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py13
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py1
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py12
12 files changed, 680 insertions, 325 deletions
diff --git a/tests/unit/network_services/collector/test_subscriber.py b/tests/unit/network_services/collector/test_subscriber.py
index 373f5dccf..260f0bb27 100644
--- a/tests/unit/network_services/collector/test_subscriber.py
+++ b/tests/unit/network_services/collector/test_subscriber.py
@@ -19,51 +19,79 @@
from __future__ import absolute_import
import unittest
+import mock
from yardstick.network_services.collector import subscriber
-class CollectorTestCase(unittest.TestCase):
-
- TRAFFIC_PROFILE = {}
- VNFS = {}
-
- def setUp(self):
- self.test_subscriber = subscriber.Collector(self.TRAFFIC_PROFILE,
- self.VNFS)
+class MockVnfAprrox(object):
- def test_successful_init(self):
+ def __init__(self):
+ self.result = {}
+ self.name = "vnf__1"
- self.assertEqual(self.test_subscriber.traffic_profile, {})
- self.assertEqual(self.test_subscriber.service, {})
+ def collect_kpi(self):
+ self.result = {
+ 'pkt_in_up_stream': 100,
+ 'pkt_drop_up_stream': 5,
+ 'pkt_in_down_stream': 50,
+ 'pkt_drop_down_stream': 40
+ }
+ return self.result
- def test_unsuccessful_init(self):
- pass
- def test_start(self):
- self.assertIsNone(self.test_subscriber.start())
+class CollectorTestCase(unittest.TestCase):
- def test_stop(self):
- self.assertIsNone(self.test_subscriber.stop())
+ NODES = {
+ 'node1': {},
+ 'node2': {
+ 'collectd': {
+ 'plugins': {'abc': 12, 'def': 34},
+ 'interval': 987,
+ },
+ },
+ }
+ TRAFFIC_PROFILE = {
+ 'key1': 'value1',
+ }
- def test_get_kpi(self):
+ def setUp(self):
+ vnf = MockVnfAprrox()
+ self.ssh_patch = mock.patch('yardstick.network_services.nfvi.resource.ssh', autospec=True)
+ mock_ssh = self.ssh_patch.start()
+ mock_instance = mock.Mock()
+ mock_instance.execute.return_value = 0, '', ''
+ mock_ssh.AutoConnectSSH.from_node.return_value = mock_instance
+ self.collector = subscriber.Collector([vnf], self.NODES, self.TRAFFIC_PROFILE, 1800)
+
+ def tearDown(self):
+ self.ssh_patch.stop()
+
+ def test___init__(self, *_):
+ vnf = MockVnfAprrox()
+ collector = subscriber.Collector([vnf], {}, {})
+ self.assertEqual(len(collector.vnfs), 1)
+ self.assertEqual(collector.traffic_profile, {})
+
+ def test___init___with_data(self, *_):
+ self.assertEqual(len(self.collector.vnfs), 1)
+ self.assertDictEqual(self.collector.traffic_profile, self.TRAFFIC_PROFILE)
+ self.assertEqual(len(self.collector.resource_profiles), 1)
+
+ def test___init___negative(self, *_):
+ pass
- class VnfAprrox(object):
- def __init__(self):
- self.result = {}
- self.name = "vnf__1"
+ def test_start(self, *_):
+ self.assertIsNone(self.collector.start())
- def collect_kpi(self):
- self.result = {'pkt_in_up_stream': 100,
- 'pkt_drop_up_stream': 5,
- 'pkt_in_down_stream': 50,
- 'pkt_drop_down_stream': 40}
- return self.result
+ def test_stop(self, *_):
+ self.assertIsNone(self.collector.stop())
- vnf = VnfAprrox()
- result = self.test_subscriber.get_kpi(vnf)
+ def test_get_kpi(self, *_):
+ result = self.collector.get_kpi()
self.assertEqual(result["vnf__1"]["pkt_in_up_stream"], 100)
self.assertEqual(result["vnf__1"]["pkt_drop_up_stream"], 5)
self.assertEqual(result["vnf__1"]["pkt_in_down_stream"], 50)
self.assertEqual(result["vnf__1"]["pkt_drop_down_stream"], 40)
+ self.assertIn('node2', result)
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index eba38c688..4fc6d7773 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -105,7 +105,7 @@ class TestResourceProfile(unittest.TestCase):
def test_check_if_sa_running(self):
self.assertEqual(self.resource_profile.check_if_sa_running("collectd"),
- [True, {}])
+ (True, {}))
def test_get_cpu_data(self):
reskey = ["", "cpufreq", "cpufreq-0"]
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 6fffb9ede..616921e33 100644
--- a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
+++ b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py
@@ -179,12 +179,12 @@ class TestIXIARFC2544Profile(unittest.TestCase):
"dst_mac_0": "00:00:00:00:00:03",
"dst_mac_1": "00:00:00:00:00:04",
"dst_mac_2": "00:00:00:00:00:04"}
- self.assertRaises(IOError, r_f_c2544_profile._get_ixia_traffic_profile,
- self.PROFILE, mac, xfile="tmp",
- static_traffic=STATIC_TRAFFIC)
+ result = r_f_c2544_profile._get_ixia_traffic_profile(
+ self.PROFILE, mac, xfile="tmp",
+ static_traffic=STATIC_TRAFFIC)
+ self.assertIsNotNone(result)
- @mock.patch("yardstick.network_services.traffic_profile.ixia_rfc2544.open")
- def test_get_ixia_traffic_profile(self, mock_open):
+ def test_get_ixia_traffic_profile(self):
traffic_generator = mock.Mock(autospec=TrexProfile)
traffic_generator.my_ports = [0, 1]
traffic_generator.uplink_ports = [-1]
diff --git a/tests/unit/network_services/traffic_profile/test_prox_acl.py b/tests/unit/network_services/traffic_profile/test_prox_acl.py
index a0c60186c..ef5bac0d5 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_acl.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_acl.py
@@ -59,18 +59,9 @@ class TestProxACLProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_gen = mock.MagicMock()
- traffic_gen.run_test = target
-
- traffic_gen.resource_helper.run_test.side_effect = [
- success_tuple,
- success_tuple,
- success_tuple,
- fail_tuple,
- success_tuple,
- fail_tuple,
- fail_tuple,
- fail_tuple,
- ]
+
+ profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile = ProxACLProfile(tp_config)
profile.init(mock.MagicMock())
@@ -82,5 +73,6 @@ class TestProxACLProfile(unittest.TestCase):
profile.duration = 30
profile.test_value = 100.0
profile.tolerated_loss = 100.0
+ profile._profile_helper = profile_helper
profile.run_test_with_pkt_size(traffic_gen, profile.pkt_size, profile.duration)
diff --git a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
index f56a7fba9..c1f1c825b 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
@@ -51,10 +51,13 @@ class TestProxBinSearchProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
+
+ profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile = ProxBinSearchProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper
profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 74.69)
@@ -82,10 +85,13 @@ class TestProxBinSearchProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
+
+ profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile = ProxBinSearchProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper
profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 24.06)
diff --git a/tests/unit/network_services/traffic_profile/test_prox_mpls.py b/tests/unit/network_services/traffic_profile/test_prox_mpls.py
index 642fecc35..00a690d2a 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_mpls.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_mpls.py
@@ -51,10 +51,11 @@ class TestProxMplsTagUntagProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
profile = ProxMplsTagUntagProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 74.69)
@@ -82,10 +83,11 @@ class TestProxMplsTagUntagProfile(unittest.TestCase):
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
traffic_generator = mock.MagicMock()
- traffic_generator.run_test = target
profile = ProxMplsTagUntagProfile(tp_config)
profile.init(mock.MagicMock())
+ profile._profile_helper = profile_helper = mock.MagicMock()
+ profile_helper.run_test = target
profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 24.06)
diff --git a/tests/unit/network_services/traffic_profile/test_prox_profile.py b/tests/unit/network_services/traffic_profile/test_prox_profile.py
index 9899d9909..078e72b8e 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_profile.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_profile.py
@@ -26,6 +26,7 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.traffic_profile.prox_profile import ProxProfile
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxResourceHelper
class TestProxProfile(unittest.TestCase):
@@ -62,8 +63,9 @@ class TestProxProfile(unittest.TestCase):
}
profile = ProxProfile(tp_config)
- profile.init(234)
- self.assertEqual(profile.queue, 234)
+ queue = mock.Mock()
+ profile.init(queue)
+ self.assertIs(profile.queue, queue)
def test_execute_traffic(self):
packet_sizes = [
@@ -78,6 +80,13 @@ class TestProxProfile(unittest.TestCase):
}
traffic_generator = mock.MagicMock()
+
+ setup_helper = traffic_generator.setup_helper
+ setup_helper.find_in_section.return_value = None
+
+ prox_resource_helper = ProxResourceHelper(setup_helper)
+ traffic_generator.resource_helper = prox_resource_helper
+
profile = ProxProfile(tp_config)
self.assertFalse(profile.done)
@@ -86,6 +95,7 @@ class TestProxProfile(unittest.TestCase):
profile.execute_traffic(traffic_generator)
self.assertIsNone(profile.execute_traffic(traffic_generator))
+ self.assertTrue(profile.done)
def test_bounds_iterator(self):
tp_config = {
diff --git a/tests/unit/network_services/traffic_profile/test_prox_ramp.py b/tests/unit/network_services/traffic_profile/test_prox_ramp.py
index 357298759..1acec2f68 100644
--- a/tests/unit/network_services/traffic_profile/test_prox_ramp.py
+++ b/tests/unit/network_services/traffic_profile/test_prox_ramp.py
@@ -26,6 +26,7 @@ stl_patch.start()
if stl_patch:
from yardstick.network_services.traffic_profile.prox_ramp import ProxRampProfile
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxProfileHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxTestDataTuple
@@ -43,14 +44,18 @@ class TestProxRampProfile(unittest.TestCase):
success_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.1, 5.2, 5.3], 995, 1000, 123.4)
traffic_gen = mock.MagicMock()
- traffic_gen.resource_helper.run_test.return_value = success_tuple
+ traffic_gen._test_type = 'Generic'
+
+ profile_helper = ProxProfileHelper(traffic_gen.resource_helper)
+ profile_helper.run_test = run_test = mock.MagicMock(return_value=success_tuple)
profile = ProxRampProfile(tp_config)
profile.fill_samples = fill_samples = mock.MagicMock()
profile.queue = mock.MagicMock()
+ profile._profile_helper = profile_helper
profile.run_test_with_pkt_size(traffic_gen, 128, 30)
- self.assertEqual(traffic_gen.resource_helper.run_test.call_count, 10)
+ self.assertEqual(run_test.call_count, 10)
self.assertEqual(fill_samples.call_count, 10)
def test_run_test_with_pkt_size_with_fail(self):
@@ -65,8 +70,7 @@ class TestProxRampProfile(unittest.TestCase):
success_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.1, 5.2, 5.3], 995, 1000, 123.4)
fail_tuple = ProxTestDataTuple(10.0, 1, 2, 3, 4, [5.6, 5.7, 5.8], 850, 1000, 123.4)
- traffic_gen = mock.MagicMock()
- traffic_gen.resource_helper.run_test.side_effect = [
+ result_list = [
success_tuple,
success_tuple,
success_tuple,
@@ -77,10 +81,17 @@ class TestProxRampProfile(unittest.TestCase):
fail_tuple,
]
+ traffic_gen = mock.MagicMock()
+ traffic_gen._test_type = 'Generic'
+
+ profile_helper = ProxProfileHelper(traffic_gen.resource_helper)
+ profile_helper.run_test = run_test = mock.MagicMock(side_effect=result_list)
+
profile = ProxRampProfile(tp_config)
profile.fill_samples = fill_samples = mock.MagicMock()
profile.queue = mock.MagicMock()
+ profile._profile_helper = profile_helper
profile.run_test_with_pkt_size(traffic_gen, 128, 30)
- self.assertEqual(traffic_gen.resource_helper.run_test.call_count, 4)
+ self.assertEqual(run_test.call_count, 4)
self.assertEqual(fill_samples.call_count, 3)
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 995b4a2cc..e4319d602 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
@@ -40,7 +40,11 @@ if stl_patch:
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxTestDataTuple
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxDpdkVnfSetupEnvHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import TotStatsTuple
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxDataHelper
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxResourceHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxProfileHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxMplsProfileHelper
+ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxBngProfileHelper
class TestCoreTuple(unittest.TestCase):
@@ -741,6 +745,106 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
},
}
+ def test_global_section(self):
+ setup_helper = ProxDpdkVnfSetupEnvHelper(mock.MagicMock(), mock.MagicMock(),
+ mock.MagicMock())
+
+ setup_helper._prox_config_data = [('a', [])]
+
+ with self.assertRaises(KeyError):
+ _ = setup_helper.global_section
+
+ global_section = (
+ 'global', [
+ ('not_name', 'other data'),
+ ('name_not', 'more data'),
+ ('name', 'prox type'),
+ ],
+ )
+
+ setup_helper._prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ global_section,
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'tagged'),
+ ]),
+ ('section3', [
+ ('key1', 'value1'),
+ ('key2', 'value2'),
+ ('key3', 'value3'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'udp'),
+ ]),
+ ]
+
+ result = setup_helper.global_section
+ self.assertEqual(result, global_section[1])
+
+ def test_find_in_section(self):
+ setup_helper = ProxDpdkVnfSetupEnvHelper(mock.MagicMock(), mock.MagicMock(),
+ mock.MagicMock())
+
+ setup_helper._prox_config_data = [
+ ('global', [
+ ('not_name', 'other data'),
+ ('name_not', 'more data'),
+ ('name', 'prox type'),
+ ]),
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'tagged'),
+ ]),
+ ('section3', [
+ ('key1', 'value1'),
+ ('key2', 'value2'),
+ ('key3', 'value3'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'udp'),
+ ]),
+ ]
+
+ expected = 'value3'
+ result = setup_helper.find_in_section('section3', 'key3')
+ self.assertEqual(result, expected)
+
+ expected = 'default value'
+ result = setup_helper.find_in_section('section3', 'key4', 'default value')
+ self.assertEqual(result, expected)
+
+ with self.assertRaises(KeyError):
+ setup_helper.find_in_section('section4', 'key1')
+
+ with self.assertRaises(KeyError):
+ setup_helper.find_in_section('section1', 'key1')
+
def test__replace_quoted_with_value(self):
# empty string
input_str = ''
@@ -858,6 +962,16 @@ class TestProxDpdkVnfSetupEnvHelper(unittest.TestCase):
result = ProxDpdkVnfSetupEnvHelper.write_prox_config(input_data)
self.assertEqual(result, expected)
+ def test_prox_config_data(self):
+ setup_helper = ProxDpdkVnfSetupEnvHelper(mock.MagicMock(), mock.MagicMock(),
+ mock.MagicMock())
+
+ setup_helper.config_queue = config_queue = mock.MagicMock()
+ config_queue.get.return_value = expected = [('s', [('a', 3), ('b', 45)])]
+
+ result = setup_helper.prox_config_data
+ self.assertEqual(result, expected)
+
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.find_relative_file')
def test_build_config_file_no_additional_file(self, mock_find_path):
vnf1 = {
@@ -1344,11 +1458,6 @@ class TestProxResourceHelper(unittest.TestCase):
},
}
- def test_line_rate_to_pps(self):
- expected = 0.25 * 1e8
- result = ProxResourceHelper.line_rate_to_pps(180, 4)
- self.assertEqual(result, expected)
-
def test_find_pci(self):
input_str_list = [
'no target here',
@@ -1377,14 +1486,255 @@ class TestProxResourceHelper(unittest.TestCase):
self.assertIs(result, helper.client)
self.assertIs(result, helper.sut)
+ def test_test_type(self):
+ setup_helper = mock.MagicMock()
+ setup_helper.find_in_section.return_value = expected = 'prox type'
+
+ helper = ProxResourceHelper(setup_helper)
+
+ self.assertIsNone(helper._test_type)
+ self.assertEqual(helper.test_type, expected)
+ self.assertEqual(helper._test_type, expected)
+ self.assertEqual(helper.test_type, expected)
+
+ def test_collect_collectd_kpi(self):
+ helper = ProxResourceHelper(mock.MagicMock())
+ helper.resource = resource = mock.MagicMock()
+
+ resource.amqp_collect_nfvi_kpi.return_value = 543
+
+ expected = {'core': 543}
+ result = helper.collect_collectd_kpi()
+ self.assertDictEqual(result, expected)
+
+ def test_collect_kpi(self):
+ helper = ProxResourceHelper(mock.MagicMock())
+ helper._queue = queue = mock.MagicMock()
+ helper._result = {'z': 123}
+ helper.resource = resource = mock.MagicMock()
+
+ resource.amqp_collect_nfvi_kpi.return_value = 543
+
+ queue.empty.return_value = False
+ queue.get.return_value = {'a': 789}
+
+ expected = {'z': 123, 'a': 789, 'collect_stats': {'core': 543}}
+ result = helper.collect_kpi()
+ self.assertDictEqual(result, expected)
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.ProxSocketHelper')
+ def test__connect(self, mock_socket_helper_type, mock_time):
+ client = mock_socket_helper_type()
+ client.connect.side_effect = chain(repeat(socket.error, 5), [None])
+
+ setup_helper = mock.MagicMock()
+ setup_helper.vnfd_helper.interfaces = []
+
+ helper = ProxResourceHelper(setup_helper)
+
+ result = helper._connect()
+ self.assertIs(result, client)
+
+ client.connect.side_effect = chain(repeat(socket.error, 65), [None])
+
+ with self.assertRaises(Exception):
+ helper._connect()
+
+ def test_run_traffic(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ traffic_profile = mock.MagicMock(**{"done": True})
+ helper.run_traffic(traffic_profile)
+ self.assertEqual(helper._terminated.value, 1)
+
+ def test__run_traffic_once(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ traffic_profile = mock.MagicMock(**{"done": True})
+ helper._run_traffic_once(traffic_profile)
+ self.assertEqual(helper._terminated.value, 1)
+
+ def test_start_collect(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ helper.resource = resource = mock.MagicMock()
+ self.assertIsNone(helper.start_collect())
+ resource.start.assert_called_once()
+
+ def test_terminate(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ with self.assertRaises(NotImplementedError):
+ helper.terminate()
+
+ def test_up_post(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ helper.client = expected = mock.MagicMock()
+ result = helper.up_post()
+ self.assertEqual(result, expected)
+
+ def test_execute(self):
+ setup_helper = mock.MagicMock()
+ helper = ProxResourceHelper(setup_helper)
+ helper.client = mock.MagicMock()
+
+ expected = helper.client.my_command()
+ result = helper.execute('my_command')
+ self.assertEqual(result, expected)
+
+ helper.client = object()
+
+ result = helper.execute('my_command')
+ self.assertIsNone(result)
+
+
+class TestProxDataHelper(unittest.TestCase):
+
+ def test_totals_and_pps(self):
+ pkt_size = 180
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+
+ sut = mock.MagicMock()
+ sut.port_stats.return_value = list(range(10))
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, pkt_size, 25, None)
+
+ self.assertEqual(data_helper.rx_total, 6)
+ self.assertEqual(data_helper.tx_total, 7)
+ self.assertEqual(data_helper.pps, 6.25e6)
+
+ def test_samples(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+ vnfd_helper.ports_iter.return_value = [('xe1', 3), ('xe2', 7)]
+
+ sut = mock.MagicMock()
+ sut.port_stats.return_value = list(range(10))
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None)
+
+ expected = {
+ 'xe1': {
+ 'in_packets': 6,
+ 'out_packets': 7,
+ },
+ 'xe2': {
+ 'in_packets': 6,
+ 'out_packets': 7,
+ },
+ }
+ result = data_helper.samples
+ self.assertDictEqual(result, expected)
+
+ def test___enter__(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+ vnfd_helper.ports_iter.return_value = [('xe1', 3), ('xe2', 7)]
+
+ sut = mock.MagicMock()
+ sut.port_stats.return_value = list(range(10))
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4)
+ data_helper._totals_and_pps = 12, 32, 4.5
+ data_helper.tsc_hz = 9.8
+ data_helper.measured_stats = {'delta': TotStatsTuple(6.1, 6.2, 6.3, 6.4)}
+ data_helper.latency = 7
+
+ self.assertIsNone(data_helper.result_tuple)
+
+ expected = ProxTestDataTuple(5.4, 9.8, 6.1, 6.2, 6.3, 7, 12, 32, 4.5)
+ with data_helper:
+ pass
+
+ result = data_helper.result_tuple
+ self.assertEqual(result, expected)
+
+ data_helper.make_tuple()
+ self.assertIs(data_helper.result_tuple, result)
+
+ def test___enter___negative(self):
+ vnfd_helper = mock.MagicMock()
+
+ data_helper = ProxDataHelper(vnfd_helper, None, None, None, None)
+
+ vnfd_helper.port_pairs.all_ports = []
+ with self.assertRaises(AssertionError):
+ with data_helper:
+ pass
+
+ vnfd_helper.port_pairs.all_ports = [0, 1, 2]
+ with self.assertRaises(AssertionError):
+ with data_helper:
+ pass
+
+ def test_measure_tot_stats(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+
+ start = (3, 4, 1, 2)
+ end = (9, 7, 6, 8)
+
+ sut = ProxSocketHelper(mock.MagicMock())
+ sut.get_all_tot_stats = mock.MagicMock(side_effect=[start, end])
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, 5.4)
+
+ self.assertIsNone(data_helper.measured_stats)
+
+ expected = {
+ 'start_tot': start,
+ 'end_tot': end,
+ 'delta': TotStatsTuple(6, 3, 5, 6),
+ }
+ with data_helper.measure_tot_stats():
+ pass
+
+ self.assertEqual(data_helper.measured_stats, expected)
+
+ def test_capture_tsc_hz(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+
+ sut = mock.MagicMock()
+ sut.hz.return_value = '54.6'
+
+ data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None)
+
+ self.assertIsNone(data_helper.tsc_hz)
+
+ expected = 54.6
+ data_helper.capture_tsc_hz()
+ self.assertEqual(data_helper.tsc_hz, expected)
+
+
+class TestProxProfileHelper(unittest.TestCase):
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.utils')
+ def test_get_cls(self, mock_utils):
+ mock_type1 = mock.MagicMock()
+ mock_type1.__prox_profile_type__ = 'another_type'
+ mock_type2 = mock.MagicMock()
+ mock_type2.__prox_profile_type__ = 'my_type'
+ mock_utils.itersubclasses.return_value = [mock_type1, mock_type2]
+
+ self.assertEqual(ProxProfileHelper.get_cls('my_type'), mock_type2)
+
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.utils')
+ def test_get_cls_default(self, mock_utils):
+ mock_utils.itersubclasses.return_value = []
+ ProxProfileHelper.get_cls('my_type')
+
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.SocketTopology')
def test_cpu_topology(self, mock_socket_topology):
mock_socket_topology.parse_cpuinfo.return_value = 432
- setup_helper = mock.MagicMock()
- setup_helper.ssh_helper.execute.return_value = 0, 'output', ''
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.ssh_helper.execute.return_value = 0, 'output', ''
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
self.assertIsNone(helper._cpu_topology)
result = helper.cpu_topology
self.assertEqual(result, 432)
@@ -1392,17 +1742,17 @@ class TestProxResourceHelper(unittest.TestCase):
self.assertIs(result, helper.cpu_topology)
def test_test_cores(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_data = []
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = []
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = []
expected = []
result = helper.test_cores
self.assertEqual(result, expected)
- setup_helper.prox_config_data = [
+ resource_helper.setup_helper.prox_config_data = [
('section1', []),
('section2', [
('a', 'b'),
@@ -1423,7 +1773,7 @@ class TestProxResourceHelper(unittest.TestCase):
]),
]
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = {
1: {
3: {
@@ -1448,83 +1798,74 @@ class TestProxResourceHelper(unittest.TestCase):
self.assertIs(result, helper._test_cores)
self.assertIs(result, helper.test_cores)
- def test_get_test_type(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
+ def test_latency_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data= []
- setup_helper.prox_config_data = [
- ('global', [
- ('name', helper.PROX_CORE_MPLS_TEST)
- ]),
- ('section2', [
- ('a', 'b'),
- ('c', 'd'),
- ]),
- ('core 1', []),
- ('core 2', [
- ('index', 8),
- ('mode', ''),
- ]),
- ('core 3', [
- ('index', 5),
- ('mode', 'gen'),
- ]),
- ('core 4', [
- ('index', 7),
- ('mode', 'gen'),
- ]),
- ]
- test_type = helper.get_test_type()
- self.assertEqual(test_type, helper.PROX_CORE_MPLS_TEST)
+ helper = ProxProfileHelper(resource_helper)
+ helper._cpu_topology = []
- def test_get_cores(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_data = [
+ expected = []
+ result = helper.latency_cores
+ self.assertEqual(result, expected)
+
+ resource_helper.setup_helper.prox_config_data = [
('section1', []),
('section2', [
('a', 'b'),
('c', 'd'),
]),
- ('core 1', []),
- ('core 2', [
+ ('core 1s3', []),
+ ('core 2s5', [
('index', 8),
('mode', ''),
]),
- ('core 3', [
+ ('core 3s1', [
('index', 5),
- ('mode', 'gen'),
+ ('mode', 'lat'),
]),
- ('core 4', [
+ ('core 4s9h', [
('index', 7),
- ('mode', 'gen'),
+ ('mode', 'lat'),
]),
]
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = {
- 0: {
- 1: {
- 5: (5, 1, 0)
- },
- 2: {
- 6: (6, 2, 0)
- },
+ 1: {
3: {
- 7: (7, 3, 0)
+ 'key1': (23, 32),
+ 'key2': (12, 21),
+ 'key3': (44, 33),
},
+ },
+ 9: {
4: {
- 8: (8, 3, 0)
+ 'key1': (44, 32),
+ 'key2': (23, 21),
+ 'key3': (12, 33),
},
- }
+ },
}
- expected = [7, 8]
- result = helper.get_cores(helper.PROX_CORE_GEN_MODE)
+ self.assertIsNone(helper._latency_cores)
+ expected = [12, 23]
+ result = helper.latency_cores
self.assertEqual(result, expected)
+ self.assertIs(result, helper._latency_cores)
+ self.assertIs(result, helper.latency_cores)
- def test_get_cores_mpls(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_data = [
+ def test_all_rx_cores(self):
+ helper = ProxBngProfileHelper(mock.MagicMock())
+ helper._latency_cores = expected = [3, 4, 6]
+ helper._test_cores = [5, 2, 1]
+
+ result = helper.all_rx_cores
+ self.assertEqual(result, expected)
+
+ def test_get_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
('section1', []),
('section2', [
('a', 'b'),
@@ -1538,16 +1879,14 @@ class TestProxResourceHelper(unittest.TestCase):
('core 3', [
('index', 5),
('mode', 'gen'),
- ('name', 'tagged'),
]),
('core 4', [
('index', 7),
('mode', 'gen'),
- ('name', 'udp'),
]),
]
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(resource_helper)
helper._cpu_topology = {
0: {
1: {
@@ -1565,123 +1904,34 @@ class TestProxResourceHelper(unittest.TestCase):
}
}
- expected_tagged = [7]
- expected_plain = [8]
- result_tagged, result_plain = helper.get_cores_mpls(helper.PROX_CORE_GEN_MODE)
- self.assertEqual(result_tagged, expected_tagged)
- self.assertEqual(result_plain, expected_plain)
-
- def test_latency_cores(self):
- setup_helper = mock.MagicMock()
- setup_helper.prox_config_data= []
-
- helper = ProxResourceHelper(setup_helper)
- helper._cpu_topology = []
-
- expected = []
- result = helper.latency_cores
- self.assertEqual(result, expected)
-
- setup_helper.prox_config_data = [
- ('section1', []),
- ('section2', [
- ('a', 'b'),
- ('c', 'd'),
- ]),
- ('core 1s3', []),
- ('core 2s5', [
- ('index', 8),
- ('mode', ''),
- ]),
- ('core 3s1', [
- ('index', 5),
- ('mode', 'lat'),
- ]),
- ('core 4s9h', [
- ('index', 7),
- ('mode', 'lat'),
- ]),
- ]
-
- helper = ProxResourceHelper(setup_helper)
- helper._cpu_topology = {
- 1: {
- 3: {
- 'key1': (23, 32),
- 'key2': (12, 21),
- 'key3': (44, 33),
- },
- },
- 9: {
- 4: {
- 'key1': (44, 32),
- 'key2': (23, 21),
- 'key3': (12, 33),
- },
- },
- }
-
- self.assertIsNone(helper._latency_cores)
- expected = [12, 23]
- result = helper.latency_cores
+ expected = [7, 8]
+ result = helper.get_cores(helper.PROX_CORE_GEN_MODE)
self.assertEqual(result, expected)
- self.assertIs(result, helper._latency_cores)
- self.assertIs(result, helper.latency_cores)
-
- def test_run_traffic(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- traffic_proifle = mock.MagicMock(**{"done": True})
- helper.run_traffic(traffic_proifle)
- self.assertEqual(helper._terminated.value, 1)
- def test__run_traffic_once(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- traffic_proifle = mock.MagicMock(**{"done": True})
- helper._run_traffic_once(traffic_proifle)
- self.assertEqual(helper._terminated.value, 1)
-
- def test_start_collect(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- helper.resource = resource = mock.MagicMock()
- self.assertIsNone(helper.start_collect())
- resource.start.assert_called_once()
+ def test_get_latency(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.vnfd_helper.interfaces = []
- def test_terminate(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- with self.assertRaises(NotImplementedError):
- helper.terminate()
+ helper = ProxProfileHelper(resource_helper)
+ helper._latency_cores = []
- def test_up_post(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
- helper.client = expected = mock.MagicMock()
- result = helper.up_post()
+ expected = []
+ result = helper.get_latency()
self.assertEqual(result, expected)
- def test_execute(self):
- setup_helper = mock.MagicMock()
- helper = ProxResourceHelper(setup_helper)
+ helper._latency_cores = [1, 2]
helper.client = mock.MagicMock()
- expected = helper.client.my_command()
- result = helper.execute('my_command')
- self.assertEqual(result, expected)
-
- helper.client = object()
-
- result = helper.execute('my_command')
- self.assertIsNone(result)
+ expected = helper.sut.lat_stats()
+ result = helper.get_latency()
+ self.assertIs(result, expected)
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
def test_traffic_context(self, mock_time):
setup_helper = mock.MagicMock()
setup_helper.vnfd_helper.interfaces = []
- helper = ProxResourceHelper(setup_helper)
+ helper = ProxProfileHelper(setup_helper)
helper._cpu_topology = {
0: {
1: {
@@ -1701,7 +1951,9 @@ class TestProxResourceHelper(unittest.TestCase):
setup_helper.prox_config_data = [
('global', [
- ('name', helper.PROX_CORE_MPLS_TEST)
+ ('not_name', 'other data'),
+ ('name_not', 'more data'),
+ ('name', helper.__prox_profile_type__),
]),
('section1', []),
('section2', [
@@ -1739,101 +1991,159 @@ class TestProxResourceHelper(unittest.TestCase):
pass
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_run_test(self, mock_time):
- @contextmanager
- def measure(*args, **kwargs):
- yield stats
-
- bad_vnfd = copy.deepcopy(self.VNFD0)
- bad_vnfd['vdu'][0]['external-interface'].append({
- 'virtual-interface': {
- 'dst_mac': '00:00:00:00:00:05',
- 'vpci': '0000:06:00.0',
- 'local_ip': '152.16.100.20',
- 'type': 'PCI-PASSTHROUGH',
- 'vld_id': 'uplink_1',
- 'netmask': '255.255.255.0',
- 'dpdk_port_num': 0,
- 'bandwidth': '10 Gbps',
- 'driver': "i40e",
- 'dst_ip': '152.16.100.20',
- 'local_iface_name': 'xe2',
- 'local_mac': '00:00:00:00:00:07',
- 'ifname': 'xe2',
- },
- 'vnfd-connection-point-ref': 'xe2',
- 'name': 'xe2',
- })
+ def test_run_test(self, _):
+ resource_helper = mock.MagicMock()
+ resource_helper.step_delta = 0.4
+ resource_helper.vnfd_helper.port_pairs.all_ports = list(range(2))
+ resource_helper.sut.port_stats.return_value = list(range(10))
- bad_vnfd_helper = VnfdHelper(bad_vnfd)
- setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper = bad_vnfd_helper
+ helper = ProxProfileHelper(resource_helper)
- stats = {
- 'delta': TotStatsTuple(6, 7, 8, 9),
- }
+ helper.run_test(120, 5, 6.5)
- client = mock.MagicMock()
- client.hz.return_value = 2
- client.measure_tot_stats = measure
- client.port_stats.return_value = tuple(range(12))
- helper = ProxResourceHelper(setup_helper)
- helper.client = client
- helper.get_latency = mock.MagicMock(return_value=[3.3, 3.6, 3.8])
+class TestProxMplsProfileHelper(unittest.TestCase):
- with self.assertRaises(AssertionError):
- helper.run_test(980, 15, 45)
-
- vnfd_helper = VnfdHelper(self.VNFD0)
- setup_helper.vnfd_helper = vnfd_helper
- helper = ProxResourceHelper(setup_helper)
- helper.client = client
- helper.get_latency = mock.MagicMock(return_value=[3.3, 3.6, 3.8])
- helper._test_cores = [3, 4]
+ def test_mpls_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'tagged'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'udp'),
+ ]),
+ ]
- expected_test_data = ProxTestDataTuple(0.0, 2.0, 6, 7, 8, [3.3, 3.6, 3.8], 6, 7, 6.5e6)
- expected_port_samples = {
- 'xe0': {'in_packets': 6, 'out_packets': 7},
- 'xe1': {'in_packets': 6, 'out_packets': 7},
+ helper = ProxMplsProfileHelper(resource_helper)
+ helper._cpu_topology = {
+ 0: {
+ 1: {
+ 5: (5, 1, 0)
+ },
+ 2: {
+ 6: (6, 2, 0)
+ },
+ 3: {
+ 7: (7, 3, 0)
+ },
+ 4: {
+ 8: (8, 3, 0)
+ },
+ }
}
- test_data, port_samples = helper.run_test(230, 60, 65)
- self.assertTupleEqual(test_data, expected_test_data)
- self.assertDictEqual(port_samples, expected_port_samples)
- def test_get_latency(self):
+ expected_tagged = [7]
+ expected_plain = [8]
+ self.assertIsNone(helper._cores_tuple)
+ self.assertEqual(helper.tagged_cores, expected_tagged)
+ self.assertEqual(helper.plain_cores, expected_plain)
+ self.assertEqual(helper._cores_tuple, (expected_tagged, expected_plain))
+
+ def test_traffic_context(self):
setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper.interfaces = []
+ helper = ProxMplsProfileHelper(setup_helper)
- helper = ProxResourceHelper(setup_helper)
- helper._latency_cores = []
+ with helper.traffic_context(120, 5.4):
+ pass
- expected = []
- result = helper.get_latency()
- self.assertEqual(result, expected)
- helper._latency_cores = [1, 2]
- helper.client = mock.MagicMock()
+class TestProxBngProfileHelper(unittest.TestCase):
- expected = helper.sut.lat_stats()
- result = helper.get_latency()
- self.assertIs(result, expected)
+ def test_bng_cores(self):
+ resource_helper = mock.MagicMock()
+ resource_helper.setup_helper.prox_config_data = [
+ ('section1', []),
+ ('section2', [
+ ('a', 'b'),
+ ('c', 'd'),
+ ]),
+ ('core 1', []),
+ ('core 2', [
+ ('index', 8),
+ ('mode', ''),
+ ]),
+ ('core 3', [
+ ('index', 5),
+ ('mode', 'gen'),
+ ('name', 'cpe'),
+ ]),
+ ('core 4', [
+ ('index', 7),
+ ('mode', 'gen'),
+ ('name', 'inet'),
+ ]),
+ ('core 6', [
+ ('index', 3),
+ ('mode', 'gen'),
+ ('name', 'arp_task'),
+ ]),
+ ('core 9', [
+ ('index', 2),
+ ('mode', 'gen'),
+ ('name', 'arp'),
+ ]),
+ ]
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.ProxSocketHelper')
- def test__connect(self, mock_socket_helper_type, mock_time):
- client = mock_socket_helper_type()
- client.connect.side_effect = chain(repeat(socket.error, 5), [None])
+ helper = ProxBngProfileHelper(resource_helper)
+ helper._cpu_topology = {
+ 0: {
+ 1: {
+ 5: (5, 1, 0)
+ },
+ 2: {
+ 6: (6, 2, 0)
+ },
+ 3: {
+ 7: (7, 3, 0)
+ },
+ 4: {
+ 8: (8, 3, 0)
+ },
+ 6: {
+ 1: (4, 8, 0)
+ },
+ 9: {
+ 2: (3, 7, 0)
+ },
+ }
+ }
- setup_helper = mock.MagicMock()
- setup_helper.vnfd_helper.interfaces = []
+ expected_cpe = [7]
+ expected_inet = [8]
+ expected_arp = [4, 3]
+ expected_arp_task = [0, 4]
+ expected_combined = (expected_cpe, expected_inet, expected_arp, expected_arp_task)
- helper = ProxResourceHelper(setup_helper)
+ self.assertIsNone(helper._cores_tuple)
+ self.assertEqual(helper.cpe_cores, expected_cpe)
+ self.assertEqual(helper.inet_cores, expected_inet)
+ self.assertEqual(helper.arp_cores, expected_arp)
+ self.assertEqual(helper.arp_task_cores, expected_arp_task)
+ self.assertEqual(helper._cores_tuple, expected_combined)
- result = helper._connect()
- self.assertIs(result, client)
+ @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
+ def test_run_test(self, _):
+ resource_helper = mock.MagicMock()
+ resource_helper.step_delta = 0.4
+ resource_helper.vnfd_helper.port_pairs.all_ports = list(range(2))
+ resource_helper.sut.port_stats.return_value = list(range(10))
- client.connect.side_effect = chain(repeat(socket.error, 65), [None])
+ helper = ProxBngProfileHelper(resource_helper)
- with self.assertRaises(Exception):
- helper._connect()
+ helper.run_test(120, 5, 6.5)
+ helper.run_test(-1000, 5, 6.5) # negative pkt_size is the only way to make ratio > 1
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
index d0c4b6f42..77c92e0fb 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
@@ -1136,11 +1136,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- '0000:05:00.2',
- ]
client_resource_helper.client.get_stats.return_value = {
0: {
'rx_pps': 5.5,
@@ -1186,10 +1181,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- ]
client_resource_helper.client.get_stats.return_value = {
'key_name': 'key_value',
0: {
@@ -1238,10 +1229,6 @@ class TestClientResourceHelper(unittest.TestCase):
dpdk_setup_helper = DpdkVnfSetupEnvHelper(vnfd_helper, ssh_helper, scenario_helper)
client_resource_helper = ClientResourceHelper(dpdk_setup_helper)
client_resource_helper.client = mock.MagicMock()
- client_resource_helper._vpci_ascending = [
- '0000:05:00.0',
- '0000:05:00.1',
- ]
client_resource_helper.client.get_stats.return_value = {
0: {
'rx_pps': 5.5,
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
index eb569cfe6..bdda149c5 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
@@ -395,7 +395,6 @@ class TestProxTrafficGen(unittest.TestCase):
sut.ssh_helper = mock.Mock()
sut.ssh_helper.run = mock.Mock()
sut.setup_helper.prox_config_dict = {}
- sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"]
sut._connect_client = mock.Mock(autospec=STLClient)
sut._connect_client.get_stats = mock.Mock(return_value="0")
sut._traffic_runner(mock_traffic_profile)
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
index eb9f0525b..d08c62e0b 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
@@ -356,6 +356,17 @@ class TestTrexTrafficGen(unittest.TestCase):
trex_traffic_gen = TrexTrafficGen(NAME, vnfd)
trex_traffic_gen.ssh_helper = mock.MagicMock()
trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
+ trex_traffic_gen.scenario_helper.scenario_cfg = {}
+ self.assertIsNone(trex_traffic_gen._start_server())
+
+ @mock.patch(SSH_HELPER)
+ def test__start_server_multiple_queues(self, ssh):
+ mock_ssh(ssh)
+ vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+ trex_traffic_gen = TrexTrafficGen(NAME, vnfd)
+ trex_traffic_gen.ssh_helper = mock.MagicMock()
+ trex_traffic_gen.resource_helper.ssh_helper = mock.MagicMock()
+ trex_traffic_gen.scenario_helper.scenario_cfg = {"options": {NAME: {"queues_per_port": 2}}}
self.assertIsNone(trex_traffic_gen._start_server())
@mock.patch(SSH_HELPER)
@@ -371,7 +382,6 @@ class TestTrexTrafficGen(unittest.TestCase):
self.sut = TrexTrafficGen(NAME, vnfd)
self.sut.ssh_helper = mock.Mock()
self.sut.ssh_helper.run = mock.Mock()
- self.sut._vpci_ascending = ["0000:05:00.0", "0000:05:00.1"]
self.sut._connect_client = mock.Mock(autospec=STLClient)
self.sut._connect_client.get_stats = mock.Mock(return_value="0")
self.sut.resource_helper.RUN_DURATION = 0