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

SNMP link-local test: wait until snmp agent fully start #16461

Merged
merged 2 commits into from
Jan 13, 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
11 changes: 11 additions & 0 deletions tests/snmp/test_snmp_link_local.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from tests.common.helpers.snmp_helpers import get_snmp_facts
from tests.common import config_reload
from tests.common.utilities import wait_until

pytestmark = [
pytest.mark.topology('t0', 't1', 't2', 'm0', 'mx', 't1-multi-asic'),
Expand All @@ -16,6 +17,14 @@ def config_reload_after_test(duthosts,
config_reload(duthost, config_source='config_db', safe_reload=True, check_intf_up_ports=True)


def is_snmpagent_listen_on_ip(duthost, ipaddr):
"""
Check if snmpagent is listening on the specific IP address.
"""
output = duthost.shell('sudo ss -tunlp | grep snmpd', module_ignore_errors=True)['stdout_lines']
return any([ipaddr in x for x in output])


@pytest.mark.bsl
def test_snmp_link_local_ip(duthosts,
enum_rand_one_per_hwsku_frontend_hostname,
Expand Down Expand Up @@ -48,6 +57,8 @@ def test_snmp_link_local_ip(duthosts,
# Restart snmp service to regenerate snmpd.conf with
# link local IP configured in MGMT_INTERFACE
duthost.shell("config snmpagentaddress add {}%eth0".format(link_local_ip))
if not wait_until(60, 5, 0, is_snmpagent_listen_on_ip, duthost, link_local_ip):
pytest.fail("SNMP agent not listen on link local IP {}".format(link_local_ip))
stdout_lines = duthost.shell("docker exec snmp snmpget \
-v2c -c {} {}%eth0 {}"
.format(creds_all_duts[duthost.hostname]
Expand Down
Loading