* [dts] [V2] [PATCH] tests: add vf reset test case
@ 2016-01-13 9:02 Yulong Pei
2016-01-19 3:25 ` Liu, Yong
0 siblings, 1 reply; 2+ messages in thread
From: Yulong Pei @ 2016-01-13 9:02 UTC (permalink / raw)
To: dts
create three vfs from one pf, passthrough to two VMs, reset one vf 1000 times,
and check if other two vfs can works well or not.
Signed-off-by: Yulong Pei <yulong.pei@intel.com>
---
conf/vf_packet_rxtx.cfg | 19 +++++
framework/tester.py | 25 +++++++
tests/TestSuite_vf_packet_rxtx.py | 150 +++++++++++++++++++++++++++++++++++++-
3 files changed, 191 insertions(+), 3 deletions(-)
diff --git a/conf/vf_packet_rxtx.cfg b/conf/vf_packet_rxtx.cfg
index 986d289..20db90c 100644
--- a/conf/vf_packet_rxtx.cfg
+++ b/conf/vf_packet_rxtx.cfg
@@ -103,3 +103,22 @@ vnc =
displayNum=1;
daemon =
enable=yes;
+
+[vm1]
+cpu =
+ model=host,number=4,cpupin=9 10 11 12;
+disk =
+ file=/home/image/sriov-fc20-2.img;
+login =
+ user=root,password=tester;
+net =
+ type=nic,opt_vlan=1;
+ type=user,opt_vlan=1;
+monitor =
+ port=;
+qga =
+ enable=yes;
+vnc =
+ displayNum=2;
+daemon =
+ enable=yes;
diff --git a/framework/tester.py b/framework/tester.py
index c8cebd6..151e0d1 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -34,6 +34,7 @@ Interface for bulk traffic generators.
"""
import re
+import subprocess
from time import sleep
from settings import NICS
from crb import Crb
@@ -540,6 +541,30 @@ class Tester(Crb):
instance.__dict__ = self.ixia_packet_gen.__dict__
instance.__dict__.update(current_attrs)
+ def sendpkt_bg(self, localPort, dst_mac):
+ """
+ loop to Send packet in background, should call stop_sendpkt_bg to stop it.
+ """
+ itf = self.get_interface(localPort)
+ src_mac = self.get_mac(localPort)
+ script_str = "from scapy.all import *\n" + \
+ "sendp([Ether(dst='%s', src='%s')/IP(len=46)], iface='%s', loop=1)\n" % (dst_mac, src_mac, itf)
+
+ self.send_expect("rm -fr send_pkg_loop.py", "# ")
+ f = open("send_pkt_loop.py", "w")
+ f.write(script_str)
+ f.close()
+
+ self.proc = subprocess.Popen(['python', 'send_pkt_loop.py'])
+
+ def stop_sendpkt_bg(self):
+ """
+ stop send_pkt_loop in background
+ """
+ if self.proc:
+ self.proc.kill()
+ self.proc = None
+
def kill_all(self, killall=False):
"""
Kill all scapy process or DPDK application on tester.
diff --git a/tests/TestSuite_vf_packet_rxtx.py b/tests/TestSuite_vf_packet_rxtx.py
index 19bc331..bfa7526 100644
--- a/tests/TestSuite_vf_packet_rxtx.py
+++ b/tests/TestSuite_vf_packet_rxtx.py
@@ -18,10 +18,12 @@ class TestVfPacketRxtx(TestCase):
self.dut_ports = self.dut.get_ports(self.nic)
self.verify(len(self.dut_ports) > 1, "Insufficient ports")
self.vm0 = None
+ self.vm1 = None
def set_up(self):
self.setup_2pf_2vf_1vm_env_flag = 0
+ self.setup_3vf_2vm_env_flag = 0
def setup_2pf_2vf_1vm_env(self, driver='default'):
@@ -98,16 +100,14 @@ class TestVfPacketRxtx(TestCase):
self.setup_2pf_2vf_1vm_env_flag = 0
-######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm scenario
+######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm scenario packet rx tx.
def test_kernel_2pf_2vf_1vm(self):
self.setup_2pf_2vf_1vm_env(driver='')
self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
-
port_id_0 = 0
-
self.vm0_testpmd = PmdOutput(self.vm_dut_0)
self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
self.vm0_testpmd.execute_cmd('show port info all')
@@ -130,16 +130,160 @@ class TestVfPacketRxtx(TestCase):
result = self.tester.check_random_pkts(tgen_ports, allow_miss=False, params=pkt_param)
self.verify(result != False, "VF0 failed to forward packets to VF1")
+ def setup_3vf_2vm_env(self, driver='default'):
+
+ self.used_dut_port = self.dut_ports[0]
+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 3, driver=driver)
+ self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
+
+ try:
+
+ for port in self.sriov_vfs_port:
+ print port.pci
+ port.bind_driver('pci-stub')
+
+ time.sleep(1)
+ vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
+ vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
+ vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
+
+ for port_id in self.dut_ports:
+ if port_id == self.used_dut_port:
+ continue
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ if driver == 'igb_uio':
+ self.host_testpmd = PmdOutput(self.dut)
+ eal_param = '-b %(vf0)s -b %(vf1)s -b %(vf2)s' % {'vf0': self.sriov_vfs_port[0].pci,
+ 'vf1': self.sriov_vfs_port[1].pci,
+ 'vf2': self.sriov_vfs_port[2].pci}
+ self.host_testpmd.start_testpmd("1S/2C/2T", eal_param=eal_param)
+
+ # set up VM0 ENV
+ self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_packet_rxtx')
+ self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
+ self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
+ self.vm_dut_0 = self.vm0.start()
+ if self.vm_dut_0 is None:
+ raise Exception("Set up VM0 ENV failed!")
+ # set up VM1 ENV
+ self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_packet_rxtx')
+ self.vm1.set_vm_device(driver='pci-assign', **vf2_prop)
+ self.vm_dut_1 = self.vm1.start()
+ if self.vm_dut_1 is None:
+ raise Exception("Set up VM1 ENV failed!")
+
+ self.setup_3vf_2vm_env_flag = 1
+ except Exception as e:
+ self.destroy_3vf_2vm_env()
+ raise Exception(e)
+
+ def destroy_3vf_2vm_env(self):
+ if getattr(self, 'vm0', None):
+ self.vm0_testpmd.execute_cmd('stop')
+ self.vm0_testpmd.execute_cmd('quit', '# ')
+ self.vm0_testpmd = None
+ self.vm0_dut_ports = None
+ self.vm_dut_0 = None
+ self.vm0.stop()
+ self.vm0 = None
+
+ if getattr(self, 'vm1', None):
+ self.vm1_testpmd.execute_cmd('stop')
+ self.vm1_testpmd.execute_cmd('quit', '# ')
+ self.vm1_testpmd = None
+ self.vm1_dut_ports = None
+ self.vm_dut_1 = None
+ self.vm1.stop()
+ self.vm1 = None
+
+ if getattr(self, 'host_testpmd', None):
+ self.host_testpmd.execute_cmd('quit', '# ')
+ self.host_testpmd = None
+
+ if getattr(self, 'used_dut_port', None):
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+ port = self.dut.ports_info[self.used_dut_port]['port']
+ port.bind_driver()
+ self.used_dut_port = None
+
+ for port_id in self.dut_ports:
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_3vf_2vm_env_flag = 0
+
+ def test_vf_reset(self):
+
+ self.setup_3vf_2vm_env(driver='')
+
+ self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
+ self.vm1_dut_ports = self.vm_dut_1.get_ports('any')
+
+ port_id_0 = 0
+ port_id_1 = 1
+
+ self.vm0_testpmd = PmdOutput(self.vm_dut_0)
+ self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
+ self.vm0_testpmd.execute_cmd('show port info all')
+ pmd0_vf0_mac = self.vm0_testpmd.get_port_mac(port_id_0)
+ self.vm0_testpmd.execute_cmd('set fwd mac')
+ self.vm0_testpmd.execute_cmd('start')
+
+ time.sleep(2)
+
+ self.vm1_testpmd = PmdOutput(self.vm_dut_1)
+ self.vm1_testpmd.start_testpmd(VM_CORES_MASK)
+ self.vm1_testpmd.execute_cmd('show port info all')
+
+ tx_port = self.tester.get_local_port(self.dut_ports[0])
+ rx_port = tx_port
+
+ dst_mac = pmd0_vf0_mac
+ self.tester.sendpkt_bg(tx_port, dst_mac)
+
+ #vf port stop/start can trigger reset action
+ for num in range(1000):
+ self.vm1_testpmd.execute_cmd('port stop all')
+ time.sleep(0.1)
+ self.vm1_testpmd.execute_cmd('port start all')
+ time.sleep(0.1)
+
+ self.tester.stop_sendpkt_bg()
+
+ pmd0_vf0_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
+ pmd0_vf1_stats = self.vm0_testpmd.get_pmd_stats(port_id_1)
+
+ vf0_rx_cnt = pmd0_vf0_stats['RX-packets']
+ self.verify(vf0_rx_cnt != 0, "no packet was received by vm0_VF0")
+
+ vf0_rx_err = pmd0_vf0_stats['RX-errors']
+ self.verify(vf0_rx_err == 0, "vm0_VF0 rx-errors")
+
+ vf1_tx_cnt = pmd0_vf1_stats['TX-packets']
+ self.verify(vf1_tx_cnt != 0, "no packet was transmitted by vm0_VF1")
+
+ vf1_tx_err = pmd0_vf1_stats['TX-errors']
+ self.verify(vf1_tx_err == 0, "vm0_VF0 tx-errors")
+
+ self.verify(vf0_rx_cnt == vf1_tx_cnt, "vm0_VF0 failed to forward packets to vm0_VF1 when reset vm1_VF0 frequently")
+
def tear_down(self):
if self.setup_2pf_2vf_1vm_env_flag == 1:
self.destroy_2pf_2vf_1vm_env()
+ if self.setup_3vf_2vm_env_flag == 1:
+ self.destroy_3vf_2vm_env()
def tear_down_all(self):
if getattr(self, 'vm0', None):
self.vm0.stop()
+ if getattr(self, 'vm1', None):
+ self.vm1.stop()
+
for port_id in self.dut_ports:
self.dut.destroy_sriov_vfs_by_port(port_id)
--
2.1.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [V2] [PATCH] tests: add vf reset test case
2016-01-13 9:02 [dts] [V2] [PATCH] tests: add vf reset test case Yulong Pei
@ 2016-01-19 3:25 ` Liu, Yong
0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2016-01-19 3:25 UTC (permalink / raw)
To: Yulong Pei, dts
Applied. Thanks.
On 01/13/2016 05:02 PM, Yulong Pei wrote:
> create three vfs from one pf, passthrough to two VMs, reset one vf 1000 times,
> and check if other two vfs can works well or not.
>
> Signed-off-by: Yulong Pei <yulong.pei@intel.com>
> ---
> conf/vf_packet_rxtx.cfg | 19 +++++
> framework/tester.py | 25 +++++++
> tests/TestSuite_vf_packet_rxtx.py | 150 +++++++++++++++++++++++++++++++++++++-
> 3 files changed, 191 insertions(+), 3 deletions(-)
>
> diff --git a/conf/vf_packet_rxtx.cfg b/conf/vf_packet_rxtx.cfg
> index 986d289..20db90c 100644
> --- a/conf/vf_packet_rxtx.cfg
> +++ b/conf/vf_packet_rxtx.cfg
> @@ -103,3 +103,22 @@ vnc =
> displayNum=1;
> daemon =
> enable=yes;
> +
> +[vm1]
> +cpu =
> + model=host,number=4,cpupin=9 10 11 12;
> +disk =
> + file=/home/image/sriov-fc20-2.img;
> +login =
> + user=root,password=tester;
> +net =
> + type=nic,opt_vlan=1;
> + type=user,opt_vlan=1;
> +monitor =
> + port=;
> +qga =
> + enable=yes;
> +vnc =
> + displayNum=2;
> +daemon =
> + enable=yes;
> diff --git a/framework/tester.py b/framework/tester.py
> index c8cebd6..151e0d1 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -34,6 +34,7 @@ Interface for bulk traffic generators.
> """
>
> import re
> +import subprocess
> from time import sleep
> from settings import NICS
> from crb import Crb
> @@ -540,6 +541,30 @@ class Tester(Crb):
> instance.__dict__ = self.ixia_packet_gen.__dict__
> instance.__dict__.update(current_attrs)
>
> + def sendpkt_bg(self, localPort, dst_mac):
> + """
> + loop to Send packet in background, should call stop_sendpkt_bg to stop it.
> + """
> + itf = self.get_interface(localPort)
> + src_mac = self.get_mac(localPort)
> + script_str = "from scapy.all import *\n" + \
> + "sendp([Ether(dst='%s', src='%s')/IP(len=46)], iface='%s', loop=1)\n" % (dst_mac, src_mac, itf)
> +
> + self.send_expect("rm -fr send_pkg_loop.py", "# ")
> + f = open("send_pkt_loop.py", "w")
> + f.write(script_str)
> + f.close()
> +
> + self.proc = subprocess.Popen(['python', 'send_pkt_loop.py'])
> +
> + def stop_sendpkt_bg(self):
> + """
> + stop send_pkt_loop in background
> + """
> + if self.proc:
> + self.proc.kill()
> + self.proc = None
> +
> def kill_all(self, killall=False):
> """
> Kill all scapy process or DPDK application on tester.
> diff --git a/tests/TestSuite_vf_packet_rxtx.py b/tests/TestSuite_vf_packet_rxtx.py
> index 19bc331..bfa7526 100644
> --- a/tests/TestSuite_vf_packet_rxtx.py
> +++ b/tests/TestSuite_vf_packet_rxtx.py
> @@ -18,10 +18,12 @@ class TestVfPacketRxtx(TestCase):
> self.dut_ports = self.dut.get_ports(self.nic)
> self.verify(len(self.dut_ports) > 1, "Insufficient ports")
> self.vm0 = None
> + self.vm1 = None
>
> def set_up(self):
>
> self.setup_2pf_2vf_1vm_env_flag = 0
> + self.setup_3vf_2vm_env_flag = 0
>
> def setup_2pf_2vf_1vm_env(self, driver='default'):
>
> @@ -98,16 +100,14 @@ class TestVfPacketRxtx(TestCase):
>
> self.setup_2pf_2vf_1vm_env_flag = 0
>
> -######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm scenario
> +######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm scenario packet rx tx.
>
> def test_kernel_2pf_2vf_1vm(self):
>
> self.setup_2pf_2vf_1vm_env(driver='')
>
> self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> -
> port_id_0 = 0
> -
> self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> self.vm0_testpmd.execute_cmd('show port info all')
> @@ -130,16 +130,160 @@ class TestVfPacketRxtx(TestCase):
> result = self.tester.check_random_pkts(tgen_ports, allow_miss=False, params=pkt_param)
> self.verify(result != False, "VF0 failed to forward packets to VF1")
>
> + def setup_3vf_2vm_env(self, driver='default'):
> +
> + self.used_dut_port = self.dut_ports[0]
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 3, driver=driver)
> + self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
> +
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
> + port.bind_driver('pci-stub')
> +
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> + vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
> +
> + for port_id in self.dut_ports:
> + if port_id == self.used_dut_port:
> + continue
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + if driver == 'igb_uio':
> + self.host_testpmd = PmdOutput(self.dut)
> + eal_param = '-b %(vf0)s -b %(vf1)s -b %(vf2)s' % {'vf0': self.sriov_vfs_port[0].pci,
> + 'vf1': self.sriov_vfs_port[1].pci,
> + 'vf2': self.sriov_vfs_port[2].pci}
> + self.host_testpmd.start_testpmd("1S/2C/2T", eal_param=eal_param)
> +
> + # set up VM0 ENV
> + self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_packet_rxtx')
> + self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> + self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> + self.vm_dut_0 = self.vm0.start()
> + if self.vm_dut_0 is None:
> + raise Exception("Set up VM0 ENV failed!")
> + # set up VM1 ENV
> + self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_packet_rxtx')
> + self.vm1.set_vm_device(driver='pci-assign', **vf2_prop)
> + self.vm_dut_1 = self.vm1.start()
> + if self.vm_dut_1 is None:
> + raise Exception("Set up VM1 ENV failed!")
> +
> + self.setup_3vf_2vm_env_flag = 1
> + except Exception as e:
> + self.destroy_3vf_2vm_env()
> + raise Exception(e)
> +
> + def destroy_3vf_2vm_env(self):
> + if getattr(self, 'vm0', None):
> + self.vm0_testpmd.execute_cmd('stop')
> + self.vm0_testpmd.execute_cmd('quit', '# ')
> + self.vm0_testpmd = None
> + self.vm0_dut_ports = None
> + self.vm_dut_0 = None
> + self.vm0.stop()
> + self.vm0 = None
> +
> + if getattr(self, 'vm1', None):
> + self.vm1_testpmd.execute_cmd('stop')
> + self.vm1_testpmd.execute_cmd('quit', '# ')
> + self.vm1_testpmd = None
> + self.vm1_dut_ports = None
> + self.vm_dut_1 = None
> + self.vm1.stop()
> + self.vm1 = None
> +
> + if getattr(self, 'host_testpmd', None):
> + self.host_testpmd.execute_cmd('quit', '# ')
> + self.host_testpmd = None
> +
> + if getattr(self, 'used_dut_port', None):
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_3vf_2vm_env_flag = 0
> +
> + def test_vf_reset(self):
> +
> + self.setup_3vf_2vm_env(driver='')
> +
> + self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
> + self.vm1_dut_ports = self.vm_dut_1.get_ports('any')
> +
> + port_id_0 = 0
> + port_id_1 = 1
> +
> + self.vm0_testpmd = PmdOutput(self.vm_dut_0)
> + self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> + self.vm0_testpmd.execute_cmd('show port info all')
> + pmd0_vf0_mac = self.vm0_testpmd.get_port_mac(port_id_0)
> + self.vm0_testpmd.execute_cmd('set fwd mac')
> + self.vm0_testpmd.execute_cmd('start')
> +
> + time.sleep(2)
> +
> + self.vm1_testpmd = PmdOutput(self.vm_dut_1)
> + self.vm1_testpmd.start_testpmd(VM_CORES_MASK)
> + self.vm1_testpmd.execute_cmd('show port info all')
> +
> + tx_port = self.tester.get_local_port(self.dut_ports[0])
> + rx_port = tx_port
> +
> + dst_mac = pmd0_vf0_mac
> + self.tester.sendpkt_bg(tx_port, dst_mac)
> +
> + #vf port stop/start can trigger reset action
> + for num in range(1000):
> + self.vm1_testpmd.execute_cmd('port stop all')
> + time.sleep(0.1)
> + self.vm1_testpmd.execute_cmd('port start all')
> + time.sleep(0.1)
> +
> + self.tester.stop_sendpkt_bg()
> +
> + pmd0_vf0_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
> + pmd0_vf1_stats = self.vm0_testpmd.get_pmd_stats(port_id_1)
> +
> + vf0_rx_cnt = pmd0_vf0_stats['RX-packets']
> + self.verify(vf0_rx_cnt != 0, "no packet was received by vm0_VF0")
> +
> + vf0_rx_err = pmd0_vf0_stats['RX-errors']
> + self.verify(vf0_rx_err == 0, "vm0_VF0 rx-errors")
> +
> + vf1_tx_cnt = pmd0_vf1_stats['TX-packets']
> + self.verify(vf1_tx_cnt != 0, "no packet was transmitted by vm0_VF1")
> +
> + vf1_tx_err = pmd0_vf1_stats['TX-errors']
> + self.verify(vf1_tx_err == 0, "vm0_VF0 tx-errors")
> +
> + self.verify(vf0_rx_cnt == vf1_tx_cnt, "vm0_VF0 failed to forward packets to vm0_VF1 when reset vm1_VF0 frequently")
> +
> def tear_down(self):
>
> if self.setup_2pf_2vf_1vm_env_flag == 1:
> self.destroy_2pf_2vf_1vm_env()
> + if self.setup_3vf_2vm_env_flag == 1:
> + self.destroy_3vf_2vm_env()
>
> def tear_down_all(self):
>
> if getattr(self, 'vm0', None):
> self.vm0.stop()
>
> + if getattr(self, 'vm1', None):
> + self.vm1.stop()
> +
> for port_id in self.dut_ports:
> self.dut.destroy_sriov_vfs_by_port(port_id)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-19 3:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 9:02 [dts] [V2] [PATCH] tests: add vf reset test case Yulong Pei
2016-01-19 3:25 ` Liu, Yong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).