* [dts] [PATCH V1]tests/packet_ordering: add packet_ordering function test case
@ 2020-02-26 7:19 hanyingya
2020-03-03 5:41 ` Tu, Lijuan
0 siblings, 1 reply; 2+ messages in thread
From: hanyingya @ 2020-02-26 7:19 UTC (permalink / raw)
To: dts, zhe.wan; +Cc: hanyingya
Signed-off-by: hanyingya <yingyax.han@intel.com>
---
tests/TestSuite_packet_ordering.py | 169 +++++++++++++++++++++++++++++
1 file changed, 169 insertions(+)
create mode 100644 tests/TestSuite_packet_ordering.py
diff --git a/tests/TestSuite_packet_ordering.py b/tests/TestSuite_packet_ordering.py
new file mode 100644
index 0000000..ac6b930
--- /dev/null
+++ b/tests/TestSuite_packet_ordering.py
@@ -0,0 +1,169 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2020 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""
+DPDK Test suite.
+Packet ordering example app test cases.
+"""
+
+import os
+import time
+import utils
+from test_case import TestCase
+from packet import Packet
+
+
+class TestPacketOrdering(TestCase):
+
+ def set_up_all(self):
+ """
+ Executes the Packet Ordering prerequisites. Creates a simple scapy
+ packet to be used later on the tests. It also compiles the example app.
+ """
+ self.tester.extend_external_packet_generator(TestPacketOrdering, self)
+ self.dut_ports = self.dut.get_ports(self.nic)
+ global valports
+ valports = [_ for _ in self.dut_ports if self.tester.get_local_port(_) != -1]
+
+ # Verify that enough ports are available
+ self.verify(len(valports) >= 1, "Insufficient ports for speed testing")
+ self.port = self.tester.get_local_port(valports[0])
+
+ # get socket and cores
+ self.socket = self.dut.get_numa_id(self.dut_ports[0])
+ self.cores = self.dut.get_core_list("1S/4C/1T", socket=self.socket)
+ self.verify(self.cores is not None, "Insufficient cores for speed testing")
+
+ self.core_mask = utils.create_mask(self.cores)
+ self.port_mask = utils.create_mask(valports)
+
+ # Builds the packet ordering example app and checks for errors.
+ out = self.dut.send_expect("make -C examples/packet_ordering", "#")
+ self.verify("Error" not in out and "No such file" not in out,
+ "Compilation error")
+
+ def set_up(self):
+ """
+ Run before each test case.
+ """
+ pass
+
+ def start_application(self):
+
+ cmdline = './examples/packet_ordering/build/packet_ordering -c {0} -n {1} -- -p {2}' . \
+ format(self.core_mask, self.dut.get_memory_channels(), self.port_mask)
+ # Executes the packet ordering example app.
+ self.dut.send_expect(cmdline, 'REORDERAPP', 120)
+
+ def remove_dhcp_from_revpackets(self, inst, timeout=3):
+
+ pkts = self.tester.load_tcpdump_sniff_packets(inst, timeout)
+ i = 0
+ while len(pkts) != 0 and i <= len(pkts) - 1:
+ if pkts[i].pktgen.pkt.haslayer('DHCP'):
+ pkts.remove(pkts[i])
+ i = i - 1
+ i = i + 1
+ return pkts
+
+ def send_ordered_packet(self):
+ """
+ send the packets with ordered of src-ip info.
+ compose the pcap file, each queue has same 5 tuple and diff load info
+ """
+
+ pkt = Packet()
+ src_ip = "11.12.13.1"
+ pay_load = "000001"
+ packet_num = 1000
+ smac = "00:00:00:00:00:00"
+ rx_interface = self.tester.get_interface(self.port)
+ tx_interface = rx_interface
+ for _port in valports:
+ index = valports[_port]
+ dmac = self.dut.get_mac_address(index)
+ config_opt = [('ether', {'dst': dmac, 'src': smac}),
+ ('ipv4', {'src': src_ip, 'dst': '11.12.1.1'}),
+ ('udp', {'src': 123, 'dst': 12})]
+ pkt.generate_random_pkts(pktnum=packet_num, random_type=['UDP'], ip_increase=False,
+ random_payload=False, options={'layers_config': config_opt})
+ # config raw info in pkts
+ for i in range(packet_num):
+ payload = "0000%.3d" % (i + 1)
+ pkt.pktgen.pkts[i + packet_num * _port]['Raw'].load = payload
+
+ filt = [{'layer': 'ether', 'config': {'src': '%s' % smac}}]
+ inst = self.tester.tcpdump_sniff_packets(rx_interface, filters=filt)
+ pkt.send_pkt(crb=self.tester, tx_port=tx_interface, timeout=300)
+ self.pkts = self.remove_dhcp_from_revpackets(inst)
+
+ def check_packet_order(self):
+ """
+ observe the packets sended by scapy, check the packets order
+ """
+
+ for _port in valports:
+ src_ip = "11.12.13.%d" % (_port + 1)
+ packet_index = 0
+ for i in range(len(self.pkts)):
+ pay_load = "0000%.2d" % packet_index
+ if self.pkts[i]['IP'].src == src_ip:
+ print(self.pkts[i].show)
+ if packet_index == 0:
+ packet_index = int(self.pkts[i]['Raw'].load[-2:])
+ pay_load = "0000%.2d" % packet_index
+ self.verify(self.pkts[i]['Raw'].load == pay_load, "The packets not ordered")
+ packet_index = packet_index + 1
+
+ def test_keep_packet_oeder(self):
+ """
+ keep the packets order with one ordered stage in single-flow and multi-flow
+ according to the tcpdump may be capture the packets whitch not belong current
+ flow, so set different src_mac of flow to identify the packets
+ """
+ self.start_application()
+ # send packets
+ self.send_ordered_packet()
+ # check packet ordering
+ self.check_packet_order()
+ self.dut.send_expect("^c", "#", 10)
+
+ def tear_down(self):
+ """
+ Run after each test case.
+ """
+ self.dut.kill_all()
+
+ def tear_down_all(self):
+ """
+ Run after each test suite.
+ """
+ pass
--
2.17.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [PATCH V1]tests/packet_ordering: add packet_ordering function test case
2020-02-26 7:19 [dts] [PATCH V1]tests/packet_ordering: add packet_ordering function test case hanyingya
@ 2020-03-03 5:41 ` Tu, Lijuan
0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2020-03-03 5:41 UTC (permalink / raw)
To: Han, YingyaX, dts, Wan, Zhe; +Cc: Han, YingyaX
Applied, thanks
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of hanyingya
> Sent: Wednesday, February 26, 2020 3:19 PM
> To: dts@dpdk.org; Wan, Zhe <zhe.wan@intel.com>
> Cc: Han, YingyaX <yingyax.han@intel.com>
> Subject: [dts] [PATCH V1]tests/packet_ordering: add packet_ordering
> function test case
>
> Signed-off-by: hanyingya <yingyax.han@intel.com>
> ---
> tests/TestSuite_packet_ordering.py | 169 +++++++++++++++++++++++++++++
> 1 file changed, 169 insertions(+)
> create mode 100644 tests/TestSuite_packet_ordering.py
>
> diff --git a/tests/TestSuite_packet_ordering.py
> b/tests/TestSuite_packet_ordering.py
> new file mode 100644
> index 0000000..ac6b930
> --- /dev/null
> +++ b/tests/TestSuite_packet_ordering.py
> @@ -0,0 +1,169 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) 2010-2020 Intel Corporation. All rights reserved.
> +# All rights reserved.
> +#
> +# Redistribution and use in source and binary forms, with or without #
> +modification, are permitted provided that the following conditions #
> +are met:
> +#
> +# * Redistributions of source code must retain the above copyright
> +# notice, this list of conditions and the following disclaimer.
> +# * Redistributions in binary form must reproduce the above copyright
> +# notice, this list of conditions and the following disclaimer in
> +# the documentation and/or other materials provided with the
> +# distribution.
> +# * Neither the name of Intel Corporation nor the names of its
> +# contributors may be used to endorse or promote products derived
> +# from this software without specific prior written permission.
> +#
> +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> CONTRIBUTORS #
> +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> #
> +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
> FOR #
> +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> COPYRIGHT #
> +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> INCIDENTAL, #
> +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> NOT #
> +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> USE, #
> +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> ON ANY #
> +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> #
> +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
> THE USE #
> +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
> DAMAGE.
> +
> +"""
> +DPDK Test suite.
> +Packet ordering example app test cases.
> +"""
> +
> +import os
> +import time
> +import utils
> +from test_case import TestCase
> +from packet import Packet
> +
> +
> +class TestPacketOrdering(TestCase):
> +
> + def set_up_all(self):
> + """
> + Executes the Packet Ordering prerequisites. Creates a simple scapy
> + packet to be used later on the tests. It also compiles the example app.
> + """
> + self.tester.extend_external_packet_generator(TestPacketOrdering, self)
> + self.dut_ports = self.dut.get_ports(self.nic)
> + global valports
> + valports = [_ for _ in self.dut_ports if
> + self.tester.get_local_port(_) != -1]
> +
> + # Verify that enough ports are available
> + self.verify(len(valports) >= 1, "Insufficient ports for speed testing")
> + self.port = self.tester.get_local_port(valports[0])
> +
> + # get socket and cores
> + self.socket = self.dut.get_numa_id(self.dut_ports[0])
> + self.cores = self.dut.get_core_list("1S/4C/1T", socket=self.socket)
> + self.verify(self.cores is not None, "Insufficient cores for
> + speed testing")
> +
> + self.core_mask = utils.create_mask(self.cores)
> + self.port_mask = utils.create_mask(valports)
> +
> + # Builds the packet ordering example app and checks for errors.
> + out = self.dut.send_expect("make -C examples/packet_ordering", "#")
> + self.verify("Error" not in out and "No such file" not in out,
> + "Compilation error")
> +
> + def set_up(self):
> + """
> + Run before each test case.
> + """
> + pass
> +
> + def start_application(self):
> +
> + cmdline = './examples/packet_ordering/build/packet_ordering -c {0} -n
> {1} -- -p {2}' . \
> + format(self.core_mask, self.dut.get_memory_channels(),
> self.port_mask)
> + # Executes the packet ordering example app.
> + self.dut.send_expect(cmdline, 'REORDERAPP', 120)
> +
> + def remove_dhcp_from_revpackets(self, inst, timeout=3):
> +
> + pkts = self.tester.load_tcpdump_sniff_packets(inst, timeout)
> + i = 0
> + while len(pkts) != 0 and i <= len(pkts) - 1:
> + if pkts[i].pktgen.pkt.haslayer('DHCP'):
> + pkts.remove(pkts[i])
> + i = i - 1
> + i = i + 1
> + return pkts
> +
> + def send_ordered_packet(self):
> + """
> + send the packets with ordered of src-ip info.
> + compose the pcap file, each queue has same 5 tuple and diff load info
> + """
> +
> + pkt = Packet()
> + src_ip = "11.12.13.1"
> + pay_load = "000001"
> + packet_num = 1000
> + smac = "00:00:00:00:00:00"
> + rx_interface = self.tester.get_interface(self.port)
> + tx_interface = rx_interface
> + for _port in valports:
> + index = valports[_port]
> + dmac = self.dut.get_mac_address(index)
> + config_opt = [('ether', {'dst': dmac, 'src': smac}),
> + ('ipv4', {'src': src_ip, 'dst': '11.12.1.1'}),
> + ('udp', {'src': 123, 'dst': 12})]
> + pkt.generate_random_pkts(pktnum=packet_num,
> random_type=['UDP'], ip_increase=False,
> + random_payload=False, options={'layers_config':
> config_opt})
> + # config raw info in pkts
> + for i in range(packet_num):
> + payload = "0000%.3d" % (i + 1)
> + pkt.pktgen.pkts[i + packet_num * _port]['Raw'].load =
> + payload
> +
> + filt = [{'layer': 'ether', 'config': {'src': '%s' % smac}}]
> + inst = self.tester.tcpdump_sniff_packets(rx_interface, filters=filt)
> + pkt.send_pkt(crb=self.tester, tx_port=tx_interface, timeout=300)
> + self.pkts = self.remove_dhcp_from_revpackets(inst)
> +
> + def check_packet_order(self):
> + """
> + observe the packets sended by scapy, check the packets order
> + """
> +
> + for _port in valports:
> + src_ip = "11.12.13.%d" % (_port + 1)
> + packet_index = 0
> + for i in range(len(self.pkts)):
> + pay_load = "0000%.2d" % packet_index
> + if self.pkts[i]['IP'].src == src_ip:
> + print(self.pkts[i].show)
> + if packet_index == 0:
> + packet_index = int(self.pkts[i]['Raw'].load[-2:])
> + pay_load = "0000%.2d" % packet_index
> + self.verify(self.pkts[i]['Raw'].load == pay_load, "The packets not
> ordered")
> + packet_index = packet_index + 1
> +
> + def test_keep_packet_oeder(self):
> + """
> + keep the packets order with one ordered stage in single-flow and multi-
> flow
> + according to the tcpdump may be capture the packets whitch not
> belong current
> + flow, so set different src_mac of flow to identify the packets
> + """
> + self.start_application()
> + # send packets
> + self.send_ordered_packet()
> + # check packet ordering
> + self.check_packet_order()
> + self.dut.send_expect("^c", "#", 10)
> +
> + def tear_down(self):
> + """
> + Run after each test case.
> + """
> + self.dut.kill_all()
> +
> + def tear_down_all(self):
> + """
> + Run after each test suite.
> + """
> + pass
> --
> 2.17.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-03 5:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 7:19 [dts] [PATCH V1]tests/packet_ordering: add packet_ordering function test case hanyingya
2020-03-03 5:41 ` Tu, Lijuan
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).