X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fbenchmark%2Fscenarios%2Fnetworking%2Fpktgen_dpdk.py;h=ce8a7f4979ed324cda07fe7a7d6de350076bc167;hb=39494c01b49cafd893982d74e030b9b96b5fa821;hp=0b70629f83e26d232d05b46f67dab27f294689a1;hpb=03d764791eeb708ade47b5e2196b18ce04552dd1;p=yardstick.git diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py index 0b70629f8..ce8a7f497 100644 --- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py +++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py @@ -12,8 +12,10 @@ import logging import time import yardstick.ssh as ssh +import yardstick.common.utils as utils from yardstick.benchmark.scenarios import base + LOG = logging.getLogger(__name__) @@ -45,28 +47,16 @@ class PktgenDPDKLatency(base.Scenario): 'yardstick.benchmark.scenarios.networking', PktgenDPDKLatency.TESTPMD_SCRIPT) host = self.context_cfg['host'] - host_user = host.get('user', 'ubuntu') - host_ssh_port = host.get('ssh_port', ssh.DEFAULT_PORT) - host_ip = host.get('ip', None) - host_key_filename = host.get('key_filename', '~/.ssh/id_rsa') target = self.context_cfg['target'] - target_user = target.get('user', 'ubuntu') - target_ssh_port = target.get('ssh_port', ssh.DEFAULT_PORT) - target_ip = target.get('ip', None) - target_key_filename = target.get('key_filename', '~/.ssh/id_rsa') - LOG.info("user:%s, target:%s", target_user, target_ip) - self.server = ssh.SSH(target_user, target_ip, - key_filename=target_key_filename, - port=target_ssh_port) + LOG.info("user:%s, target:%s", target['user'], target['ip']) + self.server = ssh.SSH.from_node(target, defaults={"user": "ubuntu"}) self.server.wait(timeout=600) # copy script to host self.server._put_file_shell(self.testpmd_script, '~/testpmd_fwd.sh') - LOG.info("user:%s, host:%s", host_user, host_ip) - self.client = ssh.SSH(host_user, host_ip, - key_filename=host_key_filename, - port=host_ssh_port) + LOG.info("user:%s, host:%s", host['user'], host['ip']) + self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"}) self.client.wait(timeout=600) # copy script to host @@ -77,29 +67,6 @@ class PktgenDPDKLatency(base.Scenario): self.testpmd_args = '' self.pktgen_args = [] - @staticmethod - def get_port_mac(sshclient, port): - cmd = "ifconfig |grep HWaddr |grep %s |awk '{print $5}' " % port - LOG.debug("Executing command: %s", cmd) - status, stdout, stderr = sshclient.execute(cmd) - - if status: - raise RuntimeError(stderr) - else: - return stdout.rstrip() - - @staticmethod - def get_port_ip(sshclient, port): - cmd = "ifconfig %s |grep 'inet addr' |awk '{print $2}' \ - |cut -d ':' -f2 " % port - LOG.debug("Executing command: %s", cmd) - status, stdout, stderr = sshclient.execute(cmd) - - if status: - raise RuntimeError(stderr) - else: - return stdout.rstrip() - def run(self, result): """execute the benchmark""" @@ -107,13 +74,13 @@ class PktgenDPDKLatency(base.Scenario): self.setup() if not self.testpmd_args: - self.testpmd_args = self.get_port_mac(self.client, 'eth2') + self.testpmd_args = utils.get_port_mac(self.client, 'eth2') if not self.pktgen_args: - server_rev_mac = self.get_port_mac(self.server, 'eth1') - server_send_mac = self.get_port_mac(self.server, 'eth2') - client_src_ip = self.get_port_ip(self.client, 'eth1') - client_dst_ip = self.get_port_ip(self.client, 'eth2') + server_rev_mac = utils.get_port_mac(self.server, 'eth1') + server_send_mac = utils.get_port_mac(self.server, 'eth2') + client_src_ip = utils.get_port_ip(self.client, 'eth1') + client_dst_ip = utils.get_port_ip(self.client, 'eth2') self.pktgen_args = [client_src_ip, client_dst_ip, server_rev_mac, server_send_mac] @@ -137,10 +104,12 @@ class PktgenDPDKLatency(base.Scenario): # wait for finishing test time.sleep(1) - cmd = "cat ~/result.log -vT \ - |awk '{match($0,/\[8;40H +[0-9]+/)} \ - {print substr($0,RSTART,RLENGTH)}' \ - |grep -v ^$ |awk '{if ($2 != 0) print $2}'" + cmd = r"""\ +cat ~/result.log -vT \ +|awk '{match($0,/\[8;40H +[0-9]+/)} \ +{print substr($0,RSTART,RLENGTH)}' \ +|grep -v ^$ |awk '{if ($2 != 0) print $2}'\ +""" client_status, client_stdout, client_stderr = self.client.execute(cmd) if client_status: