# limitations under the License.
""" Vsperf specific scenario definition """
+from __future__ import absolute_import
import logging
import os
import subprocess
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
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)
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
"""
__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
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_ssh_port = vsperf.get('ssh_port', ssh.DEFAULT_PORT)
- vsperf_password = vsperf.get('password', 'ubuntu')
- vsperf_ip = vsperf.get('ip', None)
# add trafficgen interfaces to the external bridge
if self.tg_port1:
(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, port=vsperf_ssh_port)
+ 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:
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)
# 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