Skip to content

Commit

Permalink
T6671: add smoketest for dependency deferred to priority
Browse files Browse the repository at this point in the history
  • Loading branch information
jestabro committed Aug 25, 2024
1 parent 4f0e026 commit 9ff620c
Showing 1 changed file with 83 additions and 2 deletions.
85 changes: 83 additions & 2 deletions smoketest/scripts/cli/test_config_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,39 @@


import unittest
from time import sleep

from base_vyostest_shim import VyOSUnitTestSHIM

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

from base_vyostest_shim import VyOSUnitTestSHIM


class TestConfigDep(VyOSUnitTestSHIM.TestCase):
@classmethod
def setUpClass(cls):
# smoketests are run without configd in 1.4; with configd in 1.5
# the tests below check behavior under configd:
# test_configdep_error checks for regression under configd (T6559)
# test_configdep_prio_queue checks resolution under configd (T6671)
cls.running_state = is_systemd_service_running('vyos-configd.service')

if not cls.running_state:
cmd('sudo systemctl start vyos-configd.service')
# allow time for init
sleep(1)

super(TestConfigDep, cls).setUpClass()

@classmethod
def tearDownClass(cls):
super(TestConfigDep, cls).tearDownClass()

# return to running_state
if not cls.running_state:
cmd('sudo systemctl stop vyos-configd.service')

def test_configdep_error(self):
address_group = 'AG'
address = '192.168.137.5'
Expand All @@ -45,5 +71,60 @@ def test_configdep_error(self):
self.cli_delete(['nat'])
self.cli_commit()

def test_configdep_prio_queue(self):
# confirm that that a dependency (in this case, conntrack ->
# conntrack-sync) is not immediately called if the target is
# scheduled in the priority queue, indicating that it may require an
# intermediate activitation (bond0)
bonding_base = ['interfaces', 'bonding']
bond_interface = 'bond0'
bond_address = '192.0.2.1/24'
vrrp_group_base = ['high-availability', 'vrrp', 'group']
vrrp_sync_group_base = ['high-availability', 'vrrp', 'sync-group']
vrrp_group = 'ETH2'
vrrp_sync_group = 'GROUP'
conntrack_sync_base = ['service', 'conntrack-sync']
conntrack_peer = '192.0.2.77'

# simple set to trigger in-session conntrack -> conntrack-sync
# dependency; note that this is triggered on boot in 1.4 due to
# default 'system conntrack modules'
self.cli_set(['system', 'conntrack', 'table-size', '524288'])

self.cli_set(['interfaces', 'ethernet', 'eth2', 'address',
'198.51.100.2/24'])

self.cli_set(bonding_base + [bond_interface, 'address',
bond_address])
self.cli_set(bonding_base + [bond_interface, 'member', 'interface',
'eth3'])

self.cli_set(vrrp_group_base + [vrrp_group, 'address',
'198.51.100.200/24'])
self.cli_set(vrrp_group_base + [vrrp_group, 'hello-source-address',
'198.51.100.2'])
self.cli_set(vrrp_group_base + [vrrp_group, 'interface', 'eth2'])
self.cli_set(vrrp_group_base + [vrrp_group, 'priority', '200'])
self.cli_set(vrrp_group_base + [vrrp_group, 'vrid', '22'])
self.cli_set(vrrp_sync_group_base + [vrrp_sync_group, 'member',
vrrp_group])

self.cli_set(conntrack_sync_base + ['failover-mechanism', 'vrrp',
'sync-group', vrrp_sync_group])

self.cli_set(conntrack_sync_base + ['interface', bond_interface,
'peer', conntrack_peer])

self.cli_commit()

# clean up
self.cli_delete(bonding_base)
self.cli_delete(vrrp_group_base)
self.cli_delete(vrrp_sync_group_base)
self.cli_delete(conntrack_sync_base)
self.cli_delete(['interfaces', 'ethernet', 'eth2', 'address'])
self.cli_delete(['system', 'conntrack', 'table-size'])
self.cli_commit()

if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit 9ff620c

Please sign in to comment.