diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py index affa538774f..f758977cfe9 100644 --- a/smoketest/scripts/cli/base_vyostest_shim.py +++ b/smoketest/scripts/cli/base_vyostest_shim.py @@ -18,6 +18,7 @@ import pprint from time import sleep +from time import time from typing import Type from vyos.configsession import ConfigSession @@ -43,7 +44,7 @@ class TestCase(unittest.TestCase): # trigger the certain failure condition. # Use "self.debug = True" in derived classes setUp() method debug = False - + commit_guard = 0 @classmethod def setUpClass(cls): cls._session = ConfigSession(os.getpid()) @@ -81,6 +82,7 @@ def cli_discard(self): self._session.discard() def cli_commit(self): + self.commit_guard = time() if self.debug: print('commit') self._session.commit() @@ -104,8 +106,9 @@ def op_mode(self, path : list) -> None: def getFRRconfig(self, string=None, end='$', endsection='^!', daemon=''): """ Retrieve current "running configuration" from FRR """ # Sometimes FRR needs some time after reloading the configuration to - # appear in vtysh. This is a workaround addiung a 2 seconds guard timer - sleep(2) + # appear in vtysh. This is a workaround addiung a 5 seconds guard timer + while time() - self.commit_guard < 5: + sleep(0.250) command = f'vtysh -c "show run {daemon} no-header"' if string: command += f' | sed -n "/^{string}{end}/,/{endsection}/p"' out = cmd(command)