summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/ping-ext-ip.yaml36
-rw-r--r--samples/ping.yaml1
-rw-r--r--setup.py9
-rw-r--r--yardstick/benchmark/scenarios/networking/ping.py15
-rwxr-xr-xyardstick/main.py37
5 files changed, 76 insertions, 22 deletions
diff --git a/samples/ping-ext-ip.yaml b/samples/ping-ext-ip.yaml
new file mode 100644
index 000000000..82cd02c7b
--- /dev/null
+++ b/samples/ping-ext-ip.yaml
@@ -0,0 +1,36 @@
+---
+# Sample benchmark task config file
+# Measure network latency using ping, destination is an external server
+# Make sure servers have internet access before running this test.
+# For example using virtual MOS do something this on the host:
+# sudo iptables -t nat -A POSTROUTING -s 172.16.0.0/24 \! -d 172.16.0.0/24 -j MASQUERADE
+#
+
+schema: "yardstick:task:0.1"
+
+scenarios:
+-
+ type: Ping
+ host: client.demo
+ target: 8.8.8.8
+ runner:
+ type: Duration
+ duration: 60
+ interval: 1
+ sla:
+ max_rtt: 10
+ action: monitor
+
+context:
+ name: demo
+ image: cirros-0.3.3
+ flavor: m1.tiny
+ user: cirros
+ servers:
+ client:
+ floating_ip: true
+ networks:
+ test:
+ cidr: '10.0.1.0/24'
+ external_network: "net04_ext"
+
diff --git a/samples/ping.yaml b/samples/ping.yaml
index 9a06fc48f..3bc108142 100644
--- a/samples/ping.yaml
+++ b/samples/ping.yaml
@@ -26,7 +26,6 @@ context:
image: cirros-0.3.3
flavor: m1.tiny
user: cirros
- anti_affinity: true
placement_groups:
pgrp1:
diff --git a/setup.py b/setup.py
index ff415aecd..742192c6f 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,8 @@ setup(
include_package_data=True,
package_data={'yardstick': ['benchmark/scenarios/networking/*.bash']},
url="https://www.opnfv.org",
- install_requires=["flake8",
+ install_requires=["backport_ipaddress", # remove with python3
+ "flake8",
"PyYAML>=3.10",
"pbr!=0.7,<1.0,>=0.6",
"python-glanceclient>=0.12.0",
@@ -18,14 +19,14 @@ setup(
"python-keystoneclient>=0.11.1",
"python-neutronclient>=2.3.9",
"python-novaclient>=2.24.1",
- "mock>=1.0.1",
+ "mock>=1.0.1", # remove with python3
"paramiko",
"six"
],
- entry_points = {
+ entry_points={
'console_scripts': [
'yardstick=yardstick.main:main',
],
},
- scripts =['tools/yardstick-img-modify']
+ scripts=['tools/yardstick-img-modify']
)
diff --git a/yardstick/benchmark/scenarios/networking/ping.py b/yardstick/benchmark/scenarios/networking/ping.py
index a027c817a..1b87c7460 100644
--- a/yardstick/benchmark/scenarios/networking/ping.py
+++ b/yardstick/benchmark/scenarios/networking/ping.py
@@ -40,13 +40,17 @@ class Ping(base.Scenario):
def run(self, args):
"""execute the benchmark"""
- self.options = "-s %s" % args['options'].get("packetsize", '56')
- self.ipaddr = args.get("ipaddr", '127.0.0.1')
+ if "options" in args:
+ options = "-s %s" % args['options'].get("packetsize", '56')
+ else:
+ options = ""
- LOG.debug("ping %s %s", self.options, self.ipaddr)
+ destination = args.get("ipaddr", '127.0.0.1')
+
+ LOG.debug("ping '%s' '%s'", options, destination)
exit_status, stdout, stderr = self.connection.execute(
- "/bin/sh -s {0} {1}".format(self.ipaddr, self.options),
+ "/bin/sh -s {0} {1}".format(options, destination),
stdin=open(self.target_script, "r"))
if exit_status != 0:
@@ -56,6 +60,7 @@ class Ping(base.Scenario):
if "sla" in args:
sla_max_rtt = int(args["sla"]["max_rtt"])
- assert rtt <= sla_max_rtt, "rtt %f > sla_max_rtt" % rtt
+ assert rtt <= sla_max_rtt, "rtt %f > sla:max_rtt(%f)" % \
+ (rtt, sla_max_rtt)
return rtt
diff --git a/yardstick/main.py b/yardstick/main.py
index 942b46be9..8f017431b 100755
--- a/yardstick/main.py
+++ b/yardstick/main.py
@@ -43,6 +43,7 @@ import sys
import yaml
import atexit
import pkg_resources
+import ipaddress
from yardstick.benchmark.context.model import Context
from yardstick.benchmark.runners import base as base_runner
@@ -93,6 +94,15 @@ def atexit_handler():
context.undeploy()
+def is_ip_addr(addr):
+ '''check if string addr is an IP address'''
+ try:
+ ipaddress.ip_address(addr)
+ return True
+ except ValueError:
+ return False
+
+
def run_one_scenario(scenario_cfg, output_file):
'''run one scenario using context'''
key_filename = pkg_resources.resource_filename(
@@ -107,19 +117,22 @@ def run_one_scenario(scenario_cfg, output_file):
runner_cfg['output_filename'] = output_file
if "target" in scenario_cfg:
- target = Context.get_server(scenario_cfg["target"])
-
- # get public IP for target server, some scenarios require it
- if target.public_ip:
- runner_cfg['target'] = target.public_ip
-
- # TODO scenario_cfg["ipaddr"] is bad naming
- if host.context != target.context:
- # target is in another context, get its public IP
- scenario_cfg["ipaddr"] = target.public_ip
+ if is_ip_addr(scenario_cfg["target"]):
+ scenario_cfg["ipaddr"] = scenario_cfg["target"]
else:
- # target is in the same context, get its private IP
- scenario_cfg["ipaddr"] = target.private_ip
+ target = Context.get_server(scenario_cfg["target"])
+
+ # get public IP for target server, some scenarios require it
+ if target.public_ip:
+ runner_cfg['target'] = target.public_ip
+
+ # TODO scenario_cfg["ipaddr"] is bad naming
+ if host.context != target.context:
+ # target is in another context, get its public IP
+ scenario_cfg["ipaddr"] = target.public_ip
+ else:
+ # target is in the same context, get its private IP
+ scenario_cfg["ipaddr"] = target.private_ip
runner = base_runner.Runner.get(runner_cfg)