aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py')
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_prox_binsearch.py39
1 files changed, 29 insertions, 10 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 c09903377..f17656328 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
@@ -21,6 +21,8 @@ from yardstick.network_services.traffic_profile import prox_binsearch
class TestProxBinSearchProfile(unittest.TestCase):
+ THEOR_MAX_THROUGHPUT = 0.00012340000000000002
+
def setUp(self):
self._mock_log_info = mock.patch.object(prox_binsearch.LOG, 'info')
self.mock_log_info = self._mock_log_info.start()
@@ -38,6 +40,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 +59,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,11 +78,11 @@ 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,
- 'theor_max_throughput': 7.5e-07,
+ 'theor_max_throughput': self.THEOR_MAX_THROUGHPUT,
'PktSize': 200,
'Status': 'Result'}
@@ -88,7 +98,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
"PktSize": 200,
"RxThroughput": 7.5e-07,
"Throughput": 7.5e-07,
- "TxThroughput": 0.00012340000000000002,
+ "TxThroughput": self.THEOR_MAX_THROUGHPUT,
"Status": 'Success'}
calls = profile.queue.put(success_result_tuple)
@@ -121,6 +131,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 +154,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 +169,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 +205,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)
@@ -207,6 +224,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
raise RuntimeError(' '.join([str(args), str(runs)]))
if args[2] > 75.0:
return fail_tuple, {}
+
return success_tuple, {}
tp_config = {
@@ -226,6 +244,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()
@@ -242,7 +261,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
# Result Samples inc theor_max
result_tuple = {'Actual_throughput': 5e-07,
- 'theor_max_throughput': 7.5e-07,
+ 'theor_max_throughput': self.THEOR_MAX_THROUGHPUT,
'PktSize': 200,
"Status": 'Result'}
@@ -258,7 +277,7 @@ class TestProxBinSearchProfile(unittest.TestCase):
"PktSize": 200,
"RxThroughput": 7.5e-07,
"Throughput": 7.5e-07,
- "TxThroughput": 0.00012340000000000002,
+ "TxThroughput": self.THEOR_MAX_THROUGHPUT,
"Status": 'Success'}
calls = profile.queue.put(success_result_tuple)