[V1,3/4] tests: use scapy modules vxlan instead of local modules
diff mbox series

Message ID 1603132315-19498-4-git-send-email-lihongx.ma@intel.com
State Accepted
Headers show
Series
  • use scapy modules instead of local modules
Related show

Commit Message

Ma, LihongX Oct. 19, 2020, 6:31 p.m. UTC
- modify the import path of vxlan layers

Signed-off-by: LihongX Ma <lihongx.ma@intel.com>
---
 tests/TestSuite_cloud_filter.py     |  5 ++---
 tests/TestSuite_generic_flow_api.py | 27 ---------------------------
 tests/TestSuite_vxlan.py            |  2 +-
 tests/TestSuite_vxlan_sample.py     |  2 +-
 4 files changed, 4 insertions(+), 32 deletions(-)

Patch
diff mbox series

diff --git a/tests/TestSuite_cloud_filter.py b/tests/TestSuite_cloud_filter.py
index 3723e57..abc474f 100644
--- a/tests/TestSuite_cloud_filter.py
+++ b/tests/TestSuite_cloud_filter.py
@@ -46,11 +46,10 @@  from settings import HEADER_SIZE
 from packet import Packet
 
 from scapy.layers.inet import UDP, IP
+from scapy.layers.vxlan import VXLAN
 from scapy.packet import split_layers, bind_layers
 
-from vxlan import VXLAN
-from vxlan import VXLAN_PORT
-
+VXLAN_PORT = 4789
 CLOUD_PORT = 8472
 split_layers(UDP, VXLAN, dport=VXLAN_PORT)
 bind_layers(UDP, VXLAN, dport=CLOUD_PORT)
diff --git a/tests/TestSuite_generic_flow_api.py b/tests/TestSuite_generic_flow_api.py
index da061fe..1660669 100644
--- a/tests/TestSuite_generic_flow_api.py
+++ b/tests/TestSuite_generic_flow_api.py
@@ -148,19 +148,6 @@  class TestGeneric_flow_api(TestCase):
             time.sleep(2)
         self.vf_flag = 0
 
-    def load_module(self, module=""):
-        """
-        Load vxlan or nvgre module to scapy.
-        """
-        # load vxlan module to scapy
-        cwd = os.getcwd()
-        dir_module = cwd + r'/' + 'dep'
-        self.tester.scapy_append('sys.path.append("%s")' % dir_module)
-        if module == "vxlan":
-            self.tester.scapy_append("from vxlan import VXLAN")
-        elif module == "nvgre":
-            self.tester.scapy_append('from nvgre import NVGRE')
-
     def verify_result(self, pf_vf, expect_rxpkts, expect_queue, verify_mac):
         """
         verify the packet to the expected queue or be dropped
@@ -322,12 +309,6 @@  class TestGeneric_flow_api(TestCase):
                 self.dut.send_expect(flow_cmd, "created")
                 rule_created = 1
 
-                # Enable vxlan packet sending
-                if "VXLAN" in flow_pkt:
-                    self.load_module("vxlan")
-                elif "NVGRE" in flow_pkt:
-                    self.load_module("nvgre")
-
                 # The rule is created successfully, so send the consistent packet.
                 self.sendpkt(pktstr=flow_pkt)
                 cur_mac = re.search("dst='(\S\S:\S\S:\S\S:\S\S:\S\S:\S\S)'", flow_pkt)
@@ -2290,21 +2271,17 @@  class TestGeneric_flow_api(TestCase):
         extrapkt_rulenum = self.all_flows_process(basic_flow_actions)
         extra_packet = extrapkt_rulenum['extrapacket']
 
-        self.load_module("vxlan")
         self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN()/Ether(dst="%s")/Dot1Q(vlan=11)/IP()/TCP()/Raw("x" * 20)' % (self.outer_mac, self.inner_mac))
         self.verify_result("pf", expect_rxpkts="1", expect_queue=extrapkt_rulenum['queue'][0],
                            verify_mac=self.outer_mac)
 
-        self.load_module("vxlan")
         self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN(vni=5)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (self.outer_mac, self.wrong_mac))
         self.verify_result("pf", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
 
-        self.load_module("vxlan")
         self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN(vni=%s)/Ether(dst="%s")/Dot1Q(vlan=%s)/IP()/TCP()/Raw("x" * 20)' % (
         self.outer_mac, extra_packet[5]['vni'], self.wrong_mac, extra_packet[5]['invlan']))
         self.verify_result("vf0", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
 
-        self.load_module("vxlan")
         self.sendpkt('Ether(dst="%s")/IP()/UDP()/VXLAN(vni=%s)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (
         self.wrong_mac, extra_packet[6]['vni'], self.inner_mac))
         self.verify_result("vf1", expect_rxpkts="0", expect_queue="NULL", verify_mac=self.wrong_mac)
@@ -2356,22 +2333,18 @@  class TestGeneric_flow_api(TestCase):
         extrapkt_rulenum = self.all_flows_process(basic_flow_actions)
         extra_packet = extrapkt_rulenum['extrapacket']
 
-        self.load_module("nvgre")
         self.sendpkt('Ether(dst="%s")/IP()/NVGRE()/Ether(dst="%s")/Dot1Q(vlan=1)/IP()/TCP()/Raw("x" * 20)' % (self.outer_mac, self.inner_mac))
         self.verify_result("pf", expect_rxpkts="1", expect_queue=extrapkt_rulenum['queue'][0],
                            verify_mac=self.outer_mac)
 
-        self.load_module("nvgre")
         self.sendpkt('Ether(dst="%s")/IP()/NVGRE(TNI=%s)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (
         self.outer_mac, extra_packet[4]['tni'], self.wrong_mac))
         self.verify_result("pf", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
 
-        self.load_module("nvgre")
         self.sendpkt('Ether(dst="%s")/IP()/NVGRE(TNI=%s)/Ether(dst="%s")/Dot1Q(vlan=%s)/IP()/TCP()/Raw("x" * 20)' % (
         self.outer_mac, extra_packet[5]['tni'], self.wrong_mac, extra_packet[5]['invlan']))
         self.verify_result("vf0", expect_rxpkts="1", expect_queue="0", verify_mac=self.outer_mac)
 
-        self.load_module("nvgre")
         self.sendpkt('Ether(dst="%s")/IP()/NVGRE(TNI=%s)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)' % (
         self.wrong_mac, extra_packet[6]['tni'], self.inner_mac))
         self.verify_result("vf1", expect_rxpkts="0", expect_queue="NULL", verify_mac=self.wrong_mac)
diff --git a/tests/TestSuite_vxlan.py b/tests/TestSuite_vxlan.py
index 2db3549..eb324fb 100644
--- a/tests/TestSuite_vxlan.py
+++ b/tests/TestSuite_vxlan.py
@@ -48,7 +48,7 @@  from scapy.utils import wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP
 from scapy.layers.inet6 import IPv6
 from scapy.layers.l2 import Dot1Q
-from vxlan import VXLAN
+from scapy.layers.vxlan import VXLAN
 from scapy.layers.sctp import SCTP, SCTPChunkData
 from scapy.sendrecv import sniff
 from scapy.config import conf
diff --git a/tests/TestSuite_vxlan_sample.py b/tests/TestSuite_vxlan_sample.py
index feaad14..92253bb 100644
--- a/tests/TestSuite_vxlan_sample.py
+++ b/tests/TestSuite_vxlan_sample.py
@@ -54,7 +54,7 @@  from scapy.utils import wrpcap, rdpcap
 from scapy.layers.inet import Ether, IP, TCP, UDP
 from scapy.layers.inet6 import IPv6
 from scapy.layers.l2 import Dot1Q
-from vxlan import VXLAN
+from scapy.layers.vxlan import VXLAN
 from scapy.layers.sctp import SCTP, SCTPChunkData
 from scapy.sendrecv import sniff
 from scapy.config import conf