# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from __future__ import absolute_import
import pkg_resources
import logging
import time
self.setup_done = False
def setup(self):
- '''scenario setup'''
+ """scenario setup"""
self.pktgen_dpdk_script = pkg_resources.resource_filename(
'yardstick.benchmark.scenarios.networking',
PktgenDPDKLatency.PKTGEN_DPDK_SCRIPT)
self.server.wait(timeout=600)
# copy script to host
- self.server.run("cat > ~/testpmd_fwd.sh",
- stdin=open(self.testpmd_script, "rb"))
+ 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,
self.client.wait(timeout=600)
# copy script to host
- self.client.run("cat > ~/pktgen_dpdk.sh",
- stdin=open(self.pktgen_dpdk_script, "rb"))
+ self.client._put_file_shell(
+ self.pktgen_dpdk_script, '~/pktgen_dpdk.sh')
self.setup_done = True
self.testpmd_args = ''
# 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:
latency_sum = 0
for i in latency_list:
latency_sum += int(i)
- avg_latency = latency_sum/len(latency_list)
+ avg_latency = latency_sum / len(latency_list)
result.update({"avg_latency": avg_latency})