test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Tu, Lijuan" <lijuan.tu@intel.com>
To: "Wu, ChangqingX" <changqingx.wu@intel.com>,
	"dts@dpdk.org" <dts@dpdk.org>
Cc: "Wu, ChangqingX" <changqingx.wu@intel.com>
Subject: Re: [dts] [PATCH V1] tests:add test suite about loadbalancer
Date: Thu, 14 Mar 2019 08:30:04 +0000	[thread overview]
Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BA42C89@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1551752793-18508-1-git-send-email-changqingx.wu@intel.com>

Comments inline

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of changqingxwu
> Sent: Tuesday, March 5, 2019 10:27 AM
> To: dts@dpdk.org
> Cc: Wu, ChangqingX <changqingx.wu@intel.com>
> Subject: [dts] [PATCH V1] tests:add test suite about loadbalancer
> 
> Signed-off-by: changqingxwu <changqingx.wu@intel.com>
> ---
>  tests/TestSuite_loadbalancer.py | 104 ++++++++++++++++++++++++++++++++
>  1 file changed, 104 insertions(+)
>  create mode 100644 tests/TestSuite_loadbalancer.py
> 
> diff --git a/tests/TestSuite_loadbalancer.py b/tests/TestSuite_loadbalancer.py
> new file mode 100644 index 0000000..620dbdc
> --- /dev/null
> +++ b/tests/TestSuite_loadbalancer.py
> @@ -0,0 +1,104 @@
> +# <COPYRIGHT_TAG>
> +
> +"""
> +DPDK Test suite.
> +
> +Test Load Balancer.
> +
> +"""
> +
> +import dts
> +from packet import Packet
> +from test_case import TestCase
> +import time
> +
> +
> +class TestLoadbalancer(TestCase):
> +
> +    def set_up_all(self):
> +        """
> +        Run at the start of each test suite.
> +
> +        Load Balancer prerequisites.
> +        """
> +        # Verify that enough ports are available
> +        global dutPorts
> +        # Based on h/w type, choose how many ports to use
> +        dutPorts = self.dut.get_ports(self.nic)
> +
> +        # Verify that enough ports are available
> +        self.verify(len(dutPorts) >= 4, "Insufficient ports for
> + testing")
> +
> +        global P0, P1, P2, P3, trafficFlow
> +        P0 = self.tester.get_local_port(dutPorts[0])
> +        P1 = self.tester.get_local_port(dutPorts[1])
> +        P2 = self.tester.get_local_port(dutPorts[2])
> +        P3 = self.tester.get_local_port(dutPorts[3])
> + P0, P1, P2, P3 are not easily readable
> +        trafficFlow = {
> +            "F1": [P0, "1.0.0.1"],
> +            "F2": [P1, "1.0.1.1"],
> +            "F3": [P2, "1.0.2.1"],
> +            "F4": [P3, "1.0.3.1"],
> +        }
> +
> +        out = self.dut.send_expect("make -C examples/load_balancer", "#")
> +        self.verify("Error" not in out, "compilation error 1")
> +        self.verify("No such file" not in out, "compilation error 2")
> +
> +    def set_up(self):
> +        """
> +        Run before each test case.
> +        """
> +        pass
> +
> +    def test_load_balancer(self):
> +        """
> +        Verify Load Balancer run successfully
> +        """
> +        cmd = './examples/load_balancer/build/load_balancer -l 3-7 -n 4 -- --rx
> "(0,0,3),(1,0,3),(2,0,3),(3,0,3)" ' \
> +              '--tx "(0,3),(1,3),(2,3),(3,3)" --w "4,5,6,7" ' \
> +              '--lpm "1.0.0.0/24=>0;1.0.1.0/24=>1;1.0.2.0/24=>2;1.0.3.0/24=>3;' \
> +              '" --bsz "(10, 10), (10, 10), (10, 10)" --pos-lb 29'
[Lijuan] It's better to make you code suite for generic platform , so suggest you get cores form API.
> +
> +        self.dut.send_expect(cmd, 'main loop.')
> +
> +        for flow in trafficFlow.keys():
> +            rx_port = trafficFlow[flow][0]
> +
> +            for i in range(len(dutPorts)):
> +                dstport = self.tester.get_local_port(dutPorts[i])
> +                pkt_count = 10
> +                inst =
> + self.tester.tcpdump_sniff_packets(intf=self.tester.get_interface(rx_po
> + rt), timeout=10, count=pkt_count)
> +
> +                pkt = Packet()
> +                dst_mac = self.dut.get_mac_address(dutPorts[rx_port-5])
> +                pkt.config_layer('ether', {'dst': dst_mac})
> +                pkt.config_layer('ipv4', {'src': "0.0.0.0", 'dst': trafficFlow[flow][1]})
> +                pkt.send_pkt(tx_port=self.tester.get_interface(dstport), count=10)
> +                time.sleep(5)  # Wait for the sniffer to finish.
> +
> +                pkts = self.tester.load_tcpdump_sniff_packets(inst)
> +                len_pkts = len(pkts)
> +
> +                if len_pkts == pkt_count:
> +                    result = str([pkts[i].pktgen.pkt.show for i in range(len_pkts)])
> +                    self.verify("Ether" in result, "No packet received")
> +                    self.verify("src=0.0.0.0" + " dst=" + trafficFlow[flow][1] in result,
> "Wrong IP address")
> +                    self.verify("dst=%s" % dst_mac in result, "Recive wrong packet")
[Lijuan] typo: Recive -> Received.
> +                else:
> +                    self.verify("dst=01:00" not in dst_mac, "Packet
> + arrived on an unexpected port")
[Lijuan] Maybe packet missed
> +
> +        self.dut.send_expect("^C", "#")
[Lijuan] if exception happened, how to reach here. The application may be alive while test suite finished.
> +
> +    def tear_down(self):
> +        """
> +        Run after each test case.
> +        """
> +        pass
> +
> +    def tear_down_all(self):
> +        """
> +        Run after each test suite.
> +        """
> +        pass
> --
> 2.17.2


      reply	other threads:[~2019-03-14  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05  2:26 changqingxwu
2019-03-14  8:30 ` Tu, Lijuan [this message]

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=8CE3E05A3F976642AAB0F4675D0AD20E0BA42C89@SHSMSX101.ccr.corp.intel.com \
    --to=lijuan.tu@intel.com \
    --cc=changqingx.wu@intel.com \
    --cc=dts@dpdk.org \
    /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).