diff options
| author | Christian Breunig <christian@breunig.cc> | 2024-12-16 22:25:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-16 22:25:29 +0100 |
| commit | 1da518c1100254b14b064de68844cfea372ea6ec (patch) | |
| tree | fe046cf9358c4258faf00910401783ddfaf26747 /smoketest/scripts/cli/base_vyostest_shim.py | |
| parent | 86b528863585e62fd398d05aa1a2e1a64dae0e45 (diff) | |
| parent | 90e9aa9df41c3b99f9f1421227a1f1474622b918 (diff) | |
| download | vyos-1x-1da518c1100254b14b064de68844cfea372ea6ec.tar.gz vyos-1x-1da518c1100254b14b064de68844cfea372ea6ec.zip | |
Merge pull request #4227 from c-po/T6746-frr-10
frr: upgrade to 10.2 and migrate protocols to unified FRRender class
Diffstat (limited to 'smoketest/scripts/cli/base_vyostest_shim.py')
| -rw-r--r-- | smoketest/scripts/cli/base_vyostest_shim.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py index a383e596c..d95071d1a 100644 --- a/smoketest/scripts/cli/base_vyostest_shim.py +++ b/smoketest/scripts/cli/base_vyostest_shim.py @@ -18,6 +18,7 @@ import paramiko import pprint from time import sleep +from time import time from typing import Type from vyos.configsession import ConfigSession @@ -43,7 +44,7 @@ class VyOSUnitTestSHIM: # trigger the certain failure condition. # Use "self.debug = True" in derived classes setUp() method debug = False - + commit_guard = time() @classmethod def setUpClass(cls): cls._session = ConfigSession(os.getpid()) @@ -87,6 +88,8 @@ class VyOSUnitTestSHIM: # during a commit there is a process opening commit_lock, and run() returns 0 while run(f'sudo lsof -nP {commit_lock}') == 0: sleep(0.250) + # reset getFRRconfig() guard timer + self.commit_guard = time() def op_mode(self, path : list) -> None: """ @@ -101,14 +104,29 @@ class VyOSUnitTestSHIM: pprint.pprint(out) return out - def getFRRconfig(self, string=None, end='$', endsection='^!', daemon=''): + def getFRRconfig(self, string=None, end='$', endsection='^!', daemon='', guard_time=10, empty_retry=0): """ 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 10 second guard timer + # between the last cli_commit() and the first read of FRR config via vtysh + while (time() - self.commit_guard) < guard_time: + sleep(0.250) # wait 250 milliseconds command = f'vtysh -c "show run {daemon} no-header"' if string: command += f' | sed -n "/^{string}{end}/,/{endsection}/p"' out = cmd(command) if self.debug: print(f'\n\ncommand "{command}" returned:\n') pprint.pprint(out) + if empty_retry: + retry_count = 0 + while not out and retry_count < empty_retry: + if self.debug and retry_count % 10 == 0: + print(f"Attempt {retry_count}: FRR config is still empty. Retrying...") + retry_count += 1 + sleep(1) + out = cmd(command) + if not out: + print(f'FRR configuration still empty after {empty_retry} retires!') return out @staticmethod |
