* [dts] [PATCH V2] tests/flow_filtering complete automation of flow_filtering
@ 2019-10-30 14:41 Xiaoxiao Zeng
2019-11-04 2:55 ` Tu, Lijuan
0 siblings, 1 reply; 2+ messages in thread
From: Xiaoxiao Zeng @ 2019-10-30 14:41 UTC (permalink / raw)
To: dts; +Cc: Xiaoxiao Zeng
*.automation of flow_filtering according to the test_plan.
Signed-off-by: Xiaoxiao Zeng <xiaoxiaox.zeng@intel.com>
---
tests/TestSuite_flow_filtering.py | 110 ++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
create mode 100644 tests/TestSuite_flow_filtering.py
diff --git a/tests/TestSuite_flow_filtering.py b/tests/TestSuite_flow_filtering.py
new file mode 100644
index 0000000..242d321
--- /dev/null
+++ b/tests/TestSuite_flow_filtering.py
@@ -0,0 +1,110 @@
+# BSD LICENSE
+#
+# Copyright(c) <2019> 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.
+
+import os
+import utils
+import time
+import re
+import os
+import packet
+from test_case import TestCase
+from settings import HEADER_SIZE
+
+
+class TestFlowFiltering(TestCase):
+
+ def set_up_all(self):
+ """
+ Run before each test suite
+ """
+ # initialize ports topology
+ self.dut_ports = self.dut.get_ports(self.nic)
+ self.dts_mac = self.dut.get_mac_address(self.dut_ports[0])
+ self.txitf = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
+ # Verify that enough ports are available
+ self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
+ out = self.dut.build_dpdk_apps("./examples/flow_filtering/")
+ self.verify('Error' not in out, "Compilation failed")
+
+ def set_up(self):
+ """
+ Run before each test case.
+ """
+ self.dut.send_expect("./examples/flow_filtering/build/flow -l 1 -n 1", "initializing port", 100)
+
+ def send_packet(self, pkg):
+ """
+ Send packets according to parameters.
+ """
+ self.pkt = packet.Packet()
+ for packet_type in pkg.keys():
+ self.pkt.append_pkt(pkg[packet_type])
+ self.pkt.send_pkt(crb=self.tester, tx_port=self.txitf, count=1)
+
+ time.sleep(2)
+
+ def check_flow_queue(self):
+ '''
+ Get dut flow result
+ '''
+ result = self.dut.get_session_output(timeout=2)
+ if str.upper(self.dts_mac) in result:
+ self.verify("queue" in result, "Dut receive flow failed!")
+ queue_result = re.findall(r"queue=(\S+)", result)
+ return queue_result
+ else:
+ raise Exception("Dut not receive correct package!")
+
+ def test_flow_filtering_match_rule(self):
+ pkg = {'IP/src1': 'Ether(dst="%s")/IP(src="0.0.0.0", dst="192.168.1.1")/Raw("x"*20)' % self.dts_mac,
+ 'IP/src2': 'Ether(dst="%s")/IP(src="0.0.0.1", dst="192.168.1.1")/Raw("x"*20)' % self.dts_mac}
+ self.send_packet(pkg)
+ queue_list = self.check_flow_queue()
+ self.verify(len(queue_list) == 2, "Dut receive flow queue error!")
+ self.verify(queue_list[0] == queue_list[1] and queue_list[0] == "0x1", "Flow filter not match rule!")
+
+ def test_flow_filtering_dismatch_rule(self):
+ pkg = {'IP/dst': 'Ether(dst="%s")/IP(src="0.0.0.0", dst="192.168.1.2")/Raw("x"*20)' % self.dts_mac}
+ self.send_packet(pkg)
+ queue_list = self.check_flow_queue()
+ self.verify(len(queue_list) == 1 and queue_list[0] == "0x0", "Dismatch rule failed!")
+
+ def tear_down(self):
+ """
+ Run after each test case.
+ """
+ self.dut.send_expect("^C", "#")
+
+ def tear_down_all(self):
+ """
+ Run after each test suite.
+ """
+ self.dut.kill_all()
--
2.17.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [PATCH V2] tests/flow_filtering complete automation of flow_filtering
2019-10-30 14:41 [dts] [PATCH V2] tests/flow_filtering complete automation of flow_filtering Xiaoxiao Zeng
@ 2019-11-04 2:55 ` Tu, Lijuan
0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2019-11-04 2:55 UTC (permalink / raw)
To: Zeng, XiaoxiaoX, dts; +Cc: Zeng, XiaoxiaoX
Applied, thanks
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xiaoxiao Zeng
> Sent: Wednesday, October 30, 2019 10:42 PM
> To: dts@dpdk.org
> Cc: Zeng, XiaoxiaoX <xiaoxiaox.zeng@intel.com>
> Subject: [dts] [PATCH V2] tests/flow_filtering complete automation of
> flow_filtering
>
> *.automation of flow_filtering according to the test_plan.
>
> Signed-off-by: Xiaoxiao Zeng <xiaoxiaox.zeng@intel.com>
> ---
> tests/TestSuite_flow_filtering.py | 110 ++++++++++++++++++++++++++++++
> 1 file changed, 110 insertions(+)
> create mode 100644 tests/TestSuite_flow_filtering.py
>
> diff --git a/tests/TestSuite_flow_filtering.py
> b/tests/TestSuite_flow_filtering.py
> new file mode 100644
> index 0000000..242d321
> --- /dev/null
> +++ b/tests/TestSuite_flow_filtering.py
> @@ -0,0 +1,110 @@
> +# BSD LICENSE
> +#
> +# Copyright(c) <2019> 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.
> +
> +import os
> +import utils
> +import time
> +import re
> +import os
> +import packet
> +from test_case import TestCase
> +from settings import HEADER_SIZE
> +
> +
> +class TestFlowFiltering(TestCase):
> +
> + def set_up_all(self):
> + """
> + Run before each test suite
> + """
> + # initialize ports topology
> + self.dut_ports = self.dut.get_ports(self.nic)
> + self.dts_mac = self.dut.get_mac_address(self.dut_ports[0])
> + self.txitf =
> self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
> + # Verify that enough ports are available
> + self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing")
> + out = self.dut.build_dpdk_apps("./examples/flow_filtering/")
> + self.verify('Error' not in out, "Compilation failed")
> +
> + def set_up(self):
> + """
> + Run before each test case.
> + """
> + self.dut.send_expect("./examples/flow_filtering/build/flow -l 1
> + -n 1", "initializing port", 100)
> +
> + def send_packet(self, pkg):
> + """
> + Send packets according to parameters.
> + """
> + self.pkt = packet.Packet()
> + for packet_type in pkg.keys():
> + self.pkt.append_pkt(pkg[packet_type])
> + self.pkt.send_pkt(crb=self.tester, tx_port=self.txitf, count=1)
> +
> + time.sleep(2)
> +
> + def check_flow_queue(self):
> + '''
> + Get dut flow result
> + '''
> + result = self.dut.get_session_output(timeout=2)
> + if str.upper(self.dts_mac) in result:
> + self.verify("queue" in result, "Dut receive flow failed!")
> + queue_result = re.findall(r"queue=(\S+)", result)
> + return queue_result
> + else:
> + raise Exception("Dut not receive correct package!")
> +
> + def test_flow_filtering_match_rule(self):
> + pkg = {'IP/src1': 'Ether(dst="%s")/IP(src="0.0.0.0",
> dst="192.168.1.1")/Raw("x"*20)' % self.dts_mac,
> + 'IP/src2': 'Ether(dst="%s")/IP(src="0.0.0.1",
> dst="192.168.1.1")/Raw("x"*20)' % self.dts_mac}
> + self.send_packet(pkg)
> + queue_list = self.check_flow_queue()
> + self.verify(len(queue_list) == 2, "Dut receive flow queue error!")
> + self.verify(queue_list[0] == queue_list[1] and queue_list[0] ==
> + "0x1", "Flow filter not match rule!")
> +
> + def test_flow_filtering_dismatch_rule(self):
> + pkg = {'IP/dst': 'Ether(dst="%s")/IP(src="0.0.0.0",
> dst="192.168.1.2")/Raw("x"*20)' % self.dts_mac}
> + self.send_packet(pkg)
> + queue_list = self.check_flow_queue()
> + self.verify(len(queue_list) == 1 and queue_list[0] == "0x0",
> + "Dismatch rule failed!")
> +
> + def tear_down(self):
> + """
> + Run after each test case.
> + """
> + self.dut.send_expect("^C", "#")
> +
> + def tear_down_all(self):
> + """
> + Run after each test suite.
> + """
> + self.dut.kill_all()
> --
> 2.17.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-04 2:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 14:41 [dts] [PATCH V2] tests/flow_filtering complete automation of flow_filtering Xiaoxiao Zeng
2019-11-04 2:55 ` 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).