test suite reviews and discussions
 help / color / mirror / Atom feed
From: Patrick MacArthur <pmacarth@iol.unh.edu>
To: dts@dpdk.org
Cc: pmacarth@iol.unh.edu, dpdklab@iol.unh.edu
Subject: [dts] [PATCH for-next 5/6] framework/pktgen: Start T-Rex during prepare_generator()
Date: Tue, 20 Feb 2018 12:26:11 -0500	[thread overview]
Message-ID: <20180220172612.11973-6-pmacarth@iol.unh.edu> (raw)
In-Reply-To: <20180220172612.11973-1-pmacarth@iol.unh.edu>

The currently merged patchset for T-Rex does not actually start T-Rex.
Add some code to start T-Rex as part of packet generator setup during
the prepare_generator() step. We need T-Rex running during this step so
we can determine which ports the T-Rex API is making available to the
DUT before we set up the DUT's network interfaces accordingly.

This change assumes that T-Rex will always be run on the tester node.

Tested-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Patrick MacArthur <pmacarth@iol.unh.edu>
---
 framework/pktgen.py | 30 +++++++++++++++++++++++-------
 framework/tester.py |  1 +
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/framework/pktgen.py b/framework/pktgen.py
index 9e052c832da9..c7fc81ae58fc 100644
--- a/framework/pktgen.py
+++ b/framework/pktgen.py
@@ -204,6 +204,7 @@ class TrexPacketGenerator(PacketGenerator):
     def __init__(self, tester):
         self.pktgen_type = "trex"
         self._conn = None
+        self.control_session = None
         self._ports = []
         self._traffic_ports = []
         self._transmit_streams = {}
@@ -218,7 +219,6 @@ class TrexPacketGenerator(PacketGenerator):
 
     def connect(self):
         self._conn = self.trex_client(server=self.conf["server"])
-        time.sleep(30)
         self._conn.connect()
         for p in self._conn.get_all_ports():
             self._ports.append(p)
@@ -295,7 +295,11 @@ class TrexPacketGenerator(PacketGenerator):
                 app_param_temp = app_param_temp + " --cfg " + self.conf[key]
             elif key == 'core_num':
                 app_param_temp = app_param_temp + " -c " + self.conf[key]
-
+        app = self.conf['trex_root_path'] + os.sep + self.trex_app
+        cmd = app + " " + app_param_temp
+        self.control_session = self.tester.create_session('trex_control_session')
+        self.control_session.send_expect('cd ' + self.conf['trex_root_path'] + os.sep + 'scripts', '# ')
+        self.control_session.send_expect(app + " " + app_param_temp, '-Per port stats table', 30)
 
         # Insert Trex api library
         sys.path.insert(0, "{0}/scripts/automation/trex_control_plane/stl".format(self.conf['trex_root_path']))
@@ -377,16 +381,22 @@ class TrexPacketGenerator(PacketGenerator):
         if self.conf.has_key("warmup"):
             warmup = int(self.conf["warmup"])
 
+        self._traffic_ports = list()
+        for stream_id in stream_ids:
+            self._traffic_ports.append(self._ports[self._get_stream(stream_id)['tx_port']])
+
+        print self._traffic_ports
+        self._conn.set_service_mode(ports=self._traffic_ports, enabled=True)
+        self._conn.resolve(ports=self._traffic_ports)
+        self._conn.set_service_mode(ports=self._traffic_ports, enabled=False)
+
         for stream_id in stream_ids:
             stream = self._get_stream(stream_id)
             # tester port to Trex port
             tx_port = stream["tx_port"]
             p = self._ports[tx_port]
-            self._conn.add_streams(self._transmit_streams[stream_id], ports=[p])
+            sid = self._conn.add_streams(self._transmit_streams[stream_id], ports=[p])
             rate = stream["options"]["rate"]
-            self._traffic_ports.append(p)
-
-        print self._traffic_ports
 
         if self.conf.has_key("core_mask"):
             self._conn.start(ports=self._traffic_ports, mult=rate, duration=warmup, core_mask=self.conf["core_mask"])
@@ -421,7 +431,13 @@ class TrexPacketGenerator(PacketGenerator):
         return rate_rx_bits, rate_rx_pkts
 
     def quit_generator(self):
-        self.disconnect()
+        if self._conn is not None:
+            self.disconnect()
+        self.tester.send_expect('pkill -f _t-rex-64', '# ')
+        time.sleep(5)
+        if self.control_session is not None:
+            self.tester.destroy_session(self.control_session)
+            self.control_session = None
 
 def getPacketGenerator(tester, pktgen_type="trex"):
     """
diff --git a/framework/tester.py b/framework/tester.py
index be5b0e13897c..e20c4f8ffcf7 100755
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -743,5 +743,6 @@ class Tester(Crb):
         """
         Close all resource before crb exit
         """
+        self.pktgen.quit_generator()
         self.logger.logger_exit()
         self.close()
-- 
2.14.1

  parent reply	other threads:[~2018-02-20 17:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 17:26 [dts] [PATCH for-next 0/6] Fixes and modifications for T-Rex integration and nic_single_core_perf Patrick MacArthur
2018-02-20 17:26 ` [dts] [PATCH for-next 1/6] framework/texttable: Update to latest upstream version Patrick MacArthur
2018-02-20 17:26 ` [dts] [PATCH for-next 2/6] framework: Do not attempt ping6 on T-Rex ports Patrick MacArthur
2018-02-20 17:26 ` [dts] [PATCH for-next 3/6] tests/TestSuite_nic_single_core_perf: Fix config parsing Patrick MacArthur
2018-02-20 17:26 ` [dts] [PATCH for-next 4/6] tests/TestSuite_nic_single_core_perf: Use user-specified output dir Patrick MacArthur
2018-02-20 17:26 ` Patrick MacArthur [this message]
2018-03-02  1:51   ` [dts] [PATCH for-next 5/6] framework/pktgen: Start T-Rex during prepare_generator() Liu, Yong
2018-02-20 17:26 ` [dts] [PATCH for-next 6/6] tests/TestSuite_nic_single_core_perf: Fix test case name Patrick MacArthur
     [not found]   ` <188971FCDA171749BED5DA74ABF3E6F03C123A39@SHSMSX104.ccr.corp.intel.com>
2018-03-05  9:25     ` Wang, FeiX Y
     [not found] ` <188971FCDA171749BED5DA74ABF3E6F03C1239F0@SHSMSX104.ccr.corp.intel.com>
2018-03-05  9:16   ` [dts] [PATCH for-next 0/6] Fixes and modifications for T-Rex integration and nic_single_core_perf Wang, FeiX Y
2018-03-20 22:25     ` Patrick MacArthur
2018-03-21  7:28       ` Wang, FeiX Y
2018-03-23  9:03       ` Wang, FeiX Y

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180220172612.11973-6-pmacarth@iol.unh.edu \
    --to=pmacarth@iol.unh.edu \
    --cc=dpdklab@iol.unh.edu \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).