Skip to content

Commit

Permalink
frr: T6746: add guard time after commit() and before getFRRconfig()
Browse files Browse the repository at this point in the history
As vyos-configd will take care about the commit via FRRender class, and FRR
needs to internally process the configuration we might read it back via
vtysh "to fast". Add a 5 seconds guard timer after each commit() and
before calling getFRRconfig().

Guard timer is reset with each commit().
  • Loading branch information
c-po committed Dec 13, 2024
1 parent 17ca572 commit a7b1d33
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions smoketest/scripts/cli/base_vyostest_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pprint

from time import sleep
from time import time
from typing import Type

from vyos.configsession import ConfigSession
Expand All @@ -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())
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit a7b1d33

Please sign in to comment.