summaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/network_services
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/tests/unit/network_services')
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py94
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py49
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py9
3 files changed, 134 insertions, 18 deletions
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 da550ade9..988ebe3de 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
@@ -51,6 +51,11 @@ 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}
+ traffic_generator.scenario_helper.all_options.configure_mock(**attrs1)
+
+ attrs2 = {'__getitem__.return_value' : 10, 'get.return_value': 10}
+ traffic_generator.scenario_helper.scenario_cfg["runner"].configure_mock(**attrs2)
profile_helper = mock.MagicMock()
profile_helper.run_test = target
@@ -60,9 +65,10 @@ class TestProxBinSearchProfile(unittest.TestCase):
profile._profile_helper = profile_helper
profile.execute_traffic(traffic_generator)
+
self.assertEqual(round(profile.current_lower, 2), 74.69)
self.assertEqual(round(profile.current_upper, 2), 76.09)
- self.assertEqual(len(runs), 7)
+ self.assertEqual(len(runs), 77)
# Result Samples inc theor_max
result_tuple = {"Result_Actual_throughput": 7.5e-07,
@@ -122,6 +128,11 @@ 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}
+ 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()
profile_helper.run_test = target
@@ -171,7 +182,8 @@ class TestProxBinSearchProfile(unittest.TestCase):
# Result Samples
- result_tuple = {"Result_theor_max_throughput": 0, "Result_pktSize": 200}
+ result_tuple = {'Result_Actual_throughput': 0, "Result_theor_max_throughput": 0,
+ "Result_pktSize": 200}
profile.queue.put.assert_called_with(result_tuple)
# Check for success_ tuple (None expected)
@@ -181,3 +193,81 @@ class TestProxBinSearchProfile(unittest.TestCase):
for k in call_detail:
if "Success_" in k:
self.assertRaises(AttributeError)
+
+ def test_execute_4(self):
+
+ def target(*args, **_):
+ runs.append(args[2])
+ if args[2] < 0 or args[2] > 100:
+ raise RuntimeError(' '.join([str(args), str(runs)]))
+ if args[2] > 75.0:
+ return fail_tuple, {}
+ return success_tuple, {}
+
+ tp_config = {
+ 'traffic_profile': {
+ 'packet_sizes': [200],
+ 'test_precision': 2.0,
+ 'tolerated_loss': 0.001,
+ },
+ }
+
+ runs = []
+ 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_generator = mock.MagicMock()
+ attrs1 = {'get.return_value': 100000}
+ 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()
+ 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)
+ self.assertEqual(round(profile.current_upper, 2), 76.09)
+ self.assertEqual(len(runs), 7)
+
+ # Result Samples inc theor_max
+ result_tuple = {'Result_Actual_throughput': 7.5e-07,
+ 'Result_theor_max_throughput': 0.00012340000000000002,
+ 'Result_pktSize': 200}
+
+ profile.queue.put.assert_called_with(result_tuple)
+
+ success_result_tuple = {"Success_CurrentDropPackets": 0.5,
+ "Success_DropPackets": 0.5,
+ "Success_LatencyAvg": 5.3,
+ "Success_LatencyMax": 5.2,
+ "Success_LatencyMin": 5.1,
+ "Success_PktSize": 200,
+ "Success_RxThroughput": 7.5e-07,
+ "Success_Throughput": 7.5e-07,
+ "Success_TxThroughput": 0.00012340000000000002}
+
+ calls = profile.queue.put(success_result_tuple)
+ profile.queue.put.assert_has_calls(calls)
+
+ success_result_tuple2 = {"Success_CurrentDropPackets": 0.5,
+ "Success_DropPackets": 0.5,
+ "Success_LatencyAvg": 5.3,
+ "Success_LatencyMax": 5.2,
+ "Success_LatencyMin": 5.1,
+ "Success_PktSize": 200,
+ "Success_RxThroughput": 7.5e-07,
+ "Success_Throughput": 7.5e-07,
+ "Success_TxThroughput": 123.4,
+ "Success_can_be_lost": 409600,
+ "Success_drop_total": 20480,
+ "Success_rx_total": 4075520,
+ "Success_tx_total": 4096000}
+
+ calls = profile.queue.put(success_result_tuple2)
+ profile.queue.put.assert_has_calls(calls)
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 0cb11933f..b1853f12f 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
@@ -556,6 +556,31 @@ class TestProxSocketHelper(unittest.TestCase):
result = prox.core_stats([3, 4, 5], 16)
self.assertEqual(result, expected)
+ def test_multi_port_stats(self):
+
+ mock_socket = mock.MagicMock()
+ prox = ProxSocketHelper(mock_socket)
+ prox.get_data = mock.MagicMock(return_value='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])
+ 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(result, expected)
+
+
def test_port_stats(self):
port_stats = [
','.join(str(n) for n in range(3, 15)),
@@ -1542,34 +1567,34 @@ class TestProxDataHelper(unittest.TestCase):
vnfd_helper.port_pairs.all_ports = list(range(4))
sut = mock.MagicMock()
- sut.port_stats.return_value = list(range(10))
+ 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]]
data_helper = ProxDataHelper(
vnfd_helper, sut, pkt_size, 25, None,
constants.NIC_GBPS_DEFAULT * constants.ONE_GIGABIT_IN_BITS)
- self.assertEqual(data_helper.rx_total, 6)
- self.assertEqual(data_helper.tx_total, 7)
+ self.assertEqual(data_helper.rx_total, 4)
+ self.assertEqual(data_helper.tx_total, 8)
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)]
+ vnfd_helper.ports_iter.return_value = [('xe0', 0), ('xe1', 1)]
sut = mock.MagicMock()
- sut.port_stats.return_value = list(range(10))
+ sut.multi_port_stats.return_value = [[0, 1, 2, 3, 4, 5], [1, 11, 12, 3, 4, 5]]
data_helper = ProxDataHelper(vnfd_helper, sut, None, None, None, None)
expected = {
- 'xe1': {
- 'in_packets': 6,
- 'out_packets': 7,
+ 'xe0': {
+ 'in_packets': 1,
+ 'out_packets': 2,
},
- 'xe2': {
- 'in_packets': 6,
- 'out_packets': 7,
+ 'xe1': {
+ 'in_packets': 11,
+ 'out_packets': 12,
},
}
result = data_helper.samples
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 fa2d462ab..351607fb5 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
@@ -339,16 +339,17 @@ class TestProxApproxVnf(unittest.TestCase):
mock_ssh(ssh)
resource_helper = mock.MagicMock()
- resource_helper.execute.return_value = list(range(12))
+ 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.collect_collectd_kpi.return_value = {'core': {'result': 234}}
prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf.resource_helper = resource_helper
expected = {
- 'packets_in': 6,
- 'packets_dropped': 1,
- 'packets_fwd': 7,
+ 'packets_in': 4,
+ 'packets_dropped': 4,
+ 'packets_fwd': 8,
'collect_stats': {'core': {'result': 234}},
}
result = prox_approx_vnf.collect_kpi()