Skip to content

Commit

Permalink
SNMP link-local test: wait until snmp agent fully start (#16461)
Browse files Browse the repository at this point in the history
What is the motivation for this PR?
On Nokia-7215 platform, we observed below flaky failure:

Timeout: No Response from fe80::xxxx%eth0.
The root cause is that Nokia-7215 has low performance and the snmpget command is issued before snmpagent fully start.

How did you do it?
To resolve this issue, I added a wait_until to ensure snmpagent already listening on the link-local IP address.

How did you verify/test it?
Verified on Nokia-7215 Mx testbed.
  • Loading branch information
lizhijianrd authored Jan 13, 2025
1 parent 85b3dc4 commit 8b4f733
Showing 1 changed file with 11 additions and 0 deletions.
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

0 comments on commit 8b4f733

Please sign in to comment.