From 079c34ab92b74cc3668e4f0d915d426f0c5dea62 Mon Sep 17 00:00:00 2001 From: Yaqiang Zhu Date: Wed, 18 Dec 2024 13:52:26 +0800 Subject: [PATCH] [dhcp_relay][telemetry] Fix incorrect client mac in dhcp_relay related telemetry test (#16112) What is the motivation for this PR? Client mac of DHCP packets should be ptf interface mac rather than DUT interface mac How did you do it? Modify test case to use ptf interface mac How did you verify/test it? Run tests in m0/t0 topo --- tests/telemetry/events/dhcp-relay_events.py | 4 ++-- tests/telemetry/events/event_utils.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/telemetry/events/dhcp-relay_events.py b/tests/telemetry/events/dhcp-relay_events.py index dd2fdf8bfcc..17621eb914b 100644 --- a/tests/telemetry/events/dhcp-relay_events.py +++ b/tests/telemetry/events/dhcp-relay_events.py @@ -8,7 +8,7 @@ from tests.common.helpers.assertions import pytest_assert as py_assert from tests.common.utilities import wait_until from run_events_test import run_test -from event_utils import find_test_vlan, find_test_port_and_mac, create_dhcp_discover_packet +from event_utils import find_test_vlan, find_test_client_port_and_mac, create_dhcp_discover_packet logger = logging.getLogger(__name__) tag = "sonic-events-dhcp-relay" @@ -96,7 +96,7 @@ def send_dhcp_discover_packets(duthost, ptfadapter, packets_to_send=5, interval= # Send packets # results contains up to 5 tuples of member interfaces from vlan (port, mac address) - results = find_test_port_and_mac(duthost, member_interfaces, 5) + results = find_test_client_port_and_mac(ptfadapter, duthost, member_interfaces, 5) for i in range(packets_to_send): result = results[i % len(results)] diff --git a/tests/telemetry/events/event_utils.py b/tests/telemetry/events/event_utils.py index d71aaa5e543..7cae368f651 100644 --- a/tests/telemetry/events/event_utils.py +++ b/tests/telemetry/events/event_utils.py @@ -144,19 +144,18 @@ def find_test_vlan(duthost): return {} -def find_test_port_and_mac(duthost, members, count): - # Will return up to count many up ports with their port index and mac address +def find_test_client_port_and_mac(ptfadapter, duthost, members, count): + # Will return up to count many up ports with their port index and mac address of ptf results = [] interf_status = duthost.show_interface(command="status")['ansible_facts']['int_status'] for member_interface in members: if len(results) == count: return results if interf_status[member_interface]['admin_state'] == "up": - mac = duthost.get_dut_iface_mac(member_interface) minigraph_info = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts'] port_index = minigraph_info['minigraph_port_indices'][member_interface] - if mac != "" and port_index != "": - results.append([int(port_index), mac]) + if port_index != "": + results.append([int(port_index), ptfadapter.dataplane.get_mac(0, port_index).decode()]) return results