Some of the recipes inheriting from the BaseTunnelRecipe may not require packet assert test. This could be solved by not including the PacketAssertTestAndEvaluate in the BaseTunnelRecipe inheritance but I plan to send additional tests that use the packet assert test and it's probably better to add a condition to execute the test.
The BaseTunnelRecipe is modified to perform the packet assert test only if the get_packet_assert_config() of the derived class returns anything other than None value.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Recipes/ENRT/BaseTunnelRecipe.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lnst/Recipes/ENRT/BaseTunnelRecipe.py b/lnst/Recipes/ENRT/BaseTunnelRecipe.py index 4a354a9d..d4bb6962 100644 --- a/lnst/Recipes/ENRT/BaseTunnelRecipe.py +++ b/lnst/Recipes/ENRT/BaseTunnelRecipe.py @@ -111,11 +111,15 @@ class BaseTunnelRecipe(
def ping_test(self, ping_configs): pa_config = self.get_packet_assert_config(ping_configs[0]) - self.packet_assert_test_start(pa_config) - self.ctl.wait(2) + if pa_config is not None: + self.packet_assert_test_start(pa_config) + self.ctl.wait(2) ping_result = super().ping_test(ping_configs) - self.ctl.wait(2) - pa_result = self.packet_assert_test_stop() + if pa_config is not None: + self.ctl.wait(2) + pa_result = self.packet_assert_test_stop() + else: + pa_result = None
result = ((ping_result, pa_config, pa_result),)
@@ -124,7 +128,8 @@ class BaseTunnelRecipe( def ping_report_and_evaluate(self, results): for res in results: super().ping_report_and_evaluate(res[0]) - self.packet_assert_evaluate_and_report(res[1], res[2]) + if res[1] is not None: + self.packet_assert_evaluate_and_report(res[1], res[2])
def get_packet_assert_config(self, ping_config): """