aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/networking/ping.py
diff options
context:
space:
mode:
authorJingLu5 <lvjing5@huawei.com>2016-07-01 11:05:51 +0800
committerJingLu5 <lvjing5@huawei.com>2016-07-04 15:07:38 +0800
commitd51cbf72b8fb2e5c6acc06248919b1401d09c853 (patch)
tree240c90a42656c609a7a698df6f6dded7c3934c20 /yardstick/benchmark/scenarios/networking/ping.py
parent14c7413448e4690fefd0ecad908ec86d6f774d6f (diff)
Add support for multiple VMs
Verify and add support for multiple target VMs. This is related to further work with SDNVPN project. In the task configration file, use 'target' for specifying one target VM and use 'targets' for specifying multiple target VMs. Change-Id: I682188ef4c2c2c012d5ab00417b69f5b31b87137 Signed-off-by: JingLu5 <lvjing5@huawei.com>
Diffstat (limited to 'yardstick/benchmark/scenarios/networking/ping.py')
-rw-r--r--yardstick/benchmark/scenarios/networking/ping.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py
index ae2166687..3af354850 100644
--- a/yardstick/benchmark/scenarios/networking/ping.py
+++ b/yardstick/benchmark/scenarios/networking/ping.py
@@ -57,29 +57,32 @@ class Ping(base.Scenario):
else:
options = ""
- destination = self.context_cfg['target'].get("ipaddr", '127.0.0.1')
+ destination = self.context_cfg['target'].get('ipaddr', '127.0.0.1')
+ dest_list = [s.strip() for s in destination.split(',')]
- LOG.debug("ping '%s' '%s'", options, destination)
+ result["rtt"] = {}
+ rtt_result = result["rtt"]
- exit_status, stdout, stderr = self.connection.execute(
- "/bin/sh -s {0} {1}".format(destination, options),
- stdin=open(self.target_script, "r"))
+ for dest in dest_list:
+ LOG.debug("ping '%s' '%s'", options, dest)
+ exit_status, stdout, stderr = self.connection.execute(
+ "/bin/sh -s {0} {1}".format(dest, options),
+ stdin=open(self.target_script, "r"))
- if exit_status != 0:
- raise RuntimeError(stderr)
+ if exit_status != 0:
+ raise RuntimeError(stderr)
- 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)
- else:
- LOG.error("ping '%s' '%s' timeout", options, destination)
+ if stdout:
+ rtt_result[dest] = float(stdout)
+ if "sla" in self.scenario_cfg:
+ sla_max_rtt = int(self.scenario_cfg["sla"]["max_rtt"])
+ assert rtt_result[dest] <= sla_max_rtt, "rtt %f > sla:\
+ max_rtt(%f); " % (rtt_result[dest], sla_max_rtt)
+ else:
+ LOG.error("ping '%s' '%s' timeout", options, dest)
-def _test():
+def _test(): # pragma: no cover
'''internal test function'''
key_filename = pkg_resources.resource_filename("yardstick.resources",
"files/yardstick_key")
@@ -104,5 +107,5 @@ def _test():
p.run(result)
print result
-if __name__ == '__main__':
+if __name__ == '__main__': # pragma: no cover
_test()