[PATCH LNST internal] recipes: switchdev: RedTestLib: Check actual send rate

Nogah Frankel nogahf at mellanox.com
Sun Apr 29 23:17:32 AEST 2018


Check the actual send rate when sending traffic. If it is much lower than
the wanted one, fail the test.
Note that this fail means that the setup isn't strong enough to run the RED
tests, not that they found a problem.

Signed-off-by: Nogah Frankel <nogahf at mellanox.com>
---
 recipes/switchdev/RedTestLib.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/recipes/switchdev/RedTestLib.py b/recipes/switchdev/RedTestLib.py
index 56fad43..45ac907 100644
--- a/recipes/switchdev/RedTestLib.py
+++ b/recipes/switchdev/RedTestLib.py
@@ -9,6 +9,7 @@ nogahf at mellanox.com (Nogah Frankel)
 """
 
 from time import sleep
+import datetime
 import logging
 from lnst.Controller.Task import ctl
 
@@ -201,8 +202,16 @@ class RedTestLib:
         if self.router:
             args["dst"] = self.links[self.egress_port].get_ip()
             args["dst_mac"] = self.ingress_port.get_hwaddr()
+        start_time = datetime.datetime.now()
         self.tl.pktgen(self.links[self.ingress_port],
                        self.links[self.egress_port], pkt_size, **args)
+        end_time = datetime.datetime.now()
+        # Approximate rate in mega bits per second
+        actual_rate = int(pkt_size) * 8./(end_time - start_time).total_seconds()
+        if actual_rate < self.rate * 0.8:
+            raise Exception("Actual send rate %d is much lower then asked for %d\n"
+                            "Please run on stronger machine" % (actual_rate,
+                            self.rate))
         sleep(3)
 
         rx_after = self.ingress_port.link_stats()["rx_packets"]
-- 
2.4.11



More information about the Linux-mlxsw mailing list