[dts] [PATCH]tests sriov_kvm: test vlan mirror with random vlan id.

Liu, Yong yong.liu at intel.com
Tue Jun 21 10:57:01 CEST 2016


Hi Lijuan,
I failed to applied your patch, please send out new version based on 
latest master branch.

On 06/16/2016 04:13 PM, Lijuan Tu wrote:
> vlan 0 is not a validated vlan id.
> validated vlan id is between 1 to 4095
>
> Signed-off-by: Lijuan Tu <lijuanx.a.tu at intel.com>
> ---
>   tests/TestSuite_sriov_kvm.py | 57 +++++++++++++++++++++++++-------------------
>   1 file changed, 32 insertions(+), 25 deletions(-)
>
> diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py
> index cc63804..b27ad48 100644
> --- a/tests/TestSuite_sriov_kvm.py
> +++ b/tests/TestSuite_sriov_kvm.py
> @@ -11,6 +11,7 @@ Test userland 10Gb PMD.
>   import re
>   import time
>   from functools import wraps
> +import random
>   
>   import dts
>   from qemu_kvm import QEMUKvm
> @@ -19,6 +20,7 @@ from test_case import TestCase
>   from pmd_output import PmdOutput
>   FRAME_SIZE_64 = 64
>   VM_CORES_MASK = 'all'
> +MAX_VLAN = 4095
>   
>   
>   class TestSriovKvm(TestCase):
> @@ -628,6 +630,8 @@ class TestSriovKvm(TestCase):
>                   self.reset_port_mirror_rule(port, rule_id)
>   
>       def setup_two_vm_common_prerequisite(self):
> +        self.host_testpmd.execute_cmd('port stop all')
> +        self.host_testpmd.execute_cmd('port start all')
>           self.vm0_dut_ports = self.vm_dut_0.get_ports('any')
>           self.vm0_testpmd = PmdOutput(self.vm_dut_0)
>           self.vm0_testpmd.start_testpmd(VM_CORES_MASK)
> @@ -821,36 +825,39 @@ class TestSriovKvm(TestCase):
>           vlan_id = 0
>           vf_mask = '0x1'
>           packet_num = 10
> +        random_vlan = random.randint(1, MAX_VLAN - 1)
> +        vlan_ids = [0, 1, random_vlan, MAX_VLAN]
>   
> -        if self.nic.startswith('fortville'):
> -            vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask)
> -            vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0))
> -        else:
> -            self.host_testpmd.execute_cmd(
> -                'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask))
> -        rule_id = self.set_port_vlan_mirror(port_id_0, '0 dst-pool 1 on')
> +        for vlan_id in vlan_ids:
> +            if self.nic.startswith('fortville'):
> +                vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask)
> +                vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0))
> +            else:
> +                self.host_testpmd.execute_cmd(
> +                    'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask))
> +            rule_id = self.set_port_vlan_mirror(port_id_0, '%d dst-pool 1 on' % vlan_id)
>   
> -        vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
> -        vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
> -        ether_ip = {}
> -        ether_ip['dot1q'] = {'vlan': '%d' % vlan_id}
> -        self.send_packet(
> -            self.vm_dut_0,
> -            self.vm0_dut_ports,
> -            port_id_0,
> -            count=packet_num,
> -            **ether_ip)
> -        vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
> -        vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
> +            vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
> +            vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
> +            ether_ip = {}
> +            ether_ip['dot1q'] = {'vlan': '%d' % vlan_id}
> +            self.send_packet(
> +                self.vm_dut_0,
> +                self.vm0_dut_ports,
> +                port_id_0,
> +                count=packet_num,
> +                **ether_ip)
> +            vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0)
> +            vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0)
>   
> -        vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats)
> -        vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats)
> +            vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats)
> +            vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats)
>   
> -        self.verify(vm1_ret_stats['RX-packets'] == packet_num and
> -                    vm1_ret_stats['TX-packets'] == packet_num,
> -                    "Vlan mirror failed between VM0 and VM1!")
> +            self.verify(vm1_ret_stats['RX-packets'] == packet_num and
> +                        vm1_ret_stats['TX-packets'] == packet_num,
> +                        "Vlan mirror failed between VM0 and VM1!")
>   
> -        self.reset_port_mirror_rule(port_id_0, rule_id)
> +            self.reset_port_mirror_rule(port_id_0, rule_id)
>   
>       def test_two_vms_vlan_and_pool_mirror(self):
>           self.setup_2vm_2vf_env()



More information about the dts mailing list