test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 4/7] framework/pktgen_base: fix internal bug
Date: Tue,  6 Aug 2019 15:51:25 +0800	[thread overview]
Message-ID: <1565077888-4431-5-git-send-email-yufengx.mo@intel.com> (raw)
In-Reply-To: <1565077888-4431-1-git-send-email-yufengx.mo@intel.com>


*. remove logger format setting after import libs to eliminate dts redundant logs.
*. set part of information logger display to debug level.
*. remove un-used libs import.
*. fix pep8 issue.

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 framework/pktgen_base.py | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/framework/pktgen_base.py b/framework/pktgen_base.py
index eec4e6f..8915ac5 100644
--- a/framework/pktgen_base.py
+++ b/framework/pktgen_base.py
@@ -29,27 +29,22 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import os
 import time
 import logging
 from abc import abstractmethod
 from copy import deepcopy
-from logger import getLogger
 from pprint import pformat
 
 from config import PktgenConf
+from logger import getLogger, set_verbose
 # packet generator name
-from settings import PKTGEN_DPDK, PKTGEN_TREX, PKTGEN_IXIA, PKTGEN
+from settings import (PKTGEN_DPDK, PKTGEN_TREX, PKTGEN_IXIA, PKTGEN,
+                      load_global_setting, DEBUG_SETTING)
 
 # macro definition
 TRANSMIT_CONT = 'continuous'
 TRANSMIT_M_BURST = 'multi_burst'
 TRANSMIT_S_BURST = 'single_burst'
-# set logger
-FORMAT = '%(message)s'
-logging.basicConfig(format=FORMAT)
-logger = logging.getLogger(os.path.basename(__file__)[:-3].upper())
-logger.setLevel(logging.INFO)
 
 
 class PacketGenerator(object):
@@ -57,8 +52,11 @@ class PacketGenerator(object):
     Basic class for packet generator, define basic function for each kinds of
     generators
     """
+
     def __init__(self, tester):
         self.logger = getLogger(PKTGEN)
+        if load_global_setting(DEBUG_SETTING) == "yes":
+            set_verbose()
         self.tester = tester
         self.__streams = []
         self._ports_map = []
@@ -82,8 +80,8 @@ class PacketGenerator(object):
                 tester_pci = info['pci']
                 if tester_pci == gen_pci:
                     msg = "gen port {0} map test port {1}".format(
-                                                        port_id, port_idx)
-                    self.logger.info(msg)
+                        port_id, port_idx)
+                    self.logger.debug(msg)
                     return port_idx
             else:
                 port = -1
@@ -105,15 +103,15 @@ class PacketGenerator(object):
             tester_pci = info['pci']
             port = self._get_gen_port(tester_pci)
             msg = "test port {0} map gen port {1}".format(port_id, port)
-            self.logger.info(msg)
+            self.logger.debug(msg)
         except:
             port = -1
 
         return port
 
     def add_stream(self, tx_port, rx_port, pcap_file):
-        pktgen_tx_port  = self._convert_tester_port(tx_port)
-        pktgen_rx_port  = self._convert_tester_port(rx_port)
+        pktgen_tx_port = self._convert_tester_port(tx_port)
+        pktgen_rx_port = self._convert_tester_port(rx_port)
 
         stream_id = len(self.__streams)
         stream = {'tx_port': pktgen_tx_port,
@@ -183,13 +181,14 @@ class PacketGenerator(object):
         for stream_id in stream_ids:
             if self.__streams[stream_id]['rx_port'] not in used_rx_port:
                 rxbps_rates, rxpps_rates = self._retrieve_port_statistic(
-                                                        stream_id, 'throughput')
+                    stream_id, 'throughput')
                 used_rx_port.append(self.__streams[stream_id]['rx_port'])
                 bps_rx.append(rxbps_rates)
                 pps_rx.append(rxpps_rates)
         bps_rx_total = self._summary_statistic(bps_rx)
         pps_rx_total = self._summary_statistic(pps_rx)
-        self.logger.info("throughput: pps_rx %f, bps_rx %f" % (pps_rx_total, bps_rx_total))
+        self.logger.info(
+            "throughput: pps_rx %f, bps_rx %f" % (pps_rx_total, bps_rx_total))
 
         return bps_rx_total, pps_rx_total
 
@@ -379,7 +378,7 @@ class PacketGenerator(object):
         result = self._measure_loss(stream_ids, options)
         status = self._check_loss_rate(result, permit_loss_rate)
         loss_rate_table.append(
-                    [options.get('rate') or rate_percent, result])
+            [options.get('rate') or rate_percent, result])
         # if first time loss rate is ok, ignore left flow
         if status:
             # return data is the same with dts/etgen format
@@ -439,7 +438,7 @@ class PacketGenerator(object):
                 traffic_pps_min = pps
             if traffic_pps_max - traffic_pps_min < step:
                 break
-            pps = (traffic_pps_max - traffic_pps_min)/2 + traffic_pps_min
+            pps = (traffic_pps_max - traffic_pps_min) / 2 + traffic_pps_min
 
         self.logger.info("zero loss pps is %f" % last_no_lost_mult)
         # use last result as return data to keep the same with dts/etgen format
@@ -516,4 +515,5 @@ class PacketGenerator(object):
         pass
 
 
-class DpdkPacketGenerator(PacketGenerator): pass # not implemented
\ No newline at end of file
+class DpdkPacketGenerator(PacketGenerator):
+    pass  # not implemented
-- 
1.9.3


  parent reply	other threads:[~2019-08-06  8:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06  7:51 [dts] [PATCH V1 0/7] dts/pktgen: fix internal bugs yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 1/7] framework/logger: add pktgen logger and remove duplicate yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 2/7] framework/dut: fix logger quit issue yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 3/7] framework/tester: " yufengmx
2019-08-06  7:51 ` yufengmx [this message]
2019-08-06  7:51 ` [dts] [PATCH V1 5/7] framework/pktgen_ixia: fix internal bug yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 6/7] framework/pktgen_trex: " yufengmx
2019-08-06  7:51 ` [dts] [PATCH V1 7/7] framework/pktgen: fix pep8 issue yufengmx

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=1565077888-4431-5-git-send-email-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --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).