[V1,2/6] tests: remove etgen

Message ID 20210831081224.47039-3-yufengx.mo@intel.com (mailing list archive)
State Superseded
Headers
Series etgen: remove etgen |

Commit Message

Yufen.Mo Aug. 31, 2021, 8:12 a.m. UTC
  remove etgen relevant source code.

Signed-off-by: Yufen Mo <yufengx.mo@intel.com>
---
 tests/TestSuite_af_xdp_2.py                   |   2 +-
 tests/TestSuite_distributor.py                |   2 -
 tests/TestSuite_efd.py                        |   1 -
 tests/TestSuite_iavf.py                       |   1 -
 tests/TestSuite_multiprocess.py               |   1 -
 tests/TestSuite_ntb.py                        |   1 -
 tests/TestSuite_packet_ordering.py            |   1 -
 tests/TestSuite_performance_thread.py         |   1 -
 tests/TestSuite_pmd.py                        |   1 -
 tests/TestSuite_rteflow_priority.py           |   1 -
 tests/TestSuite_userspace_ethtool.py          | 127 +++---------------
 tests/TestSuite_vhost_virtio_pmd_interrupt.py |   1 -
 tests/TestSuite_virtio_event_idx_interrupt.py |   1 -
 tests/TestSuite_vm_power_manager.py           |   3 +-
 tests/TestSuite_vmdq.py                       |   1 -
 tests/TestSuite_vmdq_dcb.py                   |   1 -
 16 files changed, 23 insertions(+), 123 deletions(-)
  

Patch

diff --git a/tests/TestSuite_af_xdp_2.py b/tests/TestSuite_af_xdp_2.py
index 40a3d416..bcc9a751 100644
--- a/tests/TestSuite_af_xdp_2.py
+++ b/tests/TestSuite_af_xdp_2.py
@@ -45,7 +45,7 @@  class TestAfXdp(TestCase):
         Run at the start of each test suite.
         """
         #self.verify(self.nic in ("fortville_spirit"), "the port can not run this suite")
-        self.tester.extend_external_packet_generator(TestAfXdp, self)
+
         self.frame_sizes = [64, 128, 256, 512, 1024, 1518]
         self.dut_ports = self.dut.get_ports()
         self.verify(len(self.dut_ports) >= 2, "Insufficient ports for testing")
diff --git a/tests/TestSuite_distributor.py b/tests/TestSuite_distributor.py
index cd88977d..09a493b3 100644
--- a/tests/TestSuite_distributor.py
+++ b/tests/TestSuite_distributor.py
@@ -45,8 +45,6 @@  class TestDistributor(TestCase):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestDistributor, self)
-
         # reduce tx queues for enable many workers
         self.dut.send_expect("sed -i -e 's/.*txRings = .*/\\tconst uint16_t rxRings = 1, txRings = 1;/' ./examples/distributor/main.c", "#")
         out = self.dut.build_dpdk_apps("./examples/distributor")
diff --git a/tests/TestSuite_efd.py b/tests/TestSuite_efd.py
index 787733ca..7d1e0a86 100644
--- a/tests/TestSuite_efd.py
+++ b/tests/TestSuite_efd.py
@@ -44,7 +44,6 @@  class TestEFD(TestCase):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestEFD, self)
 
         self.build_server_node_efd()
 
diff --git a/tests/TestSuite_iavf.py b/tests/TestSuite_iavf.py
index 9656b4fc..adaa1304 100644
--- a/tests/TestSuite_iavf.py
+++ b/tests/TestSuite_iavf.py
@@ -57,7 +57,6 @@  class TestIavf(TestCase):
     supported_vf_driver = ['pci-stub', 'vfio-pci']
 
     def set_up_all(self):
-        self.tester.extend_external_packet_generator(TestIavf, self)
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) > 1, "Insufficient ports")
         self.vm0 = None
diff --git a/tests/TestSuite_multiprocess.py b/tests/TestSuite_multiprocess.py
index 743ca1f3..8752a727 100644
--- a/tests/TestSuite_multiprocess.py
+++ b/tests/TestSuite_multiprocess.py
@@ -58,7 +58,6 @@  class TestMultiprocess(TestCase):
         # self.verify('bsdapp' not in self.target, "Multiprocess not support freebsd")
 
         self.verify(len(self.dut.get_all_cores()) >= 4, "Not enough Cores")
-        self.tester.extend_external_packet_generator(TestMultiprocess, self)
         self.dut_ports = self.dut.get_ports()
         self.socket = self.dut.get_numa_id(self.dut_ports[0])
 
diff --git a/tests/TestSuite_ntb.py b/tests/TestSuite_ntb.py
index e5013132..01e10620 100644
--- a/tests/TestSuite_ntb.py
+++ b/tests/TestSuite_ntb.py
@@ -55,7 +55,6 @@  class TestNtb(TestCase):
         self.host_mac = self.ntb_host.get_mac_address(self.host_port)
         self.client_mac = self.ntb_client.get_mac_address(self.client_port)
 
-        self.tester.extend_external_packet_generator(TestNtb, self)
         self.frame_sizes = [64, 128, 256, 512, 1024, 1518]
         self.header_size = HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + HEADER_SIZE['udp']
         self.pktgen_helper = PacketGeneratorHelper()
diff --git a/tests/TestSuite_packet_ordering.py b/tests/TestSuite_packet_ordering.py
index 807a3c0d..2280b8b1 100644
--- a/tests/TestSuite_packet_ordering.py
+++ b/tests/TestSuite_packet_ordering.py
@@ -48,7 +48,6 @@  class TestPacketOrdering(TestCase):
         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]
diff --git a/tests/TestSuite_performance_thread.py b/tests/TestSuite_performance_thread.py
index 3ff20150..459d9a11 100644
--- a/tests/TestSuite_performance_thread.py
+++ b/tests/TestSuite_performance_thread.py
@@ -47,7 +47,6 @@  class TestPerformanceThread(TestCase):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestPerformanceThread, 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]
diff --git a/tests/TestSuite_pmd.py b/tests/TestSuite_pmd.py
index 48d35831..afc36d9f 100644
--- a/tests/TestSuite_pmd.py
+++ b/tests/TestSuite_pmd.py
@@ -58,7 +58,6 @@  class TestPmd(TestCase):
 
         PMD prerequisites.
         """
-        self.tester.extend_external_packet_generator(TestPmd, self)
 
         self.frame_sizes = [64, 72, 128, 256, 512, 1024, 1280, 1518]
 
diff --git a/tests/TestSuite_rteflow_priority.py b/tests/TestSuite_rteflow_priority.py
index 353dc8f9..b0bbf245 100644
--- a/tests/TestSuite_rteflow_priority.py
+++ b/tests/TestSuite_rteflow_priority.py
@@ -42,7 +42,6 @@  from time import sleep
 from scapy.utils import struct, socket, PcapWriter
 
 import utils
-from etgen import IxiaPacketGenerator
 from test_case import TestCase
 from settings import HEADER_SIZE
 from pmd_output import PmdOutput
diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index fd65d718..4536b7d1 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -41,14 +41,14 @@  import re
 from test_case import TestCase
 from packet import Packet
 import random
-from etgen import IxiaPacketGenerator
 from settings import HEADER_SIZE
 from settings import SCAPY2IXIA
+from pktgen import PacketGeneratorHelper
 from utils import RED
 from exception import VerifyFailure
 
 
-class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
+class TestUserspaceEthtool(TestCase):
 
     def set_up_all(self):
         """
@@ -76,9 +76,8 @@  class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
         self.pause_time = 65535
         self.frame_size = 64
         self.pause_rate = 0.50
-
-        # update IxiaPacketGenerator function from local
-        self.tester.extend_external_packet_generator(TestUserspaceEthtool, self)
+        # create an instance to set stream field setting
+        self.pktgen_helper = PacketGeneratorHelper()
 
     def set_up(self):
         """
@@ -635,45 +634,6 @@  class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
 
         self.dut.send_expect("quit", "# ")
 
-    def test_perf_port_rx_pause(self):
-        """
-        Test ethtool app flow control configure
-        """
-        self.dut.send_expect(self.cmd, "EthApp>", 60)
-        # enable pause rx
-        self.dut.send_expect("pause 0 rx", "EthApp")
-
-        # calculate number of packets
-        pps = self.wirespeed(self.nic, self.frame_size, 1) * 1000000.0
-        # get line rate
-        linerate = pps * (self.frame_size + 20) * 8
-        # calculate default sleep time for one pause frame
-        sleep = (1 / linerate) * self.pause_time * 512
-        # calculate packets dropped in sleep time
-        self.n_pkts = int((sleep / (1 / pps)) * (1 / self.pause_rate))
-
-        tgen_input = []
-        headers_size = HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + \
-            HEADER_SIZE['udp']
-        payload_size = self.frame_size - headers_size
-        self.tester.scapy_append('wrpcap("pause_rx.pcap", [Ether()/IP()/UDP()/("X"*%d)])' % payload_size)
-        self.tester.scapy_execute()
-        # rx and tx is the same port
-        tester_port = self.tester.get_local_port(self.ports[0])
-        tgen_input.append((tester_port, tester_port, "pause_rx.pcap"))
-
-        ori_func = self.config_stream
-        self.config_stream = self.config_stream_pause_rx
-        _, rx_pps = self.tester.traffic_generator_throughput(tgen_input)
-        self.config_stream = ori_func
-
-        rate = rx_pps / pps
-        # rate should same as expected rate
-        self.verify(rate > (self.pause_rate - 0.01) and
-                    rate < (self.pause_rate + 0.01), "Failed to handle Rx pause frame")
-
-        self.dut.send_expect("quit", "# ")
-
     def test_perf_port_tx_pause(self):
         """
         Test ethtool app flow control configure
@@ -691,78 +651,33 @@  class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
         headers_size = HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + \
             HEADER_SIZE['udp']
         payload_size = self.frame_size - headers_size
-        self.tester.scapy_append('wrpcap("pause_tx.pcap", [Ether()/IP()/UDP()/("X"*%d)])' % payload_size)
+        dst_mac =  self.dut.get_mac_address(0)
+        self.tester.scapy_append(
+            'wrpcap("/root/pause_tx.pcap", [Ether(dst="%s")/IP()/UDP()/("X"*%d)])' % (dst_mac, payload_size))
         self.tester.scapy_execute()
         # rx and tx is the same port
         tester_port = self.tester.get_local_port(self.ports[0])
-        tgen_input.append((tester_port, tester_port, "pause_tx.pcap"))
-
-        self.wirespeed(self.nic, self.frame_size, 1) * 1000000.0
-        _, tx_pps = self.tester.traffic_generator_throughput(tgen_input)
-
+        tgen_input.append((tester_port, tester_port, "/root/pause_tx.pcap"))
+
+        # run traffic generator
+        streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
+                                        None, self.tester.pktgen)
+        traffic_opt = {'throughput_stat_flag': True}
+        loss, rx_throughput  = self.tester.pktgen._measure_loss(
+            stream_ids=streams, options=traffic_opt)
+        tx_pps = rx_throughput[1]
+        sent_pkts, recv_pkts = list(loss.values())[0][1:]
+        self.dut.send_expect("quit", "# ")
+        self.dut.send_expect("sed -i -e '/usleep(10);$/d' %s" % main_file, "# ")
+        # rebuild sample app
+        self.build_ethtool()
         # verify ixia transmit line rate dropped
         pps = self.wirespeed(self.nic, self.frame_size, 1) * 1000000.0
         rate = tx_pps / pps
         self.verify(rate < 0.1, "Failed to slow down transmit speed")
-
         # verify received packets more than sent
-        self.stat_get_stat_all_stats(tester_port)
-        sent_pkts = self.get_frames_sent()
-        recv_pkts = self.get_frames_received()
         self.verify((float(recv_pkts) / float(sent_pkts)) > 1.05, "Failed to transmit pause frame")
 
-        self.dut.send_expect("quit", "# ")
-        self.dut.send_expect("sed -i -e '/usleep(10);$/d' %s" % main_file, "# ")
-        # rebuild sample app
-        self.build_ethtool()
-
-    def config_stream_pause_rx(self, fpcap, txport, rate_percent, stream_id=1, latency=False):
-        """
-        Configure IXIA stream with pause frame and normal packet
-        """
-        # enable flow control on port
-        self.add_tcl_cmd("port config -flowControl true")
-        self.add_tcl_cmd("port config -flowControlType ieee8023x")
-        self.add_tcl_cmd("port set %d %d %d" % (self.chasId, txport['card'], txport['port']))
-
-        flows = self.parse_pcap(fpcap)
-
-        self.add_tcl_cmd("ixGlobalSetDefault")
-        self.add_tcl_cmd("stream config -rateMode usePercentRate")
-        self.add_tcl_cmd("stream config -percentPacketRate 100")
-        self.add_tcl_cmd("stream config -numBursts 1")
-        self.add_tcl_cmd("stream config -numFrames %d" % self.n_pkts)
-        self.add_tcl_cmd("stream config -dma advance")
-
-        pat = re.compile(r"(\w+)\((.*)\)")
-        for header in flows[0].split('/'):
-            match = pat.match(header)
-            params = eval('dict(%s)' % match.group(2))
-            method_name = match.group(1)
-            if method_name in SCAPY2IXIA:
-                method = getattr(self, method_name.lower())
-                method(txport, **params)
-
-        # stream id start from 1
-        self.add_tcl_cmd("stream set %d %d %d %d" % (self.chasId, txport['card'], txport['port'], 1))
-
-        # pause frame stream
-        self.add_tcl_cmd("stream config -rateMode usePercentRate")
-        self.add_tcl_cmd("stream config -percentPacketRate 100")
-        self.add_tcl_cmd("stream config -numBursts 1")
-        self.add_tcl_cmd("stream config -numFrames 1")
-        self.add_tcl_cmd("stream config -dma gotoFirst")
-
-        self.add_tcl_cmd("protocol setDefault")
-        self.add_tcl_cmd("protocol config -name pauseControl")
-        self.add_tcl_cmd("pauseControl setDefault")
-        self.add_tcl_cmd("pauseControl config -da \"01 80 C2 00 00 01\"")
-        self.add_tcl_cmd("pauseControl config -pauseTime %d" % self.pause_time)
-        self.add_tcl_cmd("pauseControl config -pauseControlType ieee8023x")
-        self.add_tcl_cmd("pauseControl set %d %d %d" % (self.chasId, txport['card'], txport['port']))
-        self.add_tcl_cmd("stream set %d %d %d %d" %
-                         (self.chasId, txport['card'], txport['port'], 2))
-
     def tear_down(self):
         """
         Run after each test case.
diff --git a/tests/TestSuite_vhost_virtio_pmd_interrupt.py b/tests/TestSuite_vhost_virtio_pmd_interrupt.py
index 675a15ee..5dd2f830 100644
--- a/tests/TestSuite_vhost_virtio_pmd_interrupt.py
+++ b/tests/TestSuite_vhost_virtio_pmd_interrupt.py
@@ -49,7 +49,6 @@  class TestVhostVirtioPmdInterrupt(TestCase):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestVhostVirtioPmdInterrupt, self)
         self.fix_ip = False
         self.nb_cores = 4
         self.queues = 4
diff --git a/tests/TestSuite_virtio_event_idx_interrupt.py b/tests/TestSuite_virtio_event_idx_interrupt.py
index 37634f05..09918992 100644
--- a/tests/TestSuite_virtio_event_idx_interrupt.py
+++ b/tests/TestSuite_virtio_event_idx_interrupt.py
@@ -49,7 +49,6 @@  class TestVirtioIdxInterrupt(TestCase):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestVirtioIdxInterrupt, self)
         self.queues = 1
         self.nb_cores = 1
         self.dut_ports = self.dut.get_ports()
diff --git a/tests/TestSuite_vm_power_manager.py b/tests/TestSuite_vm_power_manager.py
index fca122bb..f650ba28 100644
--- a/tests/TestSuite_vm_power_manager.py
+++ b/tests/TestSuite_vm_power_manager.py
@@ -37,12 +37,11 @@  VM power manager test suite.
 import re
 import utils
 from test_case import TestCase
-from etgen import IxiaPacketGenerator
 from settings import HEADER_SIZE
 from qemu_libvirt import LibvirtKvm
 
 
-class TestVmPowerManager(TestCase, IxiaPacketGenerator):
+class TestVmPowerManager(TestCase):
 
     def set_up_all(self):
         """
diff --git a/tests/TestSuite_vmdq.py b/tests/TestSuite_vmdq.py
index 3f2ccde2..6dae54a4 100644
--- a/tests/TestSuite_vmdq.py
+++ b/tests/TestSuite_vmdq.py
@@ -50,7 +50,6 @@  class TestVmdq(TestCase):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestVmdq, self)
 
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
diff --git a/tests/TestSuite_vmdq_dcb.py b/tests/TestSuite_vmdq_dcb.py
index 5f0da0fb..2a248f8c 100644
--- a/tests/TestSuite_vmdq_dcb.py
+++ b/tests/TestSuite_vmdq_dcb.py
@@ -51,7 +51,6 @@  class TestVmdqDcb(TestCase):
         """
         Run at the start of each test suite.
         """
-        self.tester.extend_external_packet_generator(TestVmdqDcb, self)
         self.dut_ports = self.dut.get_ports(self.nic)
         self.verify(len(self.dut_ports) >= 2, "Insufficient ports")
         self.socket = self.dut.get_numa_id(self.dut_ports[0])