|
| 1 | +import pytest |
| 2 | +import logging |
| 3 | + |
| 4 | +from tests.common.utilities import wait_until |
| 5 | +from tests.common.helpers.assertions import pytest_assert |
| 6 | +from isis_helpers import DEFAULT_ISIS_INSTANCE as isis_instance |
| 7 | +from isis_helpers import get_nbr_name |
| 8 | + |
| 9 | + |
| 10 | +logger = logging.getLogger(__name__) |
| 11 | + |
| 12 | + |
| 13 | +pytestmark = [ |
| 14 | + pytest.mark.topology('wan-com'), |
| 15 | +] |
| 16 | + |
| 17 | + |
| 18 | +def disable_neighbor_isis(nbr_host, interface_name): |
| 19 | + out = nbr_host.eos_config( |
| 20 | + lines=['no isis enable'], |
| 21 | + parents=['interface {}'.format(interface_name)]) |
| 22 | + logging.info('Disable neighbor isis config') |
| 23 | + return out |
| 24 | + |
| 25 | + |
| 26 | +def check_isis_neighbor(duthost, nbr_name, state): |
| 27 | + isis_facts = duthost.isis_facts()["ansible_facts"]['isis_facts'] |
| 28 | + if isis_instance not in isis_facts['neighbors']: |
| 29 | + logger.info("Failed to isis instance {} in dut {}.".format(isis_instance, duthost.hostname)) |
| 30 | + return False |
| 31 | + |
| 32 | + if state == 'Up' and nbr_name not in isis_facts['neighbors'][isis_instance]: |
| 33 | + return False |
| 34 | + |
| 35 | + if state == 'Up' and isis_facts['neighbors'][isis_instance][nbr_name]['state'] == 'Up': |
| 36 | + return True |
| 37 | + |
| 38 | + if state == 'Down' and nbr_name not in isis_facts['neighbors'][isis_instance]: |
| 39 | + return True |
| 40 | + |
| 41 | + logger.info("Failed to nbr {} in dut {}.".format(nbr_name, duthost.hostname)) |
| 42 | + return False |
| 43 | + |
| 44 | + |
| 45 | +# IS-IS neighbor default IS-IS interval is 10s and multiplier is 3 |
| 46 | +def test_isis_holdtime(isis_common_setup_teardown, nbrhosts): |
| 47 | + selected_connections = isis_common_setup_teardown |
| 48 | + (dut_host, dut_port, nbr_host, nbr_port) = selected_connections[0] |
| 49 | + |
| 50 | + nbr_name = get_nbr_name(nbrhosts, nbr_host) |
| 51 | + pytest_assert(wait_until(10, 2, 0, check_isis_neighbor, dut_host, nbr_name, 'Up'), |
| 52 | + "ISIS Neighbor {} is not Up state".format(nbr_name)) |
| 53 | + |
| 54 | + # Disable IS-IS config under PortChannel in neighbor device |
| 55 | + disable_neighbor_isis(nbr_host, nbr_port) |
| 56 | + |
| 57 | + pytest_assert(wait_until(30, 2, 1, check_isis_neighbor, dut_host, nbr_name, 'Down'), |
| 58 | + "ISIS Neighbor {} is not Down state".format(nbr_name)) |
0 commit comments