Skip to content

Commit

Permalink
SNMP link-local test: wait until snmp agent fully start
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhijianrd committed Jan 10, 2025
1 parent 4049674 commit 48a1a6b
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 confirm_snmpagent_listen_on_ip(duthost, ipaddr):
"""
Confirm 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, confirm_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 48a1a6b

Please sign in to comment.