Skip to content

Commit

Permalink
smoketest: T6989: extend cli_set() signature to pass CLI node value
Browse files Browse the repository at this point in the history
  • Loading branch information
c-po committed Feb 2, 2025
1 parent 52623f5 commit 4af6c2f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
7 changes: 4 additions & 3 deletions smoketest/scripts/cli/base_vyostest_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ def tearDownClass(cls):
cls._session.discard()
cls.fail(cls)

def cli_set(self, config):
def cli_set(self, path, value=None):
if self.debug:
print('set ' + ' '.join(config))
self._session.set(config)
str = f'set {" ".join(path)} {value}' if value else f'set {" ".join(path)}'
print(str)
self._session.set(path, value)

def cli_delete(self, config):
if self.debug:
Expand Down
34 changes: 19 additions & 15 deletions smoketest/scripts/cli/test_system_syslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def tearDown(self):

def test_console(self):
level = 'warning'
self.cli_set(base_path + ['console', 'facility', 'all', 'level', level])
self.cli_set(base_path + ['console', 'facility', 'all', 'level'], value=level)
self.cli_commit()

rsyslog_conf = get_config()
Expand All @@ -73,7 +73,7 @@ def test_console(self):
for tmp in config:
self.assertIn(tmp, rsyslog_conf)

def test_global(self):
def test_basic(self):
hostname = 'vyos123'
domain_name = 'example.local'
default_marker_interval = default_value(base_path + ['marker', 'interval'])
Expand All @@ -84,13 +84,13 @@ def test_global(self):
'all': {'level': 'notice'},
}

self.cli_set(['system', 'host-name', hostname])
self.cli_set(['system', 'domain-name', domain_name])
self.cli_set(['system', 'host-name'], value=hostname)
self.cli_set(['system', 'domain-name'], value=domain_name)
self.cli_set(base_path + ['preserve-fqdn'])

for tmp, tmp_options in facility.items():
level = tmp_options['level']
self.cli_set(base_path + ['local', 'facility', tmp, 'level', level])
self.cli_set(base_path + ['local', 'facility', tmp, 'level'], value=level)

self.cli_commit()

Expand Down Expand Up @@ -148,20 +148,21 @@ def test_remote(self):
remote_base = base_path + ['remote', remote]

if 'port' in remote_options:
self.cli_set(remote_base + ['port', remote_options['port']])
self.cli_set(remote_base + ['port'], value=remote_options['port'])

if 'facility' in remote_options:
for facility, facility_options in remote_options['facility'].items():
level = facility_options['level']
self.cli_set(remote_base + ['facility', facility, 'level', level])
self.cli_set(remote_base + ['facility', facility, 'level'],
value=level)

if 'format' in remote_options:
for format in remote_options['format']:
self.cli_set(remote_base + ['format', format])
self.cli_set(remote_base + ['format'], value=format)

if 'protocol' in remote_options:
protocol = remote_options['protocol']
self.cli_set(remote_base + ['protocol', protocol])
self.cli_set(remote_base + ['protocol'], value=protocol)

self.cli_commit()

Expand Down Expand Up @@ -229,18 +230,21 @@ def test_vrf_source_address(self):
vrf = None
if 'vrf' in remote_options:
vrf = remote_options['vrf']['name']
self.cli_set(['vrf', 'name', vrf, 'table', remote_options['vrf']['table']])
self.cli_set(remote_base + ['vrf', vrf])
self.cli_set(['vrf', 'name', vrf, 'table'],
value=remote_options['vrf']['table'])
self.cli_set(remote_base + ['vrf'], value=vrf)

if 'source_address' in remote_options:
source_address = remote_options['source_address']
self.cli_set(remote_base + ['source-address', source_address])
self.cli_set(remote_base + ['source-address'],
value=source_address)

idx = source_address.split('.')[-1]
self.cli_set(['interfaces', 'dummy', f'dum{idx}', 'address', f'{source_address}/32'])
self.cli_set(['interfaces', 'dummy', f'dum{idx}', 'address'],
value=f'{source_address}/32')
if vrf:
self.cli_set(['interfaces', 'dummy', f'dum{idx}', 'vrf', vrf])

self.cli_set(['interfaces', 'dummy', f'dum{idx}', 'vrf'],
value=vrf)

self.cli_commit()
config = read_file(RSYSLOG_CONF)
Expand Down

0 comments on commit 4af6c2f

Please sign in to comment.