On Wed, May 15, 2019 at 01:44:05PM +0200, csfakian(a)redhat.com wrote:
From: Christos Sfakianakis <csfakian(a)redhat.com>
Add a module to inititate and evaluate a PacketAssert test.
Signed-off-by: Christos Sfakianakis <csfakian(a)redhat.com>
---
lnst/RecipeCommon/PacketAssert.py | 76 +++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
create mode 100644 lnst/RecipeCommon/PacketAssert.py
diff --git a/lnst/RecipeCommon/PacketAssert.py b/lnst/RecipeCommon/PacketAssert.py
new file mode 100644
index 0000000..bf99c36
--- /dev/null
+++ b/lnst/RecipeCommon/PacketAssert.py
@@ -0,0 +1,76 @@
+from lnst.Controller.Recipe import BaseRecipe
+from lnst.Tests import PacketAssert
+
+class PacketAssertConf(object):
+ def __init__(self, host, iface, **kwargs):
+ self._host = host
+ self._iface = iface
+ self._p_filter = kwargs.get("p_filter", '')
+ self._grep_for = kwargs.get("grep_for", [])
+ self._p_min = kwargs.get("p_min", 10)
+ self._p_max = kwargs.get("p_max", 0)
+ self._promiscuous = kwargs.get("promiscuous", False)
+
+ @property
+ def host(self):
+ return self._host
+
+ @property
+ def iface(self):
+ return self._iface
+
+ @property
+ def p_filter(self):
+ return self._p_filter
+
+ @property
+ def grep_for(self):
+ return self._grep_for
+
+ @property
+ def p_min(self):
+ return self._p_min
+
+ @property
+ def p_max(self):
+ return self._p_max
+
+ @property
+ def promiscuous(self):
+ return self._promiscuous
+
+class PacketAssertTestAndEvaluate(BaseRecipe):
+ def packet_assert_test(self, packet_assert_config):
+ host = packet_assert_config.host
+ kwargs = self._generate_packet_assert_kwargs(packet_assert_config)
+ packet_assert = PacketAssert(**kwargs)
+ packet_assert_job = host.prepare_job(packet_assert)
+ return packet_assert_job
The design of this method is a bit confusing I think, the common Ping
and Perf recipes are standalone so their "test" method is self contained
- it both starts and finishes the test.
Here the PacketAssert test method only starts it and returns a job but
something else is supposed to wait on it? That's kind of not intuitive
from how the method is called.
I think it might make sense to rename this method to somehow indicate
the "start" of a test and then add a "stop" or "finish"
method. And in
that case, returning the running PacketAssert job from the start method
also wouldn't make sense - just keep it within the class instance and
use if from the stop method.
-Ondrej