[V2] tests/dcf_lifecycle: add a method to create and check acl rule

Message ID 1634698528-112655-1-git-send-email-songx.jiale@intel.com (mailing list archive)
State Superseded
Headers
Series [V2] tests/dcf_lifecycle: add a method to create and check acl rule |

Checks

Context Check Description
ci/Intel-dts-suite-test success Testing OK

Commit Message

Jiale, SongX Oct. 20, 2021, 2:55 a.m. UTC
  as the priority of switch rule becomes higher, some rules that support switch cannot be 
downloaded directly to acl. add a method to create and check acl rule.

Signed-off-by: Jiale Song <songx.jiale@intel.com>
---
 tests/TestSuite_dcf_lifecycle.py | 59 +++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)
  

Comments

Huang, ZhiminX Oct. 21, 2021, 2:04 a.m. UTC | #1
> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of Jiale Song
> Sent: Wednesday, October 20, 2021 10:55 AM
> To: dts@dpdk.org
> Cc: Jiale, SongX <songx.jiale@intel.com>
> Subject: [dts] [PATCH V2] tests/dcf_lifecycle: add a method to create and check
> acl rule
> 
> as the priority of switch rule becomes higher, some rules that support switch
> cannot be downloaded directly to acl. add a method to create and check acl
> rule.
> 
> Signed-off-by: Jiale Song <songx.jiale@intel.com>
> ---
Add dpdk code changed commit: e4a0a7599d974f05665fec3e4c251659f0b11453
  
Tu, Lijuan Oct. 25, 2021, 8:01 a.m. UTC | #2
> -----Original Message-----
> From: dts <dts-bounces@dpdk.org> On Behalf Of Jiale Song
> Sent: 2021年10月20日 10:55
> To: dts@dpdk.org
> Cc: Jiale, SongX <songx.jiale@intel.com>
> Subject: [dts] [PATCH V2] tests/dcf_lifecycle: add a method to create and check
> acl rule
> 
> as the priority of switch rule becomes higher, some rules that support switch
> cannot be downloaded directly to acl. add a method to create and check acl rule.
> 
> Signed-off-by: Jiale Song <songx.jiale@intel.com>

Please update test plan accordingly.
  

Patch

diff --git a/tests/TestSuite_dcf_lifecycle.py b/tests/TestSuite_dcf_lifecycle.py
index d47ef2b1..310172af 100755
--- a/tests/TestSuite_dcf_lifecycle.py
+++ b/tests/TestSuite_dcf_lifecycle.py
@@ -315,6 +315,7 @@  class TestDcfLifeCycle(TestCase):
             "-c {core_mask} "
             "-n {mem_channel} "
             "{allowlist} "
+            "--log-level=ice,7 "
             "--file-prefix={prefix} "
             "-- -i ").format(**{
                 'bin': ''.join(['./',self.vf_dcf_testpmd]),
@@ -374,6 +375,7 @@  class TestDcfLifeCycle(TestCase):
             "-c {core_mask} "
             "-n {mem_channel} "
             "{allowlist} "
+            "--log-level=ice,7 "
             "--file-prefix={prefix} "
             "-- -i ").format(**{
                 'bin': ''.join(['./',self.vf_testpmd2]),
@@ -1020,6 +1022,60 @@  class TestDcfLifeCycle(TestCase):
         self.preset_pmd_res()
         self.vf_create()
 
+    def create_acl_filter_rule(self, rules, session_name="", check_stats=True):
+        """
+        create acl filter rules
+        """
+        if session_name == "":
+            session_name = self.dut
+        p = re.compile(r"Flow rule #(\d+) created")
+        rule_list = []
+        acl_list = []
+        switch_rule = "Succeeded to create (2) flow"
+        acl_rule = "Succeeded to create (4) flow"
+        if isinstance(rules, str):
+            rule_list.append(rules)
+        else:
+            rule_list = rules
+        for rule in rule_list:
+            # create rule is switch or acl
+            out1 = session_name.send_expect(rule, "testpmd> ")
+            if check_stats:
+                if switch_rule in out1:
+                    switch_id = p.findall(out1)[0]
+                    # crete acl_rule
+                    out2 = session_name.send_expect(rule, "testpmd> ")
+                    # destory switch rule
+                    session_name.send_expect("flow destroy %s rule %s" % (0, switch_id), "testpmd> ")
+                    rule_id = p.search(out2)
+                    if rule_id:
+                        acl_list.append(rule_id.group(1))
+                    else:
+                        acl_list.append(False)
+
+                elif acl_rule in out1:
+                    rule_id = p.search(out1)
+                    if rule_id:
+                        acl_list.append(rule_id.group(1))
+                    else:
+                        acl_list.append(False)
+                else:
+                    self.verify(False, "some rules not created Successful, result %s, rule %s" % (acl_list, rule_list))
+
+            else:
+                if switch_rule in out1:
+                    # crete acl_rule
+                    out2 = session_name.send_expect(rule, "testpmd> ")
+                    self.verify('Failed to create flow' in out2,
+                                "some rules should created Failed, '%s'" % (rule))
+                elif acl_rule in out1:
+                    self.verify(False, "some rules should created Failed, '%s' " % (rule))
+
+                else:
+                    self.verify(True, "some rules should created Failed, '%s' " % (rule))
+
+        return acl_list
+
     def destroy_resource(self):
         try:
             self.vf_destroy()
@@ -1232,7 +1288,8 @@  class TestDcfLifeCycle(TestCase):
     def pretest_handle_acl_filter(self):
         # Create an ACL rule, and send packet with dst mac of VF1, then it will dropped by VF1.
         rule = 'flow create 0 priority 0 ingress pattern eth / ipv4 / tcp src spec 8010 src mask 65520 / end actions drop / end'
-        self.d_con([rule, "testpmd> ", 15])
+        # acl rule
+        self.create_acl_filter_rule(rule, check_stats=True)
         self.check_rule_list()
         self.send_pkt_to_vf1_first(self.dmac)
         out = self.vf_pmd2_con(['stop', "testpmd> ", 15])