summaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/tests/unit')
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_model.py2
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py2
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py18
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py28
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py274
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py57
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py5
7 files changed, 319 insertions, 67 deletions
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_model.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_model.py
index 98d2b1836..d87ebe01a 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_model.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_model.py
@@ -123,7 +123,7 @@ class ModelLibvirtTestCase(unittest.TestCase):
def test_add_ovs_interfaces(self):
xml_input = copy.deepcopy(XML_SAMPLE)
xml_output = model.Libvirt.add_ovs_interface(
- '/usr/local', 0, self.pci_address_str, self.mac, xml_input)
+ '/usr/local', 0, self.pci_address_str, self.mac, xml_input, 4)
root = ElementTree.fromstring(xml_output)
et_out = ElementTree.ElementTree(element=root)
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
index 6cc8b11f3..a03d9082b 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
@@ -389,7 +389,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk._enable_interfaces(0, ["private_0"], 'test')
mock_add_ovs_interface.assert_called_once_with(
'fake_path', 0, self.NETWORKS['private_0']['vpci'],
- self.NETWORKS['private_0']['mac'], 'test')
+ self.NETWORKS['private_0']['mac'], 'test', 1)
@mock.patch.object(model.StandaloneContextHelper, 'check_update_key')
@mock.patch.object(model.Libvirt, 'write_file')
diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
index 6bf2f2c2f..90248d1bf 100644
--- a/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vnf_generic.py
@@ -629,7 +629,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
@mock.patch.object(vnfdgen, 'generate_vnfd')
def test__fill_traffic_profile(self, mock_generate, mock_tprofile_get):
fake_tprofile = mock.Mock()
- fake_vnfd = mock.Mock()
+ fake_vnfd = mock.MagicMock()
with mock.patch.object(self.s, '_get_traffic_profile',
return_value=fake_tprofile) as mock_get_tp:
mock_generate.return_value = fake_vnfd
@@ -646,6 +646,22 @@ class TestNetworkServiceTestCase(unittest.TestCase):
)
mock_tprofile_get.assert_called_once_with(fake_vnfd)
+ @mock.patch.object(base.TrafficProfile, 'get')
+ @mock.patch.object(vnfdgen, 'generate_vnfd')
+ def test__fill_traffic_profile2(self, mock_generate, mock_tprofile_get):
+ fake_tprofile = mock.Mock()
+ fake_vnfd = {}
+ with mock.patch.object(self.s, '_get_traffic_profile',
+ return_value=fake_tprofile) as mock_get_tp:
+ mock_generate.return_value = fake_vnfd
+
+ self.s.scenario_cfg["options"] = {"traffic_config": {"duration": 99899}}
+ self.s._fill_traffic_profile()
+ mock_get_tp.assert_called_once()
+ self.assertIn("traffic_profile", fake_vnfd)
+ self.assertIn("duration", fake_vnfd["traffic_profile"])
+ self.assertEqual(99899, fake_vnfd["traffic_profile"]["duration"])
+
@mock.patch.object(utils, 'open_relative_file')
def test__get_topology(self, mock_open_path):
self.s.scenario_cfg['topology'] = 'fake_topology'
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py b/yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
index c09903377..4524eb7e6 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
@@ -38,6 +38,12 @@ class TestProxBinSearchProfile(unittest.TestCase):
return fail_tuple, {}
return success_tuple, {}
+ def side_effect_func(arg1, arg2):
+ if arg1 == "confirmation":
+ return arg2
+ else:
+ return {}
+
tp_config = {
'traffic_profile': {
'packet_sizes': [200],
@@ -51,11 +57,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()
- attrs1 = {'get.return_value' : 10}
+ attrs1 = {'get.return_value': 10}
traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
- attrs2 = {'__getitem__.return_value' : 10, 'get.return_value': 10}
+ attrs2 = {'__getitem__.return_value': 10, 'get.return_value': 10}
+ attrs3 = {'get.side_effect': side_effect_func}
traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
+ traffic_generator.scenario_helper.scenario_cfg["options"].configure_mock(**attrs3)
profile_helper = mock.MagicMock()
profile_helper.run_test = target
@@ -68,7 +76,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
self.assertEqual(round(profile.current_lower, 2), 74.69)
self.assertEqual(round(profile.current_upper, 2), 76.09)
- self.assertEqual(len(runs), 77)
+ self.assertEqual(len(runs), 7)
# Result Samples inc theor_max
result_tuple = {'Actual_throughput': 5e-07,
@@ -121,6 +129,12 @@ class TestProxBinSearchProfile(unittest.TestCase):
return fail_tuple, {}
return success_tuple, {}
+ def side_effect_func(arg1, _):
+ if arg1 == "confirmation":
+ return 2
+ else:
+ return {}
+
tp_config = {
'traffic_profile': {
'packet_sizes': [200],
@@ -138,7 +152,10 @@ class TestProxBinSearchProfile(unittest.TestCase):
traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
attrs2 = {'__getitem__.return_value': 0, 'get.return_value': 0}
+ attrs3 = {'get.side_effect': side_effect_func}
+
traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
+ traffic_generator.scenario_helper.scenario_cfg["options"].configure_mock(**attrs3)
profile_helper = mock.MagicMock()
profile_helper.run_test = target
@@ -150,7 +167,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
profile.execute_traffic(traffic_generator)
self.assertEqual(round(profile.current_lower, 2), 24.06)
self.assertEqual(round(profile.current_upper, 2), 25.47)
- self.assertEqual(len(runs), 7)
+ self.assertEqual(len(runs), 21)
def test_execute_3(self):
def target(*args, **_):
@@ -186,8 +203,6 @@ class TestProxBinSearchProfile(unittest.TestCase):
profile.lower_bound = 99.0
profile.execute_traffic(traffic_generator)
-
- # Result Samples
result_tuple = {'Actual_throughput': 0, 'theor_max_throughput': 0,
"Status": 'Result', "Next_Step": ''}
profile.queue.put.assert_called_with(result_tuple)
@@ -226,6 +241,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
attrs2 = {'__getitem__.return_value': 0, 'get.return_value': 0}
+
traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
profile_helper = mock.MagicMock()
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
index 3d6ebb25b..894b16e13 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016-2017 Intel Corporation
+# Copyright (c) 2016-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -320,7 +320,8 @@ class TestProxSocketHelper(unittest.TestCase):
self.assertEqual(len(prox._pkt_dumps), 0)
mock_select.select.reset_mock()
- mock_select.select.side_effect = chain([['a'], ['']], repeat([1], 3))
+ mock_select.select.side_effect = chain([['a'], ['']],
+ repeat([1], 3))
mock_recv.decode.return_value = PACKET_DUMP_1
ret = prox.get_data()
self.assertEqual(mock_select.select.call_count, 2)
@@ -328,13 +329,54 @@ class TestProxSocketHelper(unittest.TestCase):
self.assertEqual(len(prox._pkt_dumps), 1)
mock_select.select.reset_mock()
- mock_select.select.side_effect = chain([[object()], [None]], repeat([1], 3))
+ mock_select.select.side_effect = chain([[object()], [None]],
+ repeat([1], 3))
mock_recv.decode.return_value = PACKET_DUMP_2
ret = prox.get_data()
self.assertEqual(mock_select.select.call_count, 1)
self.assertEqual(ret, 'jumped over')
self.assertEqual(len(prox._pkt_dumps), 3)
+ @mock.patch.object(prox_helpers, 'select')
+ def test_get_string(self, mock_select):
+ mock_select.select.side_effect = [[1], [0]]
+ mock_socket = mock.MagicMock()
+ mock_recv = mock_socket.recv()
+ mock_recv.decode.return_value = ""
+ prox = prox_helpers.ProxSocketHelper(mock_socket)
+ status, ret = prox.get_string()
+ self.assertEqual(ret, "")
+ self.assertTrue(status)
+ self.assertEqual(len(prox._pkt_dumps), 0)
+
+ @mock.patch.object(prox_helpers, 'select')
+ def test_get_string2(self, mock_select):
+ mock_select.select.side_effect = chain([['a'], ['']],
+ repeat([1], 3))
+ mock_socket = mock.MagicMock()
+ mock_recv = mock_socket.recv()
+ mock_recv.decode.return_value = PACKET_DUMP_1
+ prox = prox_helpers.ProxSocketHelper(mock_socket)
+ status, ret = prox.get_string()
+ self.assertEqual(mock_select.select.call_count, 2)
+ self.assertEqual(ret, 'pktdump,3,11')
+ self.assertTrue(status)
+ self.assertEqual(len(prox._pkt_dumps), 1)
+
+ @mock.patch.object(prox_helpers, 'select')
+ def test_get_string3(self, mock_select):
+ mock_select.select.side_effect = chain([[object()], [None]],
+ repeat([1], 3))
+ mock_socket = mock.MagicMock()
+ mock_recv = mock_socket.recv()
+ mock_recv.decode.return_value = PACKET_DUMP_2
+ prox = prox_helpers.ProxSocketHelper(mock_socket)
+ status, ret = prox.get_string()
+ self.assertTrue(status)
+ self.assertTrue(mock_select.select.assert_called_once)
+ self.assertEqual(ret, 'jumped over')
+ self.assertEqual(len(prox._pkt_dumps), 2)
+
def test__parse_socket_data_mixed_data(self):
prox = prox_helpers.ProxSocketHelper(mock.MagicMock())
ret, _ = prox._parse_socket_data(PACKET_DUMP_NON_1, False)
@@ -551,26 +593,60 @@ class TestProxSocketHelper(unittest.TestCase):
def test_multi_port_stats(self, *args):
mock_socket = mock.MagicMock()
prox = prox_helpers.ProxSocketHelper(mock_socket)
- prox.get_data = mock.MagicMock(return_value='0,1,2,3,4,5;1,1,2,3,4,5')
+ prox.get_string = mock.MagicMock(return_value=(True, '0,1,2,3,4,5;1,1,2,3,4,5'))
expected = [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5]]
- result = prox.multi_port_stats([0, 1])
+ status, result = prox.multi_port_stats([0, 1])
self.assertEqual(result, expected)
-
- prox.get_data = mock.MagicMock(return_value='0,1,2,3,4,5;1,1,2,3,4,5')
- result = prox.multi_port_stats([0])
- expected = [0]
- self.assertEqual(result, expected)
-
- prox.get_data = mock.MagicMock(return_value='0,1,2,3;1,1,2,3,4,5')
- result = prox.multi_port_stats([0, 1])
- expected = [0] * 2
- self.assertEqual(result, expected)
-
- prox.get_data = mock.MagicMock(return_value='99,1,2,3,4,5;1,1,2,3,4,5')
- expected = [0] * 2
- result = prox.multi_port_stats([0, 1])
+ self.assertEqual(status, True)
+
+ prox.get_string = mock.MagicMock(
+ return_value=(True, '0,1,2,3,4,5;1,1,2,3,4,5'))
+ status, result = prox.multi_port_stats([0])
+ self.assertEqual(status, False)
+
+ prox.get_string = mock.MagicMock(
+ return_value=(True, '0,1,2,3,4,5;1,1,2,3,4,5'))
+ status, result = prox.multi_port_stats([0, 1, 2])
+ self.assertEqual(status, False)
+
+ prox.get_string = mock.MagicMock(
+ return_value=(True, '0,1,2,3;1,1,2,3,4,5'))
+ status, result = prox.multi_port_stats([0, 1])
+ self.assertEqual(status, False)
+
+ prox.get_string = mock.MagicMock(
+ return_value=(True, '99,1,2,3,4,5;1,1,2,3,4,5'))
+ status, result = prox.multi_port_stats([0, 1])
+ self.assertEqual(status, False)
+
+ prox.get_string = mock.MagicMock(
+ return_value=(True, '99,1,2,3,4,5;1,1,2,3,4,5'))
+ status, result = prox.multi_port_stats([99, 1])
+ expected = [[99, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5]]
+ self.assertEqual(status, True)
self.assertEqual(result, expected)
+ prox.get_string = mock.MagicMock(
+ return_value=(True,
+ '2,21,22,23,24,25;1,11,12,13,14,15;0,1,2,3,4,5'))
+
+ sample1 = [0, 1, 2, 3, 4, 5]
+ sample2 = [1, 11, 12, 13, 14, 15]
+ sample3 = [2, 21, 22, 23, 24, 25]
+ expected = [sample3, sample2, sample1]
+ status, result = prox.multi_port_stats([1, 2, 0])
+ self.assertTrue(status)
+ self.assertListEqual(result, expected)
+
+ prox.get_string = mock.MagicMock(
+ return_value=(True, '6,21,22,23,24,25;1,11,12,13,14,15;0,1,2,3,4,5'))
+ ok, result = prox.multi_port_stats([1, 6, 0])
+ sample1 = [6, 21, 22, 23, 24, 25]
+ sample2 = [1, 11, 12, 13, 14, 15]
+ sample3 = [0, 1, 2, 3, 4, 5]
+ expected = [sample1, sample2, sample3]
+ self.assertListEqual(result, expected)
+ self.assertTrue(ok)
def test_port_stats(self):
port_stats = [
@@ -1584,8 +1660,9 @@ class TestProxDataHelper(unittest.TestCase):
vnfd_helper.port_pairs.all_ports = list(range(4))
sut = mock.MagicMock()
- sut.multi_port_stats.return_value = [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5],
- [2, 1, 2, 3, 4, 5], [3, 1, 2, 3, 4, 5]]
+ sut.multi_port_stats.return_value = (True,
+ [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5],
+ [2, 1, 2, 3, 4, 5], [3, 1, 2, 3, 4, 5]])
data_helper = prox_helpers.ProxDataHelper(
vnfd_helper, sut, pkt_size, 25, None,
@@ -1593,14 +1670,77 @@ class TestProxDataHelper(unittest.TestCase):
self.assertEqual(data_helper.rx_total, 4)
self.assertEqual(data_helper.tx_total, 8)
- self.assertEqual(data_helper.requested_pps, 6.25e6)
+ self.assertEqual(data_helper.requested_pps, 6250000.0)
+
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = [3, 4]
+
+ sut = mock.MagicMock()
+ sut.multi_port_stats.return_value = (True,
+ [[3, 1, 2, 3, 4, 5], [4, 1, 2, 3, 4, 5]])
+
+ data_helper = prox_helpers.ProxDataHelper(
+ vnfd_helper, sut, pkt_size, 25, None,
+ constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+
+ self.assertEqual(data_helper.rx_total, 2)
+ self.assertEqual(data_helper.tx_total, 4)
+ self.assertEqual(data_helper.requested_pps, 3125000.0)
+
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = [0, 1, 2, 3, 4, 6, 7]
+
+ sut = mock.MagicMock()
+ sut.multi_port_stats.return_value = (True,
+ [[8, 1, 2, 3, 4, 5], [9, 1, 2, 3, 4, 5]])
+
+ data_helper = prox_helpers.ProxDataHelper(
+ vnfd_helper, sut, pkt_size, 25, None,
+ constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+
+ self.assertEqual(data_helper.rx_total, 2)
+ self.assertEqual(data_helper.tx_total, 4)
+ self.assertEqual(data_helper.requested_pps, 10937500.0)
+
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = []
+
+ sut = mock.MagicMock()
+ sut.multi_port_stats.return_value = (True,
+ [[8, 1, 2, 3, 4, 5], [9, 1, 2, 3, 4, 5]])
+
+ data_helper = prox_helpers.ProxDataHelper(
+ vnfd_helper, sut, pkt_size, 25, None,
+ constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+
+ self.assertEqual(data_helper.rx_total, 2)
+ self.assertEqual(data_helper.tx_total, 4)
+ self.assertEqual(data_helper.requested_pps, 0.0)
+
+ def test_totals_and_pps2(self):
+ pkt_size = 180
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.port_pairs.all_ports = list(range(4))
+
+ sut = mock.MagicMock()
+ sut.multi_port_stats.return_value = (True,
+ [[0, 'A', 2, 3, 4, 5], [1, 'B', 'C', 3, 4, 5],
+ ['D', 1, 2, 3, 4, 5], [3, 1, 2, 3, 4, 'F']])
+
+ data_helper = prox_helpers.ProxDataHelper(
+ vnfd_helper, sut, pkt_size, 25, None,
+ constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+
+ self.assertEqual(data_helper.rx_total, 0)
+ self.assertEqual(data_helper.tx_total, 0)
+ self.assertEqual(data_helper.requested_pps, 0)
def test_samples(self):
vnfd_helper = mock.MagicMock()
vnfd_helper.ports_iter.return_value = [('xe0', 0), ('xe1', 1)]
sut = mock.MagicMock()
- sut.multi_port_stats.return_value = [[0, 1, 2, 3, 4, 5], [1, 11, 12, 3, 4, 5]]
+ sut.multi_port_stats.return_value = (True, [[0, 1, 2, 3, 4, 5], [1, 11, 12, 3, 4, 5]])
data_helper = prox_helpers.ProxDataHelper(
vnfd_helper, sut, None, None, None, None)
@@ -1618,13 +1758,35 @@ class TestProxDataHelper(unittest.TestCase):
result = data_helper.samples
self.assertDictEqual(result, expected)
+ def test_samples2(self):
+ vnfd_helper = mock.MagicMock()
+ vnfd_helper.ports_iter.return_value = [('xe1', 3), ('xe2', 7)]
+
+ sut = mock.MagicMock()
+ sut.multi_port_stats.return_value = (True, [[3, 1, 2, 3, 4, 5], [7, 11, 12, 3, 4, 5]])
+
+ data_helper = prox_helpers.ProxDataHelper(
+ vnfd_helper, sut, None, None, None, None)
+
+ expected = {
+ 'xe1': {
+ 'in_packets': 1,
+ 'out_packets': 2,
+ },
+ 'xe2': {
+ 'in_packets': 11,
+ 'out_packets': 12,
+ },
+ }
+ 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 = prox_helpers.ProxDataHelper(vnfd_helper, sut, None, None,
5.4, constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
@@ -1978,7 +2140,6 @@ class TestProxProfileHelper(unittest.TestCase):
client = mock.MagicMock()
client.hz.return_value = 2
- client.port_stats.return_value = tuple(range(12))
helper.client = client
helper.get_latency = mock.MagicMock(return_value=[3.3, 3.6, 3.8])
@@ -1988,18 +2149,20 @@ class TestProxProfileHelper(unittest.TestCase):
with helper.traffic_context(64, 1):
pass
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_run_test(self, _):
+ def test_run_test(self, *args):
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))
+ resource_helper.sut.multi_port_stats.return_value = (True, [[0, 1, 1, 2, 4, 5],
+ [1, 1, 2, 3, 4, 5]])
helper = prox_helpers.ProxProfileHelper(resource_helper)
- helper.run_test(120, 5, 6.5,
- constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
-
+ helper.run_test(pkt_size=120, duration=5, value=6.5, tolerated_loss=0.0,
+ line_speed=constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+ self.assertTrue(resource_helper.sut.multi_port_stats.called)
+ self.assertTrue(resource_helper.sut.stop_all.called)
+ self.assertTrue(resource_helper.sut.reset_stats.called)
class TestProxMplsProfileHelper(unittest.TestCase):
@@ -2135,22 +2298,30 @@ class TestProxBngProfileHelper(unittest.TestCase):
self.assertEqual(helper.arp_task_cores, expected_arp_task)
self.assertEqual(helper._cores_tuple, expected_combined)
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_run_test(self, _):
+ def test_run_test(self, *args):
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))
+ resource_helper.sut.multi_port_stats.return_value = (True, [[0, 1, 1, 2, 4, 5],
+ [1, 1, 2, 3, 4, 5]])
helper = prox_helpers.ProxBngProfileHelper(resource_helper)
- helper.run_test(120, 5, 6.5,
- constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+ helper.run_test(pkt_size=120, duration=5, value=6.5, tolerated_loss=0.0,
+ line_speed=constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+ self.assertTrue(resource_helper.sut.multi_port_stats.called)
+ self.assertTrue(resource_helper.sut.stop_all.called)
+ self.assertTrue(resource_helper.sut.reset_stats.called)
+
+ resource_helper.reset_mock()
# negative pkt_size is the only way to make ratio > 1
- helper.run_test(-1000, 5, 6.5,
- constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+ helper.run_test(pkt_size=-1000, duration=5, value=6.5, tolerated_loss=0.0,
+ line_speed=constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+ self.assertTrue(resource_helper.sut.multi_port_stats.called)
+ self.assertTrue(resource_helper.sut.stop_all.called)
+ self.assertTrue(resource_helper.sut.reset_stats.called)
class TestProxVpeProfileHelper(unittest.TestCase):
@@ -2253,18 +2424,21 @@ class TestProxVpeProfileHelper(unittest.TestCase):
self.assertEqual(helper.inet_ports, expected_inet)
self.assertEqual(helper._ports_tuple, expected_combined)
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_run_test(self, _):
+ def test_run_test(self, *args):
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))
+ resource_helper.sut.multi_port_stats.return_value = (True, [[0, 1, 1, 2, 4, 5],
+ [1, 1, 2, 3, 4, 5]])
helper = prox_helpers.ProxVpeProfileHelper(resource_helper)
- 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
+ helper.run_test(pkt_size=120, duration=5, value=6.5, tolerated_loss=0.0,
+ line_speed=constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+ # negative pkt_size is the only way to make ratio > 1
+ helper.run_test(pkt_size=-1000, duration=5, value=6.5, tolerated_loss=0.0,
+ line_speed=constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
class TestProxlwAFTRProfileHelper(unittest.TestCase):
@@ -2367,14 +2541,18 @@ class TestProxlwAFTRProfileHelper(unittest.TestCase):
self.assertEqual(helper.inet_ports, expected_inet)
self.assertEqual(helper._ports_tuple, expected_combined)
- @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.time')
- def test_run_test(self, _):
+ def test_run_test(self, *args):
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))
+ resource_helper.sut.multi_port_stats.return_value = (True, [[0, 1, 2, 4, 6, 5],
+ [1, 1, 2, 3, 4, 5]])
helper = prox_helpers.ProxlwAFTRProfileHelper(resource_helper)
- 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
+ helper.run_test(pkt_size=120, duration=5, value=6.5, tolerated_loss=0.0,
+ line_speed=constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
+
+ # negative pkt_size is the only way to make ratio > 1
+ helper.run_test(pkt_size=-1000, duration=5, value=6.5, tolerated_loss=0.0,
+ line_speed=constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
index f144e8c42..62cbea0bb 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
@@ -335,6 +335,8 @@ class TestProxApproxVnf(unittest.TestCase):
'packets_in': 0,
'packets_dropped': 0,
'packets_fwd': 0,
+ 'curr_packets_in': 0,
+ 'curr_packets_fwd': 0,
'collect_stats': {'core': {}}
}
result = prox_approx_vnf.collect_kpi()
@@ -346,8 +348,8 @@ class TestProxApproxVnf(unittest.TestCase):
mock_ssh(ssh)
resource_helper = mock.MagicMock()
- resource_helper.execute.return_value = [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5],
- [2, 1, 2, 3, 4, 5], [3, 1, 2, 3, 4, 5]]
+ resource_helper.execute.return_value = (True,
+ [[0, 1, 2, 3, 4, 5], [1, 1, 2, 3, 4, 5]])
resource_helper.collect_collectd_kpi.return_value = {'core': {'result': 234}}
prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id')
@@ -355,20 +357,61 @@ class TestProxApproxVnf(unittest.TestCase):
'nodes': {prox_approx_vnf.name: "mock"}
}
prox_approx_vnf.resource_helper = resource_helper
+ prox_approx_vnf.tsc_hz = 1000
expected = {
+ 'curr_packets_in': 200,
+ 'curr_packets_fwd': 400,
'physical_node': 'mock_node',
- 'packets_in': 4,
- 'packets_dropped': 4,
- 'packets_fwd': 8,
+ 'packets_in': 2,
+ 'packets_dropped': 2,
+ 'packets_fwd': 4,
'collect_stats': {'core': {'result': 234}},
}
result = prox_approx_vnf.collect_kpi()
self.assertEqual(result['packets_in'], expected['packets_in'])
self.assertEqual(result['packets_dropped'], expected['packets_dropped'])
self.assertEqual(result['packets_fwd'], expected['packets_fwd'])
- self.assertNotEqual(result['packets_fwd'], 0)
- self.assertNotEqual(result['packets_fwd'], 0)
+ self.assertEqual(result['curr_packets_in'], expected['curr_packets_in'])
+ self.assertEqual(result['curr_packets_fwd'], expected['curr_packets_fwd'])
+
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ @mock.patch(SSH_HELPER)
+ def test_collect_kpi_bad_input(self, ssh, *args):
+ mock_ssh(ssh)
+
+ resource_helper = mock.MagicMock()
+ resource_helper.execute.return_value = (True,
+ [[0, 'A', 'B', 'C', 'D', 'E'],
+ ['F', 1, 2, 3, 4, 5]])
+
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id')
+ prox_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {prox_approx_vnf.name: "mock"}
+ }
+ prox_approx_vnf.resource_helper = resource_helper
+
+ result = prox_approx_vnf.collect_kpi()
+ self.assertDictEqual(result, {})
+
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ @mock.patch(SSH_HELPER)
+ def test_collect_kpi_bad_input2(self, ssh, *args):
+ mock_ssh(ssh)
+
+ resource_helper = mock.MagicMock()
+ resource_helper.execute.return_value = (False,
+ [[0, 'A', 'B', 'C', 'D', 'E'],
+ ['F', 1, 2, 3, 4, 5]])
+
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0, 'task_id')
+ prox_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {prox_approx_vnf.name: "mock"}
+ }
+ prox_approx_vnf.resource_helper = resource_helper
+
+ result = prox_approx_vnf.collect_kpi()
+ self.assertDictEqual(result, {})
@mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index ec0e6aa6d..741201fdb 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -205,8 +205,8 @@ class TestIXIATrafficGen(unittest.TestCase):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd,
'task_id')
- scenario_cfg = {'tc': "nsb_test_case", "topology": "",
- 'ixia_profile': "ixload.cfg"}
+ scenario_cfg = {'tc': "nsb_test_case",
+ "topology": ""}
scenario_cfg.update(
{
'options': {
@@ -379,7 +379,6 @@ class TestIXIATrafficGen(unittest.TestCase):
},
},
},
- 'ixia_profile': '/path/to/profile',
'task_path': '/path/to/task'
}