From: wu.zhihui Date: Mon, 2 Nov 2015 08:11:54 +0000 (+0800) Subject: Avoid the ValueError exception for a ping timeout. X-Git-Tag: brahmaputra.1.0~157^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=377fa4dfa142b0bc7e8be92e442199456993fe9d;p=yardstick.git Avoid the ValueError exception for a ping timeout. In ping.py: If ping a ip address timeout, the return value "stdout" is null. And the code "rtt=float(stdout)" raises a ValueError exception. The better handle is to avoid the exception and log a ping timeout. Change-Id: Ia2a3ff44c35dda1a700a5109f8e642a636e89bc6 Signed-off-by: wu.zhihui --- diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py index 34278b90f..c62c79e54 100644 --- a/yardstick/benchmark/scenarios/networking/ping.py +++ b/yardstick/benchmark/scenarios/networking/ping.py @@ -67,12 +67,15 @@ class Ping(base.Scenario): if exit_status != 0: raise RuntimeError(stderr) - result["rtt"] = float(stdout) + if stdout: + result["rtt"] = float(stdout) - if "sla" in self.scenario_cfg: - sla_max_rtt = int(self.scenario_cfg["sla"]["max_rtt"]) - assert result["rtt"] <= sla_max_rtt, "rtt %f > sla:max_rtt(%f); " % \ - (result["rtt"], sla_max_rtt) + if "sla" in self.scenario_cfg: + sla_max_rtt = int(self.scenario_cfg["sla"]["max_rtt"]) + assert result["rtt"] <= sla_max_rtt, "rtt %f > sla:max_rtt(%f); " % \ + (result["rtt"], sla_max_rtt) + else: + LOG.error("ping '%s' '%s' timeout", options, destination) def _test():