diff --git a/test/lib/systestlib.py b/test/lib/systestlib.py index 3721455..1c1d8e4 100644 --- a/test/lib/systestlib.py +++ b/test/lib/systestlib.py @@ -66,9 +66,15 @@ def sort_dict_by_keys(self, d): def random_interface(dut, exclude=None): + # interfaces read in 'show run all' and those actually present may differ, + # thus interface list must be picked from the actually present + if not getattr( random_interface, 'present', False ): + random_interface.present = dut.run_commands( + 'show interfaces', send_enable=False )[ 0 ][ 'interfaces' ].keys() exclude = [] if exclude is None else exclude interfaces = dut.api('interfaces') - names = [name for name in list(interfaces.keys()) if name.startswith('Et')] + names = [ name for name in list(interfaces.keys()) if name.startswith('Et') ] + names = [ name for name in names if name in random_interface.present ] exclude_interfaces = dut.settings.get('exclude_interfaces', []) if exclude_interfaces: