From ac7b2867ae5a38468695ced6c761117a722e04c5 Mon Sep 17 00:00:00 2001 From: Anders Linn Date: Mon, 27 Apr 2026 22:26:19 +0000 Subject: [PATCH] Issue 20758: Changes to run telemetry/test_events.py on v6 topos * use duthost.get_mgmt_ip() in generate_client_cli() to pick the right mgmt ip (v4 or v6) for the gnxi tool * fix get_mgmt_ip() to read from the kernel via 'ip addr' rather than from SONiC's 'show ip[v6] interface', which filters out site-local v6 addresses (fec0::/10) and breaks the helper on v6-only mgmt setups; also skip link-local (fe80::/10) explicitly so the v6 regex never matches the '0/64' tail of 'eth0/64' * remove the IPv6-only conditional skip and xfail entries for test_events Signed-off-by: Anders Linn --- tests/common/devices/sonic.py | 12 ++++++++++-- .../conditional_mark/tests_mark_conditions.yaml | 12 ------------ tests/telemetry/telemetry_utils.py | 3 ++- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/common/devices/sonic.py b/tests/common/devices/sonic.py index 0db1fa6ab82..47680d6f34c 100644 --- a/tests/common/devices/sonic.py +++ b/tests/common/devices/sonic.py @@ -3240,13 +3240,21 @@ def get_mgmt_ip(self): ipv4_regex = re.compile(r"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/\d+") ipv6_regex = re.compile(r"([a-fA-F0-9:]+)/\d+") - mgmt_interface = self.shell("show ip interface | egrep '^eth0 '", module_ignore_errors=True)["stdout"] + # Use 'ip addr' instead of 'show ip[v6] interface' because the latter + # filters out site-local v6 addresses (fec0::/10) that may legitimately + # be configured as mgmt. + mgmt_interface = self.shell( + "ip -4 -o addr show eth0 scope global", module_ignore_errors=True + )["stdout"] if mgmt_interface: match = ipv4_regex.search(mgmt_interface) if match: return {"mgmt_ip": match.group(1), "version": "v4"} - mgmt_interface = self.shell("show ipv6 interface | egrep '^eth0 '", module_ignore_errors=True)["stdout"] + # Exclude link-local (fe80::/10) — not routable, can't be the mgmt addr. + mgmt_interface = self.shell( + "ip -6 -o addr show eth0 | grep -v 'scope link'", module_ignore_errors=True + )["stdout"] if mgmt_interface: match = ipv6_regex.search(mgmt_interface) if match: diff --git a/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml b/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml index e790bb0f7ab..049337948c1 100644 --- a/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml +++ b/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml @@ -5455,18 +5455,6 @@ telemetry/test_events.py: - "asic_type in ['vs']" - https://github.com/sonic-net/sonic-buildimage/issues/19943 -telemetry/test_events.py::test_events: - xfail: - reason: "xfail for IPv6-only topologies, issue https://github.com/sonic-net/sonic-mgmt/issues/20758" - conditions: - - "https://github.com/sonic-net/sonic-mgmt/issues/20758 and '-v6-' in topo_name" - skip: - reason: "dut ipv6 mgmt ip not supported" - conditions_logical_operator: and - conditions: - - "is_mgmt_ipv6_only==True" - - "https://github.com/sonic-net/sonic-mgmt/issues/20395" - telemetry/test_telemetry.py: skip: reason: "Skip telemetry test for 201911 and older branches" diff --git a/tests/telemetry/telemetry_utils.py b/tests/telemetry/telemetry_utils.py index ab0d171fd5b..2e01c5bdd9c 100644 --- a/tests/telemetry/telemetry_utils.py +++ b/tests/telemetry/telemetry_utils.py @@ -126,7 +126,8 @@ def generate_client_cli(duthost, gnxi_path, method=METHOD_GET, xpath="COUNTERS/E # 3. Executes the py_gnmicli.py script. cmdFormat = '. /root/env-python3/bin/activate && cd {7}gnmi_cli_py' \ ' && python py_gnmicli.py -g -t {0} -p {1} -m {2} -x {3} -xt {4}{5} -o {6}' - cmd = cmdFormat.format(duthost.mgmt_ip, env.gnmi_port, + mgmt_ip = duthost.get_mgmt_ip()["mgmt_ip"] + cmd = cmdFormat.format(mgmt_ip, env.gnmi_port, method, xpath, target, ns, "ndastreamingservertest", gnxi_path)