def dpdk_setup(self): """dpdk setup""" # setup dpdk loopback in VM self.testpmd_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', VsperfDPDK.TESTPMD_SCRIPT) self.client._put_file_shell(self.testpmd_script, '~/testpmd_vsperf.sh') # disable Address Space Layout Randomization (ASLR) cmd = "echo 0 | sudo tee /proc/sys/kernel/randomize_va_space" self.client.send_command(cmd) if not self._is_dpdk_setup(): self.tgen_port1_ip = \ utils.get_port_ip(self.client, self.tg_port1) self.tgen_port1_mac = \ utils.get_port_mac(self.client, self.tg_port1) self.client.run("tee ~/.testpmd.ipaddr.port1 > /dev/null", stdin=self.tgen_port1_ip) self.client.run("tee ~/.testpmd.macaddr.port1 > /dev/null", stdin=self.tgen_port1_mac) self.tgen_port2_ip = \ utils.get_port_ip(self.client, self.tg_port2) self.tgen_port2_mac = \ utils.get_port_mac(self.client, self.tg_port2) self.client.run("tee ~/.testpmd.ipaddr.port2 > /dev/null", stdin=self.tgen_port2_ip) self.client.run("tee ~/.testpmd.macaddr.port2 > /dev/null", stdin=self.tgen_port2_mac) cmd = "ip link set %s down" % (self.tg_port1) LOG.debug("Executing command: %s", cmd) self.client.send_command(cmd) cmd = "ip link set %s down" % (self.tg_port2) LOG.debug("Executing command: %s", cmd) self.client.send_command(cmd) else: cmd = "cat ~/.testpmd.macaddr.port1" status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) self.tgen_port1_mac = stdout cmd = "cat ~/.testpmd.macaddr.port2" status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) self.tgen_port2_mac = stdout cmd = "screen -d -m sudo -E bash ~/testpmd_vsperf.sh %s %s" % \ (self.moongen_port1_mac, self.moongen_port2_mac) LOG.debug("Executing command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) time.sleep(1) self.dpdk_setup_done = True
def dpdk_setup(self): """dpdk setup""" # disable Address Space Layout Randomization (ASLR) cmd = "echo 0 | sudo tee /proc/sys/kernel/randomize_va_space" self.server.send_command(cmd) self.client.send_command(cmd) if not self._is_dpdk_setup("client"): cmd = "sudo ifup eth1" LOG.debug("Executing command: %s", cmd) self.client.send_command(cmd) time.sleep(1) self.source_ipaddr[1] = utils.get_port_ip(self.client, 'eth1') self.client.run("tee ~/.pktgen-dpdk.ipaddr.eth1 > /dev/null", stdin=self.source_ipaddr[1]) else: cmd = "cat ~/.pktgen-dpdk.ipaddr.eth1" status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) self.source_ipaddr[1] = stdout if not self._is_dpdk_setup("server"): cmd = "sudo ifup eth1" LOG.debug("Executing command: %s", cmd) self.server.send_command(cmd) time.sleep(1) self.target_ipaddr[1] = utils.get_port_ip(self.server, 'eth1') self.target_macaddr[1] = utils.get_port_mac(self.server, 'eth1') self.server.run("tee ~/.testpmd.ipaddr.eth1 > /dev/null", stdin=self.target_ipaddr[1]) self.server.run("tee ~/.testpmd.macaddr.eth1 > /dev/null", stdin=self.target_macaddr[1]) cmd = "screen sudo -E bash ~/testpmd_rev.sh" LOG.debug("Executing command: %s", cmd) self.server.send_command(cmd) time.sleep(1) else: cmd = "cat ~/.testpmd.ipaddr.eth1" status, stdout, stderr = self.server.execute(cmd) if status: raise RuntimeError(stderr) self.target_ipaddr[1] = stdout cmd = "cat ~/.testpmd.macaddr.eth1" status, stdout, stderr = self.server.execute(cmd) if status: raise RuntimeError(stderr) self.target_macaddr[1] = stdout self.dpdk_setup_done = True
def test_pktgen_dpdk_successful_get_port_ip(self): args = { 'options': {'packetsize': 60}, } p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx) p.server = self.mock_ssh.SSH.from_node() self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '') utils.get_port_ip(p.server, "eth1") self.mock_ssh.SSH.from_node().execute.assert_called_with( "ifconfig eth1 |grep 'inet addr' |awk '{print $2}' |cut -d ':' -f2 ")
def run(self, result): """execute the benchmark""" options = self.scenario_cfg['options'] eth1 = options.get("eth1", "ens4") eth2 = options.get("eth2", "ens5") if not self.setup_done: self.setup() if not self.testpmd_args: self.testpmd_args = utils.get_port_mac(self.client, eth2) if not self.pktgen_args: 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 ] packetsize = options.get("packetsize", 64) rate = options.get("rate", 100) cmd = "screen sudo -E bash ~/testpmd_fwd.sh %s %s %s" % \ (self.testpmd_args, eth1, eth2) LOG.debug("Executing command: %s", cmd) self.server.send_command(cmd) time.sleep(1) cmd = "screen sudo -E bash ~/pktgen_dpdk.sh %s %s %s %s %s %s %s %s" % \ (self.pktgen_args[0], self.pktgen_args[1], self.pktgen_args[2], self.pktgen_args[3], rate, packetsize, eth1, eth2) LOG.debug("Executing command: %s", cmd) self.client.send_command(cmd) # wait for finishing test time.sleep(60) 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: raise RuntimeError(client_stderr) avg_latency = 0 if client_stdout: latency_list = client_stdout.split('\n')[0:-2] LOG.info("10 samples of latency: %s", latency_list) latency_sum = 0 for i in latency_list: latency_sum += int(i) avg_latency = latency_sum / len(latency_list) result.update({"avg_latency": avg_latency}) if avg_latency and "sla" in self.scenario_cfg: sla_max_latency = int(self.scenario_cfg["sla"]["max_latency"]) LOG.info("avg_latency : %d ", avg_latency) LOG.info("sla_max_latency: %d", sla_max_latency) debug_info = "avg_latency %d > sla_max_latency %d" \ % (avg_latency, sla_max_latency) assert avg_latency <= sla_max_latency, debug_info
def forward_setup(self): """forward tool setup""" # setup forward loopback in VM self.testpmd_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', self.TESTPMD_SCRIPT) self.client._put_file_shell(self.testpmd_script, '~/testpmd_vsperf.sh') # disable Address Space Layout Randomization (ASLR) cmd = "echo 0 | sudo tee /proc/sys/kernel/randomize_va_space" self.client.send_command(cmd) if not self._is_forward_setup(): self.tgen_port1_ip = \ utils.get_port_ip(self.client, self.tg_port1) self.tgen_port1_mac = \ utils.get_port_mac(self.client, self.tg_port1) self.client.run("tee ~/.testpmd.ipaddr.port1 > /dev/null", stdin=self.tgen_port1_ip) self.client.run("tee ~/.testpmd.macaddr.port1 > /dev/null", stdin=self.tgen_port1_mac) self.tgen_port2_ip = \ utils.get_port_ip(self.client, self.tg_port2) self.tgen_port2_mac = \ utils.get_port_mac(self.client, self.tg_port2) self.client.run("tee ~/.testpmd.ipaddr.port2 > /dev/null", stdin=self.tgen_port2_ip) self.client.run("tee ~/.testpmd.macaddr.port2 > /dev/null", stdin=self.tgen_port2_mac) else: cmd = "cat ~/.testpmd.macaddr.port1" status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) self.tgen_port1_mac = stdout cmd = "cat ~/.testpmd.ipaddr.port1" status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) self.tgen_port1_ip = stdout cmd = "cat ~/.testpmd.macaddr.port2" status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) self.tgen_port2_mac = stdout cmd = "cat ~/.testpmd.ipaddr.port2" status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) self.tgen_port2_ip = stdout LOG.info("forward type is %s", self.forward_type) if self.forward_type == 'testpmd': cmd = "sudo ip link set %s down" % (self.tg_port1) LOG.debug("Executing command: %s", cmd) self.client.execute(cmd) cmd = "sudo ip link set %s down" % (self.tg_port2) LOG.debug("Executing command: %s", cmd) self.client.execute(cmd) cmd = "screen -d -m sudo -E bash ~/testpmd_vsperf.sh %s %s %d" % \ (self.moongen_port1_mac, self.moongen_port2_mac, self.testpmd_queue) LOG.debug("Executing command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) if status: raise RuntimeError(stderr) elif self.forward_type == 'l2fwd': cmd = ('sed -i "s/static char *net1 = \\\"eth1\\\";' '/static char *net1 = \\\"%s %s %s\\\";/g" /home/l2fwd/l2fwd.c' % (self.tg_port1, self.tgen_port1_ip, self.moongen_port1_mac)) LOG.debug("Executing command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) cmd = ('sed -i "s/static char *net2 = \\\"eth2\\\";' '/static char *net2 = \\\"%s %s %s\\\";/g" /home/l2fwd/l2fwd.c' % (self.tg_port2, self.tgen_port2_ip, self.moongen_port2_mac)) LOG.debug("Executing command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) cmd = ('cd /home/l2fwd/;make;./gen_debian_package.sh;' 'sudo dpkg -i *.deb;' 'sudo modprobe l2fwd') LOG.debug("Executing command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) time.sleep(1) self.forward_setup_done = True