Mon, May 21, 2018 at 10:42:45AM CEST, olichtne(a)redhat.com wrote:
From: Ondrej Lichtner <olichtne(a)redhat.com>
Renamed the IcmpPing testmodule as just Ping. Implements the Ping
TestModule class that can be used to test connectivity between hosts.
The module returns statistics on the measured success rate of the Ping.
The PASS/FAIL of the Ping testmodule job indicates whether or not the
measurement was succesfull, actual connectivity status needs to be
evaluated outside of this class.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
diff --git a/lnst/Tests/Ping.py b/lnst/Tests/Ping.py
new file mode 100644
index 0000000..f2dabe3
--- /dev/null
+++ b/lnst/Tests/Ping.py
@@ -0,0 +1,93 @@
+ match = re.search(stat_pttr1, stdout)
+ if not match:
+ self._res_data = {"msg": "expected pattern not found"}
+ logging.error(self._res_data["msg"])
+ return False
+ else:
+ trans_pkts, recv_pkts = match.groups()
+ rate = int(round((float(recv_pkts) / float(trans_pkts)) * 100))
+ logging.debug("Transmitted '{}', received '{}', "
+ "rate '{}%'".format(trans_pkts, recv_pkts,
rate))
+
+ self._res_data = {"trans_pkts": trans_pkts,
+ "recv_pkts": recv_pkts,
+ "rate": rate}
+
+ match = re.search(stat_pttr2, stdout)
+ if match:
+ tmin, tavg, tmax, tmdev = [float(x) for x in match.groups()]
+ logging.debug("rtt min \"%.3f\", avg \"%.3f\", max
\"%.3f\", "
+ "mdev \"%.3f\"" % (tmin, tavg, tmax,
tmdev))
+
+ self._res_data["rtt_min"] = tmin
+ self._res_data["rtt_max"] = tmax
+ self._res_data["rtt_avg"] = tavg
+ self._res_data["rtt_mdev"] = tmdev
missing "if not match" as in stat_pttr1 matching