Skip to content

Commit 0bb5d8e

Browse files
authored
netlab validate: Allow the use of regular expressions for tests to execute (ipspace#2474)
For example: .*v4 to run only ipv4 tests (suitably named)
1 parent 1c85607 commit 0bb5d8e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/cli-overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ The following programs, scripts and Ansible playbooks are included with *netlab*
3131

3232
**netlab exec**
3333
: Use Ansible inventory to connect to one or more lab devices using the inventory names and executes an arbitrary command on them. Device IP address (**ansible_host**) and username/passwords are retrieved from Ansible inventory. Ideal when you use centralized Vagrant or Clab environments and want to execute commands on the devices. [More details...](netlab/exec.md)
34+
35+
**netlab validate**
36+
: Run validation tests included with the topology. A subset of tests can be selected by using one or more test names, or a regular expression [More details...](topology/validate.md)

netsim/cli/validate.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,19 +1047,20 @@ def execute_validation_test(
10471047
def filter_by_tests(args: argparse.Namespace, topology: Box) -> None:
10481048
if not args.tests:
10491049
return
1050-
1050+
tests_to_execute = {}
10511051
for t in args.tests:
1052-
find_test = [ v_entry for v_entry in topology.validate if v_entry.name == t ]
1052+
find_test = { v_entry.name: v_entry for v_entry in topology.validate if re.match(t,v_entry.name) }
10531053
if not find_test:
10541054
log.error(
1055-
f'Invalid test name {t}, use "netlab validate --list" to list test names',
1055+
f'Invalid test name or regex expression {t}, use "netlab validate --list" to list test names',
10561056
category=log.IncorrectValue,
10571057
module='validation')
1058+
tests_to_execute.update(find_test)
10581059

10591060
if log.pending_errors():
10601061
return
10611062

1062-
topology.validate = [ v_entry for v_entry in topology.validate if v_entry.name in args.tests ]
1063+
topology.validate = tests_to_execute.values()
10631064

10641065
'''
10651066
filter_by_nodes: select only tests executed on specified node

0 commit comments

Comments
 (0)