Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sanity-check] Add IPv4 MGMT reachability check #16645

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/common/plugins/sanity_check/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'check_monit',
'check_secureboot',
'check_neighbor_macsec_empty',
'check_ipv4_mgmt',
'check_ipv6_mgmt',
'check_mux_simulator',
'check_orchagent_usage',
Expand Down Expand Up @@ -1036,6 +1037,42 @@ def _check(*args, **kwargs):
return _check


# check ipv4 neighbor reachability
@pytest.fixture(scope="module")
def check_ipv4_mgmt(duthosts, localhost):
def _check(*args, **kwargs):
init_result = {"failed": False, "check_item": "ipv4_mgmt"}
result = parallel_run(_check_ipv4_mgmt_to_dut, args, kwargs, duthosts, timeout=30, init_result=init_result)
return list(result.values())

def _check_ipv4_mgmt_to_dut(*args, **kwargs):
dut = kwargs['node']
results = kwargs['results']

logger.info("Checking ipv4 mgmt interface reachability on %s..." % dut.hostname)
check_result = {"failed": False, "check_item": "ipv4_mgmt", "host": dut.hostname}

if dut.mgmt_ip is None or dut.mgmt_ip == "":
logger.info("%s doesn't have ipv4 mgmt configured. Skip the ipv4 mgmt reachability check." % dut.hostname)
results[dut.hostname] = check_result
return

# most of the testbed should reply within 10 ms, Set the timeout to 2 seconds to reduce the impact of delay.
try:
shell_result = localhost.shell("ping -c 2 -W 2 " + dut.mgmt_ip)
logging.info("ping output: %s" % shell_result["stdout"])
except RunAnsibleModuleFail as e:
check_result["failed"] = True
logging.info("Failed to ping ipv4 mgmt interface on %s, exception: %s" % (dut.hostname, repr(e)))
except Exception as e:
check_result["failed"] = True
logger.info("Exception while checking ipv4_mgmt reachability for %s: %s" % (dut.hostname, repr(e)))
finally:
logger.info("Done checking ipv4 management reachability on %s" % dut.hostname)
results[dut.hostname] = check_result
return _check


# check ipv6 neighbor reachability
@pytest.fixture(scope="module")
def check_ipv6_mgmt(duthosts, localhost):
Expand Down
Loading