test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] tests/stats_checks: clear xstats before starting testing
@ 2021-06-01 16:58 ohilyard
  2021-06-09  6:38 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: ohilyard @ 2021-06-01 16:58 UTC (permalink / raw)
  To: dts; +Cc: ohilyard, lijuan.tu, dpdklab

From: Owen Hilyard <ohilyard@iol.unh.edu>

Port xstats would have non-zero values when the entire test suite
was run. Clearing those stats before starting the tests prevents a
failure where it appears that more packets were sent than were sent
during the test, causing a failure.

Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
---
 tests/TestSuite_stats_checks.py | 34 +++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/tests/TestSuite_stats_checks.py b/tests/TestSuite_stats_checks.py
index 74de4eee..5dc21b6d 100644
--- a/tests/TestSuite_stats_checks.py
+++ b/tests/TestSuite_stats_checks.py
@@ -130,8 +130,8 @@ class TestStatsChecks(TestCase):
             src_ip = self.get_random_ip()
             pkt.config_layers([('ether', {'dst': mac}),
                                ('ipv4', {'src': src_ip})])
-            pkt.send_pkt(crb=self.tester, tx_port=self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])))
-
+            pkt.send_pkt(crb=self.tester,
+                         tx_port=self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])))
 
     def send_packet_of_size_to_tx_port(self, pktsize, received=True):
         """
@@ -180,7 +180,7 @@ class TestStatsChecks(TestCase):
             out = self.exec('show port xstats %s' % port_id)
             tmp_data = dict()
             for prefix in prefix_list:
-                pattern = re.compile('%s:(\s+)([0-9]+)' % prefix)
+                pattern = re.compile('%s:(\\s+)([0-9]+)' % prefix)
                 m = pattern.search(out)
                 if not m:
                     tmp_data.setdefault(prefix, 0)
@@ -193,40 +193,42 @@ class TestStatsChecks(TestCase):
         if if_zero:
             for port in xstats_data.keys():
                 self.verify(not any(xstats_data[port].values()), 'xstats Initial value error! port {} xstats '
-                                                                         'data is {}'.format(port, xstats_data[port]))
+                                                                 'data is {}'.format(port, xstats_data[port]))
         else:
             self.verify(xstats_data[rx_port]['rx_good_packets'] == stats_data[rx_port]['RX-packets']
-                                == xstats_data[tx_port]['tx_good_packets'] == stats_data[tx_port]['TX-packets']
-                                == 100, "pkt recieve or transport count error!")
+                        == xstats_data[tx_port]['tx_good_packets'] == stats_data[tx_port]['TX-packets']
+                        == 100, "pkt recieve or transport count error!")
             self.verify(xstats_data[rx_port]['rx_good_bytes'] == stats_data[rx_port]['RX-bytes'] ==
                         xstats_data[tx_port]['tx_good_bytes'] == stats_data[tx_port]['TX-bytes'],
                         'pkt recieve or transport bytes error!')
 
     def xstats_check(self, rx_port, tx_port, if_vf=False):
-        self.exec ("port config all rss all")
-        self.exec ("set fwd mac")
+        self.exec("port config all rss all")
+        self.exec("set fwd mac")
+        self.exec("clear port xstats all")
         org_xstats = self.get_xstats([rx_port, tx_port])
         self.verify_results(org_xstats, rx_port, tx_port, if_zero=True)
-        self.exec ("start")
+        self.exec("start")
 
         self.send_pkt_with_random_ip(tx_port, count=100, if_vf=if_vf)
 
-        self.exec ("stop")
+        self.exec("stop")
         if rx_port == tx_port:
             final_xstats = self.get_xstats([rx_port])
-            stats_data = {rx_port: self.pmdout.get_pmd_stats(rx_port)}
+            stats_data = {
+                rx_port: self.pmdout.get_pmd_stats(rx_port)
+            }
         else:
             rx_stats_info = self.pmdout.get_pmd_stats(rx_port)
             tx_stats_info = self.pmdout.get_pmd_stats(tx_port)
             final_xstats = self.get_xstats([rx_port, tx_port])
-            stats_data = {rx_port: rx_stats_info,
-                          tx_port: tx_stats_info
-                          }
+            stats_data = {
+                rx_port: rx_stats_info,
+                tx_port: tx_stats_info
+            }
         self.verify_results(final_xstats, rx_port, tx_port, stats_data=stats_data)
-
         self.pmdout.quit()
 
-
     def set_up_all(self):
         """
         Prerequisite steps for each test suit.
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH] tests/stats_checks: clear xstats before starting testing
  2021-06-01 16:58 [dts] [PATCH] tests/stats_checks: clear xstats before starting testing ohilyard
@ 2021-06-09  6:38 ` Tu, Lijuan
  0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2021-06-09  6:38 UTC (permalink / raw)
  To: ohilyard, dts; +Cc: dpdklab


> -----Original Message-----
> From: ohilyard@iol.unh.edu <ohilyard@iol.unh.edu>
> Sent: 2021年6月2日 0:59
> To: dts@dpdk.org
> Cc: ohilyard@iol.unh.edu; Tu, Lijuan <lijuan.tu@intel.com>;
> dpdklab@iol.unh.edu
> Subject: [PATCH] tests/stats_checks: clear xstats before starting testing
> 
> From: Owen Hilyard <ohilyard@iol.unh.edu>
> 
> Port xstats would have non-zero values when the entire test suite was run.
> Clearing those stats before starting the tests prevents a failure where it appears
> that more packets were sent than were sent during the test, causing a failure.
> 
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-09  6:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 16:58 [dts] [PATCH] tests/stats_checks: clear xstats before starting testing ohilyard
2021-06-09  6:38 ` Tu, Lijuan

test suite reviews and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dts/0 dts/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dts dts/ https://inbox.dpdk.org/dts \
		dts@dpdk.org
	public-inbox-index dts

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dts


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git