test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Fu, Qi" <qi.fu@intel.com>
To: "Min, JiaqiX" <jiaqix.min@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Cc: "Min, JiaqiX" <jiaqix.min@intel.com>
Subject: Re: [dts] [PATCH V2] tests/shutdown_api: update change linkspeed
Date: Wed, 26 Feb 2020 01:53:47 +0000	[thread overview]
Message-ID: <122BE83F39B639498C1565A7B0CDA2200352A569@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20200225093944.60115-1-jiaqix.min@intel.com>

Acked by Fu, Qi <qi.fu@intel.com>

Best regards,
Fu, Qi

> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of Jiaqi Min
> Sent: Tuesday, February 25, 2020 5:40 PM
> To: dts@dpdk.org
> Cc: Min, JiaqiX <jiaqix.min@intel.com>
> Subject: [dts] [PATCH V2] tests/shutdown_api: update change linkspeed
> 
> update change linkspeed case
> add change linkspeed vf case
> add shutdown_api.cfg
> 
> Signed-off-by: Jiaqi Min <jiaqix.min@intel.com>
> ---
>  conf/shutdown_api.cfg           |  44 +++++++
>  tests/TestSuite_shutdown_api.py | 206 ++++++++++++++++++++++++++++++--
>  2 files changed, 239 insertions(+), 11 deletions(-)  create mode 100644
> conf/shutdown_api.cfg
> 
> diff --git a/conf/shutdown_api.cfg b/conf/shutdown_api.cfg new file mode
> 100644 index 0000000..2787adb
> --- /dev/null
> +++ b/conf/shutdown_api.cfg
> @@ -0,0 +1,44 @@
> +# Configuration: shutdown_api.cfg
> +[vm0]
> +cpu =
> +    model=host,number=4,cpupin=5 6 7 8; disk =
> +
> +file=/storage/vm-image/vm0.img,opt_format=qcow2,opt_if=virtio,opt_index
> +=0,opt_media=disk;
> +mem =
> +    size=10250;
> +login =
> +    user=root,password=tester;
> +# net option is not necessary for libvirt, comment out below 2 lines if
> +using libvirt net =
> +    type=nic,opt_vlan=0;
> +    type=user,opt_vlan=0;
> +qga =
> +    enable=yes;
> +# vnc option is not supported by libvirt yet, comment out below 2 lines
> +if using libvirt vnc =
> +    displayNum=1;
> +# daemon option is not supported by libvirt yet, comment out below 2
> +lines if using libvirt daemon =
> +    enable=yes;
> +
> +[vm1]
> +cpu =
> +    model=host,number=4,cpupin=14 15 16 17; disk =
> +
> +file=/storage/vm-image/vm0.img_copy.img,opt_format=qcow2,opt_if=virtio,
> +opt_index=0,opt_media=disk;
> +mem =
> +    size=10250;
> +login =
> +    user=root,password=tester;
> +# net option is not necessary for libvirt, comment out below 2 lines if
> +using libvirt net =
> +    type=nic,opt_vlan=0;
> +    type=user,opt_vlan=0;
> +qga =
> +    enable=yes;
> +# vnc option is not supported by libvirt yet, comment out below 2 lines
> +if using libvirt vnc =
> +    displayNum=2;
> +# daemon option is not supported by libvirt yet, comment out below 2
> +lines if using libvirt daemon =
> +    enable=yes;
> diff --git a/tests/TestSuite_shutdown_api.py b/tests/TestSuite_shutdown_api.py
> index 03a7e86..11d451b 100644
> --- a/tests/TestSuite_shutdown_api.py
> +++ b/tests/TestSuite_shutdown_api.py
> @@ -44,6 +44,8 @@ from test_case import TestCase  from pmd_output import
> PmdOutput  from settings import HEADER_SIZE, PROTOCOL_PACKET_SIZE  from
> exception import VerifyFailure
> +from qemu_kvm import QEMUKvm
> +from settings import get_nic_name
> 
>  #
>  #
> @@ -51,6 +53,7 @@ from exception import VerifyFailure  #
> 
> 
> +VM_CORES_MASK = 'all'
>  class TestShutdownApi(TestCase):
> 
>      #
> @@ -58,7 +61,7 @@ class TestShutdownApi(TestCase):
>      #
>      # Test cases.
>      #
> -
> +    supported_vf_driver = ['pci-stub', 'vfio-pci']
>      def set_up_all(self):
>          """
>          Run at the start of each test suite.
> @@ -73,6 +76,7 @@ class TestShutdownApi(TestCase):
>                  self.tester.get_interface(self.tester.get_local_port(port)), 5000), "# ")
> 
>          self.pmdout = PmdOutput(self.dut)
> +        self.vm_env_done = False
> 
>      def get_stats(self, portid):
>          """
> @@ -187,6 +191,130 @@ class TestShutdownApi(TestCase):
>          """
>          pass
> 
> +    def check_linkspeed_config(self, configs):
> +        ret_val = False
> +        if (configs == None):
> +            self.verify(False, "Link speed config error.")
> +            ret_val = False
> +        elif (len(configs) < 1):
> +            self.verify(False, "Link speed config error.")
> +            ret_val = False
> +        elif len(configs) < 2:
> +            print("\nOnly one link speed, can't be changed.\n")
> +            ret_val = False
> +        else:
> +            ret_val = True
> +
> +        return ret_val
> +
> +    def check_vf_link_status(self):
> +        self.dut_testpmd.start_testpmd("Default", "--port-topology=chained")
> +        self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-
> topology=chained')
> +        for i in range(10):
> +            out = self.vm0_testpmd.execute_cmd('show port info 0')
> +            print(out)
> +            if 'Link status: down' in out:
> +                self.dut_testpmd.execute_cmd('port stop all')
> +                self.dut_testpmd.execute_cmd('port start all')
> +                time.sleep(2)
> +            else :
> +                break
> +        self.verify("Link status: up" in out, "VF link down!!!")
> +
> +    def bind_nic_driver(self, ports, driver=""):
> +        if driver == "igb_uio":
> +            for port in ports:
> +                netdev = self.dut.ports_info[port]['port']
> +                driver = netdev.get_nic_driver()
> +                if driver != 'igb_uio':
> +                    netdev.bind_driver(driver='igb_uio')
> +        else:
> +            for port in ports:
> +                netdev = self.dut.ports_info[port]['port']
> +                driver_now = netdev.get_nic_driver()
> +                if driver == "":
> +                    driver = netdev.default_driver
> +                if driver != driver_now:
> +                    netdev.bind_driver(driver=driver)
> +
> +    def setup_vm_env(self, driver='default'):
> +        """
> +        Create testing environment with 1VF generated from 1PF
> +        """
> +        if self.vm_env_done:
> +            return
> +
> +        # initialize vm
> +        self.dut_ports = self.dut.get_ports(self.nic)
> +        self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
> +        self.vm0 = None
> +
> +        # set vf assign method and vf driver
> +        self.vf_driver = self.get_suite_cfg()['vf_driver']
> +        if self.vf_driver is None:
> +            self.vf_driver = 'pci-stub'
> +        self.verify(self.vf_driver in self.supported_vf_driver, "Unspported vf driver")
> +        if self.vf_driver == 'pci-stub':
> +            self.vf_assign_method = 'pci-assign'
> +        else:
> +            self.vf_assign_method = 'vfio-pci'
> +            self.dut.send_expect('modprobe vfio-pci', '#')
> +
> +        self.bind_nic_driver(self.dut_ports[:1], driver="igb_uio")
> +        self.used_dut_port = self.dut_ports[0]
> +        tester_port = self.tester.get_local_port(self.used_dut_port)
> +        self.tester_intf = self.tester.get_interface(tester_port)
> +
> +        self.dut.generate_sriov_vfs_by_port(
> +            self.used_dut_port, 2, driver=driver)
> +        self.sriov_vfs_port = self.dut.ports_info[
> +            self.used_dut_port]['vfs_port']
> +        for port in self.sriov_vfs_port:
> +            port.bind_driver(self.vf_driver)
> +        time.sleep(1)
> +        self.dut_testpmd = PmdOutput(self.dut)
> +        self.dut_testpmd.start_testpmd(
> +            "Default", "--rxq=4 --txq=4 --port-topology=chained")
> +        self.dut_testpmd.execute_cmd("start")
> +        time.sleep(5)
> +
> +        vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> +
> +        # set up VM0 ENV
> +        self.vm0 = QEMUKvm(self.dut, 'vm0', 'shutdown_api')
> +        self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop)
> +        try:
> +            self.vm0_dut = self.vm0.start()
> +            if self.vm0_dut is None:
> +                raise Exception("Set up VM0 ENV failed!")
> +        except Exception as e:
> +            self.destroy_vm_env()
> +            raise Exception(e)
> +
> +        self.vm0_dut_ports = self.vm0_dut.get_ports('any')
> +        self.vm0_testpmd = PmdOutput(self.vm0_dut)
> +
> +        self.vm_env_done = True
> +        self.dut_testpmd.quit()
> +
> +    def destroy_vm_env(self):
> +        if not self.vm_env_done:
> +            return
> +        if getattr(self, 'vm0', None):
> +            self.vm0_dut.kill_all()
> +            self.vm0_testpmd = None
> +            self.vm0_dut_ports = None
> +            # destroy vm0
> +            self.vm0.stop()
> +            self.vm0 = 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']
> +            self.used_dut_port = None
> +
> +        self.vm_env_done = False
> +
>      def test_stop_restart(self):
>          """
>          Stop and Restar.
> @@ -306,7 +434,6 @@ class TestShutdownApi(TestCase):
>          self.dut.send_expect("start", "testpmd> ")
>          self.check_forwarding()
> 
> -
>      def test_change_linkspeed(self):
>          """
>          Change Link Speed.
> @@ -320,31 +447,32 @@ class TestShutdownApi(TestCase):
> 
>          out = self.tester.send_expect(
>              "ethtool %s" %
> self.tester.get_interface(self.tester.get_local_port(self.ports[0])), "# ")
> -        if 'fortville_spirit' == self.nic:
> -            result_scanner = r"([0-9]+)baseSR4/([A-Za-z]+)"
> -        else:
> -            result_scanner = r"([0-9]+)baseT/([A-Za-z]+)"
> +
> +        self.verify("Supports auto-negotiation: Yes" in out,
> + "Auto-negotiation not support.")
> +
> +        result_scanner = r"([0-9]+)base\S*/([A-Za-z]+)"
>          scanner = re.compile(result_scanner, re.DOTALL)
>          m = scanner.findall(out)
>          configs = m[:-int(len(m) / 2)]
> +
> +        if not self.check_linkspeed_config(configs):
> +            return;
> +
>          for config in configs:
>              print(config)
>              if self.nic in ["ironpond"]:
>                  if config[0] != '1000' or '10000':
>                      continue
> -            elif self.nic in ["fortville_eagle"]:
> -                if config[0] != '10000':
> -                    continue
>              elif self.nic in ["sagepond"]:
>                  if config[0] != '1000' and '10000':
>                      continue
>              self.dut.send_expect("port stop all", "testpmd> ", 100)
>              for port in self.ports:
>                  self.dut.send_expect("port config %d speed %s duplex %s" % (port,
> -                                                                            config[0], config[1].lower()),
> "testpmd> ")
> +                            config[0], config[1].lower()), "testpmd> ")
>              self.dut.send_expect("set fwd mac", "testpmd>")
>              self.dut.send_expect("port start all", "testpmd> ", 100)
> -            time.sleep(5)  # sleep few seconds for link stable
> +            time.sleep(8)  # sleep few seconds for link stable
> 
>              for port in self.ports:
>                  out = self.tester.send_expect( @@ -357,6 +485,61 @@ class
> TestShutdownApi(TestCase):
>              self.check_forwarding()
>              self.dut.send_expect("stop", "testpmd> ")
> 
> +    def test_change_linkspeed_vf(self):
> +        """
> +        Change Link Speed VF .
> +        """
> +        self.setup_vm_env()
> +        self.check_vf_link_status()
> +        out = self.tester.send_expect(
> +            "ethtool %s" %
> + self.tester.get_interface(self.tester.get_local_port(self.ports[0])),
> + "# ", 100)
> +
> +        self.verify("Supports auto-negotiation: Yes" in out,
> + "Auto-negotiation not support.")
> +
> +        result_scanner = r"([0-9]+)base\S*/([A-Za-z]+)"
> +        scanner = re.compile(result_scanner, re.DOTALL)
> +        m = scanner.findall(out)
> +        configs = m[:-int(len(m) / 2)]
> +
> +        if not self.check_linkspeed_config(configs):
> +            return;
> +
> +        result_linkspeed_scanner = r"Link\s*speed:\s([0-9]+)\s*Mbps"
> +        linkspeed_scanner = re.compile(result_linkspeed_scanner, re.DOTALL)
> +        result_linktype_scanner = r"Link\s*duplex:\s*(\S*)\s*-\s*duplex"
> +        linktype_scanner = re.compile(result_linktype_scanner,
> + re.DOTALL)
> +
> +        for config in configs:
> +            print(config)
> +            if self.nic in ["ironpond"]:
> +                if config[0] != '1000' or '10000':
> +                    continue
> +            elif self.nic in ["sagepond"]:
> +                if config[0] != '1000' and '10000':
> +                    continue
> +            self.dut.send_expect("port stop all", "testpmd> ", 100)
> +            for port in self.ports:
> +                self.dut.send_expect("port config %d speed %s duplex %s" % (port,
> +                                     config[0], config[1].lower()), "testpmd> ")
> +            self.dut.send_expect("set fwd mac", "testpmd>")
> +            self.dut.send_expect("port start all", "testpmd> ", 100)
> +            time.sleep(8)  # sleep few seconds for link stable
> +            # check changing VF link speed is supported or not.
> +            out = self.vm0_testpmd.execute_cmd('show port info all')
> +
> +            linkspeed = linkspeed_scanner.findall(out)
> +            linktype = linktype_scanner.findall(out)
> +
> +            self.verify(config[0] in linkspeed,
> +                        "Wrong VF speed reported by the self.tester.")
> +            self.verify(config[1].lower() == linktype[0].lower(),
> +                        "Wrong VF link type reported by the self.tester.")
> +        # quit vm
> +        self.vm0_testpmd.quit()
> +        self.dut_testpmd.quit()
> +        time.sleep(3)
> +        self.vm0_dut.kill_all()
> +
>      def test_enable_disablejumbo(self):
>          """
>          Enable/Disable Jumbo Frames.
> @@ -582,3 +765,4 @@ class TestShutdownApi(TestCase):
>          Run after each test suite.
>          """
>          self.dut.kill_all()
> +        self.destroy_vm_env()
> --
> 2.17.1


  reply	other threads:[~2020-02-26  1:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25  9:39 Jiaqi Min
2020-02-26  1:53 ` Fu, Qi [this message]
2020-02-28  1:14 ` Tu, Lijuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=122BE83F39B639498C1565A7B0CDA2200352A569@SHSMSX103.ccr.corp.intel.com \
    --to=qi.fu@intel.com \
    --cc=dts@dpdk.org \
    --cc=jiaqix.min@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).