From: Jozef Urbanovsky <jurbanov(a)redhat.com>
Signed-off-by: Jozef Urbanovsky <jurbanov(a)redhat.com>
---
lnst/RecipeCommon/PacketAssert.py | 27 +++++++++++++++++++++++++++
lnst/Tests/PacketAssert.py | 20 ++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/lnst/RecipeCommon/PacketAssert.py b/lnst/RecipeCommon/PacketAssert.py
index 689250e..b42be74 100644
--- a/lnst/RecipeCommon/PacketAssert.py
+++ b/lnst/RecipeCommon/PacketAssert.py
@@ -4,6 +4,17 @@ from lnst.Tests import PacketAssert
from lnst.Common.LnstError import LnstError
class PacketAssertConf(object):
+ """
+ Class for the configuration of the :any:`PacketAssert` class
+
+ :param host: client in :any:`PingConf` object used to specify host for the ping test
+ :param iface: interface used for the ping test
+ :param p_filter: string representation of desired packets in dump
+ :param grep_for: string representation of the content of given packet in dump
+ :param p_min: minimum count of the packets to be found in the dump
+ :param p_max: maximum count of the packets to be found in the dump
+ :param promiscuous: toggle of promiscuous mode
+ """
def __init__(self, host, iface, **kwargs):
self._host = host
self._iface = iface
@@ -42,9 +53,19 @@ class PacketAssertConf(object):
return self._promiscuous
class PacketAssertTestAndEvaluate(BaseRecipe):
+ """
+ Class to control and execute :any:`PacketAssert` test.
+ """
started_job = None
def packet_assert_test_start(self, packet_assert_config):
+ """
+ Method starts a :any:`PacketAssert` job and stores ***started_job*** attribute
+ containing LNST :any:`Job: object.
+
+ :param packet_assert_config: configuration in a form of :any:`PacketAssertConf`
+ class
+ """
if self.started_job:
raise LnstError("Only 1 packet_assert job is allowed to run at a
time.")
@@ -54,6 +75,12 @@ class PacketAssertTestAndEvaluate(BaseRecipe):
self.started_job = host.prepare_job(packet_assert).start(bg=True)
def packet_assert_test_stop(self):
+ """
+ Method kills a process executing :any:`PacketAssert` job and
+ resets the value of the ***started_job*** attribute.
+
+ :return: result of the packet assert
+ """
if not self.started_job:
raise LnstError("No packet_assert job is running.")
diff --git a/lnst/Tests/PacketAssert.py b/lnst/Tests/PacketAssert.py
index 25a92ba..901fdc0 100644
--- a/lnst/Tests/PacketAssert.py
+++ b/lnst/Tests/PacketAssert.py
@@ -8,6 +8,19 @@ from lnst.Tests.BaseTestModule import BaseTestModule
from lnst.Common.LnstError import LnstError
class PacketAssert(BaseTestModule):
+ """
+ Class to control tcpdump test
+
+ This class runs tcpdump and searches through its output in order
+ to evaluate whether specified packets are traversing the network stack.
+
+ :param interface: interface used for the :any:`PacketAssert` test
+ :param p_filter: string representation of desired packets in dump
+ :param grep_for: string representation of the content of given packet in dump
+ :param promiscuous: toggle of promiscuous mode
+ :param grep_exprs: concatenated expression to be used by grep for search
+ :param p_recv: amount of received packets
+ """
interface = DeviceParam(mandatory=True)
p_filter = StrParam(default='')
grep_for = ListParam(default=[])
@@ -57,6 +70,13 @@ class PacketAssert(BaseTestModule):
return False
def run(self):
+ """
+ Method used for the control of :any:`PacketAssert` test.
+ Process with tcpdump is spawned and its output is digested
+ in order to find and count specified packets through grep expressions.
+
+ :return: result of the run
+ """
self._res_data = {}
if not is_installed("tcpdump"):
self._res_data["msg"] = "tcpdump is not installed on this
machine!"
--
2.25.4