summaryrefslogtreecommitdiffstats
path: root/tests/unit/network_services
diff options
context:
space:
mode:
authorAbhijit Sinha <abhijit.sinha@intel.com>2017-09-12 19:08:41 +0100
committerRoss Brattain <ross.b.brattain@intel.com>2017-09-30 01:23:07 -0700
commit3cb73072d2da631f671ec54f3de518bb781a9623 (patch)
treea39d0a6e6f311691c6dbfd53481e81229cb724ea /tests/unit/network_services
parent25eccae14eadc2cfe6ae6a3aff6087e0c324145d (diff)
Addition of Prox NSB BNG and BNG-QoS test
JIRA: YARDSTICK-802 Added Prox BNG and BNG-QoS Test - The tests supports BM, Openstack Heat - Supports 4 ports - Test added for BNG traffic profile - Fixed the Prox heat test cases with proper upstream and downstream links - Grafana Dashboard for BNG & BNG-QoS added - Increased the test Duration to 300 TODO: - Test does not Terminate correctly Update: Added new helper class for run_test: Genric, MPLS and BNG tests. Change-Id: Ib40811bedb45a3c3030643943f32679a4044e076 Signed-off-by: Abhijit Sinha <abhijit.sinha@intel.com> Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: Daniel Martin Buckley <daniel.m.buckley@intel.com>
Diffstat (limited to 'tests/unit/network_services')
-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.py9
-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
6 files changed, 602 insertions, 272 deletions
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..c32cc2878 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):
@@ -78,6 +79,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 +94,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