Skip to content

Commit

Permalink
smoketest: T6747: call wait after commit() only for FRR related tests
Browse files Browse the repository at this point in the history
Commit 702a60a ("smoketest: T6746: wait after commit() until frr-reload
is no longer running") added a guard timeout for every commit executed via CLI
smoketests. This commit changes the bahavior to only add the guard timeout
for FRR related testscases.

This improves the overall smoketest time.
  • Loading branch information
c-po committed Jan 4, 2025
1 parent 9dae22e commit fb87278
Show file tree
Hide file tree
Showing 21 changed files with 101 additions and 11 deletions.
4 changes: 4 additions & 0 deletions smoketest/scripts/cli/base_interfaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from netifaces import ifaddresses

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.defaults import directories
Expand Down Expand Up @@ -181,6 +182,9 @@ def setUpClass(cls):
section = Section.section(span)
cls.cli_set(cls, ['interfaces', section, span])

# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

@classmethod
def tearDownClass(cls):
# Tear down mirror interfaces for SPAN (Switch Port Analyzer)
Expand Down
5 changes: 4 additions & 1 deletion smoketest/scripts/cli/base_vyostest_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class TestCase(unittest.TestCase):
# trigger the certain failure condition.
# Use "self.debug = True" in derived classes setUp() method
debug = False
# Time to wait after a commit to ensure the CStore is up to date
# only required for testcases using FRR
_commit_guard_time = 0
@classmethod
def setUpClass(cls):
cls._session = ConfigSession(os.getpid())
Expand Down Expand Up @@ -96,7 +99,7 @@ def cli_commit(self):
while run(f'sudo lsof -nP {commit_lock}') == 0:
sleep(0.250)
# Wait for CStore completion for fast non-interactive commits
sleep(CSTORE_GUARD_TIME)
sleep(self._commit_guard_time)

def op_mode(self, path : list) -> None:
"""
Expand Down
14 changes: 13 additions & 1 deletion smoketest/scripts/cli/test_policy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2021-2023 VyOS maintainers and contributors
# Copyright (C) 2021-2025 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand All @@ -17,13 +17,25 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.utils.process import cmd

base_path = ['policy']

class TestPolicy(VyOSUnitTestSHIM.TestCase):
@classmethod
def setUpClass(cls):
super(TestPolicy, cls).setUpClass()

# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
cls.cli_delete(cls, ['vrf'])
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
self.cli_delete(base_path)
self.cli_commit()
Expand Down
5 changes: 4 additions & 1 deletion smoketest/scripts/cli/test_policy_local-route.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2024 VyOS maintainers and contributors
# Copyright (C) 2024-2025 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand All @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

interface = 'eth0'
mark = '100'
Expand All @@ -32,6 +33,8 @@ def setUpClass(cls):
# Clear out current configuration to allow running this test on a live system
cls.cli_delete(cls, ['policy', 'local-route'])
cls.cli_delete(cls, ['policy', 'local-route6'])
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

cls.cli_set(cls, ['vrf', 'name', vrf_name, 'table', vrf_rt_id])

Expand Down
5 changes: 4 additions & 1 deletion smoketest/scripts/cli/test_policy_route.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2021-2023 VyOS maintainers and contributors
# Copyright (C) 2021-2025 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand All @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

mark = '100'
conn_mark = '555'
Expand All @@ -36,6 +37,8 @@ def setUpClass(cls):
# Clear out current configuration to allow running this test on a live system
cls.cli_delete(cls, ['policy', 'route'])
cls.cli_delete(cls, ['policy', 'route6'])
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

cls.cli_set(cls, ['interfaces', 'ethernet', interface, 'address', interface_ip])
cls.cli_set(cls, ['protocols', 'static', 'table', table_id, 'route', '0.0.0.0/0', 'interface', interface])
Expand Down
3 changes: 3 additions & 0 deletions smoketest/scripts/cli/test_protocols_babel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.ifconfig import Section
from vyos.frrender import babel_daemon
Expand All @@ -38,6 +39,8 @@ def setUpClass(cls):
cls.cli_delete(cls, base_path)
cls.cli_delete(cls, ['policy', 'prefix-list'])
cls.cli_delete(cls, ['policy', 'prefix-list6'])
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
# always destroy the entire babel configuration to make the processes
Expand Down
7 changes: 6 additions & 1 deletion smoketest/scripts/cli/test_protocols_bfd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2021-2023 VyOS maintainers and contributors
# Copyright (C) 2021-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand All @@ -17,6 +17,8 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.frrender import bfd_daemon
from vyos.utils.process import process_named_running
Expand Down Expand Up @@ -86,6 +88,9 @@ def setUpClass(cls):
# Retrieve FRR daemon PID - it is not allowed to crash, thus PID must remain the same
cls.daemon_pid = process_named_running(bfd_daemon)

# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
Expand Down
4 changes: 4 additions & 0 deletions smoketest/scripts/cli/test_protocols_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from time import sleep

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.ifconfig import Section
from vyos.configsession import ConfigSessionError
Expand Down Expand Up @@ -200,6 +201,9 @@ def setUpClass(cls):
cls.cli_set(cls, ['policy', 'prefix-list6', prefix_list_out6, 'rule', '10', 'action', 'deny'])
cls.cli_set(cls, ['policy', 'prefix-list6', prefix_list_out6, 'rule', '10', 'prefix', '2001:db8:2000::/64'])

# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

@classmethod
def tearDownClass(cls):
cls.cli_delete(cls, ['policy', 'route-map'])
Expand Down
6 changes: 5 additions & 1 deletion smoketest/scripts/cli/test_protocols_isis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2021-2024 VyOS maintainers and contributors
# Copyright (C) 2021-2025 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand All @@ -17,6 +17,8 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
from vyos.utils.process import process_named_running
Expand All @@ -38,6 +40,8 @@ def setUpClass(cls):
# out the current configuration :)
cls.cli_delete(cls, base_path)
cls.cli_delete(cls, ['vrf'])
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
# cleanup any possible VRF mess
Expand Down
5 changes: 4 additions & 1 deletion smoketest/scripts/cli/test_protocols_mpls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
from vyos.frrender import ldpd_daemon
Expand Down Expand Up @@ -72,10 +74,11 @@ def setUpClass(cls):

# Retrieve FRR daemon PID - it is not allowed to crash, thus PID must remain the same
cls.daemon_pid = process_named_running(ldpd_daemon)

# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
self.cli_delete(base_path)
Expand Down
4 changes: 4 additions & 0 deletions smoketest/scripts/cli/test_protocols_openfabric.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.utils.process import process_named_running
from vyos.frrender import openfabric_daemon
Expand All @@ -40,6 +42,8 @@ def setUpClass(cls):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
self.cli_delete(base_path)
Expand Down
3 changes: 3 additions & 0 deletions smoketest/scripts/cli/test_protocols_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from time import sleep
from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
Expand Down Expand Up @@ -45,6 +46,8 @@ def setUpClass(cls):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

@classmethod
def tearDownClass(cls):
Expand Down
3 changes: 3 additions & 0 deletions smoketest/scripts/cli/test_protocols_ospfv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
Expand Down Expand Up @@ -44,6 +45,8 @@ def setUpClass(cls):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

@classmethod
def tearDownClass(cls):
Expand Down
11 changes: 11 additions & 0 deletions smoketest/scripts/cli/test_protocols_pim.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.frrender import pim_daemon
Expand All @@ -26,6 +27,16 @@
base_path = ['protocols', 'pim']

class TestProtocolsPIM(VyOSUnitTestSHIM.TestCase):
@classmethod
def setUpClass(cls):
# call base-classes classmethod
super(TestProtocolsPIM, cls).setUpClass()
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
# pimd process must be running
self.assertTrue(process_named_running(pim_daemon))
Expand Down
4 changes: 4 additions & 0 deletions smoketest/scripts/cli/test_protocols_pim6.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.ifconfig import Section
from vyos.frrender import pim6_daemon
Expand All @@ -34,6 +36,8 @@ def setUpClass(cls):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
self.cli_delete(base_path)
Expand Down
3 changes: 3 additions & 0 deletions smoketest/scripts/cli/test_protocols_rip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.ifconfig import Section
from vyos.frrender import rip_daemon
Expand All @@ -39,6 +40,8 @@ def setUpClass(cls):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

cls.cli_set(cls, ['policy', 'access-list', acl_in, 'rule', '10', 'action', 'permit'])
cls.cli_set(cls, ['policy', 'access-list', acl_in, 'rule', '10', 'source', 'any'])
Expand Down
5 changes: 4 additions & 1 deletion smoketest/scripts/cli/test_protocols_ripng.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2021-2023 VyOS maintainers and contributors
# Copyright (C) 2021-2025 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand All @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.ifconfig import Section
from vyos.frrender import ripng_daemon
Expand All @@ -40,6 +41,8 @@ def setUpClass(cls):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

cls.cli_set(cls, ['policy', 'access-list6', acl_in, 'rule', '10', 'action', 'permit'])
cls.cli_set(cls, ['policy', 'access-list6', acl_in, 'rule', '10', 'source', 'any'])
Expand Down
3 changes: 3 additions & 0 deletions smoketest/scripts/cli/test_protocols_rpki.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

from base_vyostest_shim import VyOSUnitTestSHIM
from base_vyostest_shim import CSTORE_GUARD_TIME

from vyos.configsession import ConfigSessionError
from vyos.frrender import bgp_daemon
Expand Down Expand Up @@ -111,6 +112,8 @@ def setUpClass(cls):
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
cls.cli_delete(cls, base_path)
# Enable CSTORE guard time required by FRR related tests
cls._commit_guard_time = CSTORE_GUARD_TIME

def tearDown(self):
self.cli_delete(base_path)
Expand Down
Loading

0 comments on commit fb87278

Please sign in to comment.