X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fbenchmark%2Fscenarios%2Fnetworking%2Fvsperf.py;h=705544c41096277d46bc25db0f5222aa29aff5ad;hb=99abbb424007da2e01762f3c040a39c0157cbe1f;hp=d3123083a356f8ff897f931bd69e5c60eb425450;hpb=415af13357318f6c3328ea13953a0369fb27a147;p=yardstick.git diff --git a/yardstick/benchmark/scenarios/networking/vsperf.py b/yardstick/benchmark/scenarios/networking/vsperf.py index d3123083a..705544c41 100644 --- a/yardstick/benchmark/scenarios/networking/vsperf.py +++ b/yardstick/benchmark/scenarios/networking/vsperf.py @@ -13,6 +13,7 @@ # limitations under the License. """ Vsperf specific scenario definition """ +from __future__ import absolute_import import logging import os import subprocess @@ -32,14 +33,11 @@ class Vsperf(base.Scenario): the valid values are "rfc2544", "continuous", "back2back" type: string default: "rfc2544" - pkt_sizes - a packet size for which test should be executed; - Multiple packet sizes can be tested by modification of Sequence runner + frame_size - a frame size for which test should be executed; + Multiple frame sizes can be tested by modification of sequence runner section inside TC YAML definition. type: string default: "64" - duration - sets duration for which traffic will be generated - type: int - default: 30 bidirectional - speficies if traffic will be uni (False) or bi-directional (True) type: string @@ -47,9 +45,6 @@ class Vsperf(base.Scenario): iload - specifies frame rate type: string default: 100 - rfc2544_trials - the number of trials performed for each packet size - type: string - default: NA multistream - the number of simulated streams type: string default: 0 (disabled) @@ -57,11 +52,24 @@ class Vsperf(base.Scenario): the valid values are "L4", "L3" and "L2" type: string default: "L4" - conf-file - path to the vsperf configuration file, which will be uploaded - to the VM + test_params - specifies a string with a list of vsperf configuration + parameters, which will be passed to the '--test-params' CLI argument; + Parameters should be stated in the form of 'param=value' and separated + by a semicolon. Please check VSPERF documentation for details about + available configuration parameters and their data types. + In case that both 'test_params' and 'conf_file' are specified, + then values from 'test_params' will override values defined + in the configuration file. + type: string + default: NA + conf_file - path to the vsperf configuration file, which will be uploaded + to the VM; + In case that both 'test_params' and 'conf_file' are specified, + then values from 'test_params' will override values defined + in configuration file. type: string default: NA - setup-script - path to the setup script, which will be executed during + setup_script - path to the setup script, which will be executed during setup and teardown phases type: string default: NA @@ -80,8 +88,6 @@ class Vsperf(base.Scenario): """ __scenario_type__ = "Vsperf" - VSPERF_CONF = '~/vsperf-yardstick.conf' - def __init__(self, scenario_cfg, context_cfg): self.scenario_cfg = scenario_cfg self.context_cfg = context_cfg @@ -93,19 +99,21 @@ class Vsperf(base.Scenario): None) self.br_ex = self.scenario_cfg['options'].get('external_bridge', 'br-ex') - self.vsperf_conf = os.path.expanduser( - self.scenario_cfg['options'].get('conf-file', Vsperf.VSPERF_CONF)) - self.setup_script = self.scenario_cfg['options'].get('setup-script', + self.vsperf_conf = self.scenario_cfg['options'].get('conf_file', None) + if self.vsperf_conf: + self.vsperf_conf = os.path.expanduser(self.vsperf_conf) + + self.setup_script = self.scenario_cfg['options'].get('setup_script', None) if self.setup_script: self.setup_script = os.path.expanduser(self.setup_script) + self.test_params = self.scenario_cfg['options'].get('test-params', + None) + def setup(self): - '''scenario setup''' + """scenario setup""" vsperf = self.context_cfg['host'] - vsperf_user = vsperf.get('user', 'ubuntu') - vsperf_password = vsperf.get('password', 'ubuntu') - vsperf_ip = vsperf.get('ip', None) # add trafficgen interfaces to the external bridge if self.tg_port1: @@ -116,15 +124,14 @@ class Vsperf(base.Scenario): (self.br_ex, self.tg_port2), shell=True) # copy vsperf conf to VM - LOG.info("user:%s, host:%s", vsperf_user, vsperf_ip) - self.client = ssh.SSH(vsperf_user, vsperf_ip, - password=vsperf_password) + self.client = ssh.SSH.from_node(vsperf, defaults={ + "user": "ubuntu", "password": "ubuntu" + }) # traffic generation could last long self.client.wait(timeout=1800) # copy script to host - self.client.run("cat > ~/vsperf.conf", - stdin=open(self.vsperf_conf, "rb")) + self.client._put_file_shell(self.vsperf_conf, '~/vsperf.conf') # execute external setup script if self.setup_script: @@ -165,18 +172,26 @@ class Vsperf(base.Scenario): options = self.scenario_cfg['options'] test_params = [] test_params.append(add_test_params(options, "traffic_type", "rfc2544")) - test_params.append(add_test_params(options, "pkt_sizes", "64")) - test_params.append(add_test_params(options, "duration", None)) test_params.append(add_test_params(options, "bidirectional", "False")) test_params.append(add_test_params(options, "iload", 100)) - test_params.append(add_test_params(options, "rfc2544_trials", None)) test_params.append(add_test_params(options, "multistream", None)) test_params.append(add_test_params(options, "stream_type", None)) + if 'frame_size' in options: + test_params.append("%s=(%s,)" % ('TRAFFICGEN_PKT_SIZES', + options['frame_size'])) + if 'test_params' in options: + test_params.append(options['test_params']) + + # filter empty parameters and escape quotes and double quotes + test_params = [tp.replace('"', '\\"').replace("'", "\\'") + for tp in test_params if tp] # execute vsperf cmd = "source ~/vsperfenv/bin/activate ; cd vswitchperf ; " - cmd += "./vsperf --mode trafficgen --conf-file ~/vsperf.conf " - cmd += "--test-params=\"%s\"" % (';'.join(filter(None, test_params))) + cmd += "./vsperf --mode trafficgen " + if self.vsperf_conf: + cmd += "--conf-file ~/vsperf.conf " + cmd += "--test-params=\"%s\"" % (';'.join(test_params)) LOG.debug("Executing command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) @@ -193,7 +208,7 @@ class Vsperf(base.Scenario): # convert result.csv to JSON format reader = csv.DictReader(stdout.split('\r\n')) - result.update(reader.next()) + result.update(next(reader)) # sla check; go through all defined SLAs and check if values measured # by VSPERF are higher then those defined by SLAs