test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org, wenjiex.a.li@intel.com, zhaoyan.chen@intel.com,
	lijuan.tu@intel.com
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V2 6/7] framework/pktgen_trex: fix internal bug
Date: Mon, 23 Sep 2019 14:50:39 +0800	[thread overview]
Message-ID: <20190923065040.8251-7-yufengx.mo@intel.com> (raw)
In-Reply-To: <20190923065040.8251-1-yufengx.mo@intel.com>


*. use tester alt session to close trex.
*. set part of information logger display to debug level.
*. remove logger format setting after import libs to eliminate dts redundant logs.

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 framework/pktgen_trex.py | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/framework/pktgen_trex.py b/framework/pktgen_trex.py
index c6c904b..690d070 100644
--- a/framework/pktgen_trex.py
+++ b/framework/pktgen_trex.py
@@ -35,14 +35,9 @@ import time
 import logging
 from pprint import pformat
 
-from pktgen_base import (PacketGenerator, PKTGEN_TREX,
+from pktgen_base import (PacketGenerator, PKTGEN_TREX, PKTGEN,
                          TRANSMIT_CONT, TRANSMIT_M_BURST, TRANSMIT_S_BURST)
 
-FORMAT = '%(message)s'
-logging.basicConfig(format=FORMAT)
-logger = logging.getLogger(os.path.basename(__file__)[:-3].upper())
-logger.setLevel(logging.INFO)
-
 
 class TrexConfigVm(object):
     '''
@@ -492,7 +487,7 @@ class TrexPacketGenerator(PacketGenerator):
         '''
         for name, _port_obj in self._conn.ports.iteritems():
             _pci = _port_obj.info['pci_addr']
-            self.logger.info((_pci, pci))
+            self.logger.debug((_pci, pci))
             if _pci == pci:
                 return True
         else:
@@ -585,9 +580,7 @@ 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]
-            self.control_session = \
-                        self.tester.create_session('trex_control_session')
-
+            self.control_session = self.tester.create_session(PKTGEN)
             self.control_session.send_expect(
                ';'.join(['cd ' + self.conf['trex_root_path'],
                 './' + self.trex_app + " " + app_param_temp]),
@@ -628,7 +621,7 @@ class TrexPacketGenerator(PacketGenerator):
         if port_id not in ports:
             return None
         features = self._conn.ports[port_id].get_formatted_info()
-        self.logger.info(pformat(features))
+        self.logger.debug(pformat(features))
 
         return features
 
@@ -637,7 +630,7 @@ class TrexPacketGenerator(PacketGenerator):
         features = self._get_port_features(port_id)
         if not features or features.get('fc_supported') == 'no':
             msg = "trex port <{0}> not support flow control".format(port_id)
-            self.logger.warning(msg)
+            self.logger.debug(msg)
             return False
         else:
             return True
@@ -669,8 +662,8 @@ class TrexPacketGenerator(PacketGenerator):
             "Tx Port %d stats: " % (tx_port_id),
             "tx_port: %d,  tx_bps: %f, tx_pps: %f " % (
                                             tx_port_id, tx_bps, tx_pps)]
-        self.logger.info(pformat(port_stats))
-        self.logger.info(os.linesep.join(msg))
+        self.logger.debug(pformat(port_stats))
+        self.logger.debug(os.linesep.join(msg))
         # rx bps/pps
         rx_port_id = stream["rx_port"]
         port_stats = self.runtime_stats.get(rx_port_id)
@@ -684,8 +677,8 @@ class TrexPacketGenerator(PacketGenerator):
             "rx_port: %d,  rx_bps: %f, rx_pps: %f" % (
                                         rx_port_id, rx_bps, rx_pps)]
 
-        self.logger.info(pformat(port_stats))
-        self.logger.info(os.linesep.join(msg))
+        self.logger.debug(pformat(port_stats))
+        self.logger.debug(os.linesep.join(msg))
 
         return rx_bps, rx_pps
 
@@ -699,13 +692,13 @@ class TrexPacketGenerator(PacketGenerator):
             self.logger.error(msg)
             return None
         msg = "Tx Port %d stats: " % (port_id)
-        self.logger.info(msg)
+        self.logger.debug(msg)
         opackets = port_stats["opackets"]
         # rx packet
         port_id = stream.get("rx_port")
         port_stats = stats[port_id]
         msg = "Rx Port %d stats: " % (port_id)
-        self.logger.info(msg)
+        self.logger.debug(msg)
         ipackets = port_stats["ipackets"]
 
         return opackets, ipackets
@@ -813,13 +806,14 @@ class TrexPacketGenerator(PacketGenerator):
                 'core_mask':core_mask,
                 'force':    True,}
             self.logger.info("begin traffic ......")
+            self.logger.debug(run_opt)
             self._conn.start(**run_opt)
             ###########################################
             if sample_delay:
                 time.sleep(sample_delay) # wait
                 # get ports runtime statistics
                 self.runtime_stats = self._conn.get_stats()
-                self.logger.info(pformat(self.runtime_stats))
+                self.logger.debug(pformat(self.runtime_stats))
             ###########################################
             # Block until traffic on specified port(s) has ended
             wait_opt = {'ports':  self._traffic_ports}
@@ -840,8 +834,8 @@ class TrexPacketGenerator(PacketGenerator):
         '''
         stats = self._conn.get_stats()
         stream = self._get_stream(stream_id)
-        self.logger.info(pformat(stream))
-        self.logger.info(pformat(stats))
+        self.logger.debug(pformat(stream))
+        self.logger.debug(pformat(stats))
         if mode == 'throughput':
             return self._throughput_stats(stream, stats)
         elif mode == 'loss':
@@ -855,7 +849,7 @@ class TrexPacketGenerator(PacketGenerator):
         if self._conn is not None:
             self._disconnect()
         if self.control_session is not None:
-            self.tester.send_expect('pkill -f _t-rex-64', '# ')
+            self.tester.alt_session.send_expect('pkill -f _t-rex-64', '# ')
             time.sleep(5)
             self.tester.destroy_session(self.control_session)
             self.control_session = None
-- 
2.21.0


  parent reply	other threads:[~2019-09-23  6:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23  6:50 [dts] [PATCH V2 0/7] dts/pktgen: fix internal bugs yufengmx
2019-09-23  6:50 ` [dts] [PATCH V2 1/7] framework/logger: add pktgen logger and remove duplicate yufengmx
2019-09-23  6:58   ` Mo, YufengX
2019-09-23  6:50 ` [dts] [PATCH V2 2/7] framework/dut: fix logger quit issue yufengmx
2019-09-23  6:58   ` Mo, YufengX
2019-09-23  6:50 ` [dts] [PATCH V2 3/7] framework/tester: " yufengmx
2019-09-23  6:58   ` Mo, YufengX
2019-09-23  6:50 ` [dts] [PATCH V2 4/7] framework/pktgen_base: fix internal bug yufengmx
2019-09-23  6:58   ` Mo, YufengX
2019-09-23  6:50 ` [dts] [PATCH V2 5/7] framework/pktgen_ixia: " yufengmx
2019-09-23  6:57   ` Mo, YufengX
2019-09-23  6:50 ` yufengmx [this message]
2019-09-23  6:57   ` [dts] [PATCH V2 6/7] framework/pktgen_trex: " Mo, YufengX
2019-09-23  6:50 ` [dts] [PATCH V2 7/7] framework/pktgen: " yufengmx
2019-09-23  6:57   ` Mo, YufengX
2019-09-23  6:58 ` [dts] [PATCH V2 0/7] dts/pktgen: fix internal bugs Mo, YufengX
2019-09-24  9:14 ` Tu, Lijuan

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=20190923065040.8251-7-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    --cc=wenjiex.a.li@intel.com \
    --cc=zhaoyan.chen@intel.com \
    /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).