aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick
diff options
context:
space:
mode:
authorDeepanshu Bhatia <deepanshu@voereir.com>2019-05-13 12:52:17 +0530
committerDeepanshu Bhatia <deepanshu@voereir.com>2019-05-13 12:52:17 +0530
commit4a28136293a210b9da725c7dc0a5f0eca37370ee (patch)
tree4d4f636ada097a45ea53c992d0ea33573ef5b37d /yardstick
parent9539b3c3bd480d6dcbc37a7eacf44015cced3bb8 (diff)
Ping: Fix TypeError without SLA in timeout scenario
In case of no SLA association with scenario, when the commands timeout, stdout is empty and it gives TypeError. Reverted the condition to the old one which was used before introduction of verifySLA() JIRA: YARDSTICK-1618 Change-Id: Ibd86ba7168f26ae5b15c21fd6129cc737a7038db Signed-off-by: Deepanshu Bhatia <deepanshu@voereir.com>
Diffstat (limited to 'yardstick')
-rw-r--r--yardstick/benchmark/scenarios/networking/ping.py14
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py14
2 files changed, 22 insertions, 6 deletions
diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py
index 6caeab5ef..1c9510220 100644
--- a/yardstick/benchmark/scenarios/networking/ping.py
+++ b/yardstick/benchmark/scenarios/networking/ping.py
@@ -103,12 +103,14 @@ class Ping(base.Scenario):
rtt_result[target_vm_name] = float(self.PING_ERROR_RTT)
# store result before potential AssertionError
result.update(utils.flatten_dict_key(ping_result))
- self.verify_SLA(sla_max_rtt is None,
- "packet dropped rtt %f > sla: max_rtt(%f)"
- % (rtt_result[target_vm_name], sla_max_rtt))
- self.verify_SLA(False,
- "packet dropped rtt %f"
- % (rtt_result[target_vm_name]))
+ if sla_max_rtt is not None:
+ self.verify_SLA(rtt_result[target_vm_name] <= sla_max_rtt,
+ "packet dropped rtt %f > sla: max_rtt(%f)"
+ % (rtt_result[target_vm_name], sla_max_rtt))
+ else:
+ self.verify_SLA(False,
+ "packet dropped rtt %f"
+ % (rtt_result[target_vm_name]))
def _test(): # pragma: no cover
diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py
index 559e0599e..944202658 100644
--- a/yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py
+++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_ping.py
@@ -91,3 +91,17 @@ class PingTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.run, result)
+
+ @mock.patch('yardstick.benchmark.scenarios.networking.ping.ssh')
+ def test_ping_unsuccessful_no_sla(self, mock_ssh):
+
+ args = {
+ 'options': {'packetsize': 200},
+ 'target': 'ares.demo'
+ }
+ result = {}
+
+ p = ping.Ping(args, self.ctx)
+
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.assertRaises(y_exc.SLAValidationError, p.run, result)