From: Ondrej Lichtner <olichtne(a)redhat.com>
Adding the count, interval and size parameters to the PingConf class.
The Ping test module has default values defined for these but the tester
should have the ability to override them when using the common
PingTestAndEvaluate class.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/RecipeCommon/Ping.py | 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping.py
index 0f9f800..7599b66 100644
--- a/lnst/RecipeCommon/Ping.py
+++ b/lnst/RecipeCommon/Ping.py
@@ -4,11 +4,15 @@ from lnst.Tests import Ping
class PingConf(object):
def __init__(self,
client, client_bind,
- destination, destination_address):
+ destination, destination_address,
+ count=None, interval=None, size=None):
self._client = client
self._client_bind = client_bind
self._destination = destination
self._destination_address = destination_address
+ self._count = count
+ self._interval = interval
+ self._size = size
@property
def client(self):
@@ -26,13 +30,24 @@ class PingConf(object):
def destination_address(self):
return self._destination_address
+ @property
+ def count(self):
+ return self._count
+
+ @property
+ def interval(self):
+ return self._interval
+
+ @property
+ def size(self):
+ return self._size
+
class PingTestAndEvaluate(BaseRecipe):
def ping_test(self, ping_config):
client = ping_config.client
destination = ping_config.destination
- ping = Ping(dst = ping_config.destination_address,
- interface = ping_config.client_bind)
+ ping = Ping(self._generate_ping_kwargs(ping_config))
ping_job = client.run(ping)
return ping_job.result
@@ -43,3 +58,17 @@ class PingTestAndEvaluate(BaseRecipe):
self.add_result(True, "Ping succesful", results)
else:
self.add_result(False, "Ping unsuccesful", results)
+
+ def _generate_ping_kwargs(self, ping_config):
+ kwargs = dict(dst=ping_config.destination_address,
+ interface=ping_config.client_bind)
+
+ if ping_config.count:
+ kwargs["count"] = ping_config.count
+
+ if ping_config.interval:
+ kwargs["interval"] = ping_config.interval
+
+ if ping_config.size:
+ kwargs["size"] = ping_config.size
+ return kwargs
--
2.17.0