Skip to content

Commit a31c79d

Browse files
authored
fix dhcpv6 counter test error, #6953 double commit (#7277)
double commit #6953, fix dhcpv6 counter test issue
1 parent 7063c23 commit a31c79d

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

ansible/roles/test/files/ptftests/dhcpv6_counter_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import os
12
import ast
3+
import time
24
import subprocess
35

46
# Packet Test Framework imports
@@ -56,6 +58,7 @@ def setUp(self):
5658
self.server_ip = self.test_params['server_ip']
5759
self.relay_iface_ip = self.test_params['relay_iface_ip']
5860
self.relay_iface_mac = self.test_params['relay_iface_mac']
61+
self.dut_mac = self.test_params['dut_mac']
5962
self.vlan_ip = self.test_params['vlan_ip']
6063
self.client_mac = self.dataplane.get_mac(0, self.client_port_index)
6164

@@ -93,7 +96,7 @@ def create_packet(self, message):
9396
return packet
9497

9598
def create_server_packet(self, message):
96-
packet = Ether(dst=self.relay_iface_mac)
99+
packet = Ether(dst=self.dut_mac)
97100
packet /= IPv6(src=self.server_ip, dst=self.relay_iface_ip)
98101
packet /= UDP(sport=self.DHCP_SERVER_PORT, dport=self.DHCP_SERVER_PORT)
99102
packet /= DHCP6_RelayReply(msgtype=13, linkaddr=self.vlan_ip, peeraddr=self.client_link_local)
@@ -112,13 +115,17 @@ def client_send(self):
112115
for message in client_messages:
113116
packet = self.create_packet(message)
114117
testutils.send_packet(self, self.client_port_index, packet)
118+
# sleep a short time to low down packet sending rate in case multicast packets
119+
# flooding cause packets drop on dhcpv6 relay filter raw socket
120+
time.sleep(1)
115121

116122
def server_send(self):
117123
server_messages = [DHCP6_Advertise, DHCP6_Reply]
118124
for message in server_messages:
119125
packet = self.create_server_packet(message)
120126
packet.src = self.dataplane.get_mac(0, self.server_port_indices[0])
121127
testutils.send_packet(self, self.server_port_indices[0], packet)
128+
time.sleep(1)
122129

123130
def runTest(self):
124131
self.client_send()

tests/dhcp_relay/test_dhcpv6_relay.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from tests.common.platform.processes_utils import wait_critical_processes
1414
from tests.common.utilities import wait_until
1515
from tests.common.helpers.assertions import pytest_assert
16+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401
17+
1618

1719
pytestmark = [
1820
pytest.mark.topology('t0', 'm0'),
@@ -24,6 +26,14 @@
2426

2527
logger = logging.getLogger(__name__)
2628

29+
30+
def wait_all_bgp_up(duthost):
31+
config_facts = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
32+
bgp_neighbors = config_facts.get('BGP_NEIGHBOR', {})
33+
if not wait_until(60, 10, 0, duthost.check_bgp_session_state, bgp_neighbors.keys()):
34+
pytest.fail("not all bgp sessions are up after config change")
35+
36+
2737
@pytest.fixture(scope="module", params=[SINGLE_TOR_MODE, DUAL_TOR_MODE])
2838
def testing_config(request, duthosts, rand_one_dut_hostname, tbinfo):
2939
testing_mode = request.param
@@ -160,7 +170,8 @@ def test_interface_binding(duthosts, rand_one_dut_hostname, dut_dhcp_relay_data)
160170
for dhcp_relay in dut_dhcp_relay_data:
161171
assert ("*:{}".format(dhcp_relay['downlink_vlan_iface']['name']) or "*:*" in output, "{} is not found in {}".format("*:{}".format(dhcp_relay['downlink_vlan_iface']['name']), output)) or ("*:*" in output, "dhcp6relay socket is not properly binded")
162172

163-
def test_dhcpv6_relay_counter(ptfhost, duthosts, rand_one_dut_hostname, dut_dhcp_relay_data):
173+
def test_dhcpv6_relay_counter(ptfhost, duthosts, rand_one_dut_hostname, dut_dhcp_relay_data,
174+
toggle_all_simulator_ports_to_rand_selected_tor_m): # noqa F811
164175
""" Test DHCPv6 Counter """
165176
duthost = duthosts[rand_one_dut_hostname]
166177
skip_release(duthost, ["201911", "202106"])
@@ -185,6 +196,7 @@ def test_dhcpv6_relay_counter(ptfhost, duthosts, rand_one_dut_hostname, dut_dhcp
185196
"server_ip": str(dhcp_relay['downlink_vlan_iface']['dhcpv6_server_addrs'][0]),
186197
"relay_iface_ip": str(dhcp_relay['downlink_vlan_iface']['addr']),
187198
"relay_iface_mac": str(dhcp_relay['downlink_vlan_iface']['mac']),
199+
"dut_mac": str(dhcp_relay['uplink_mac']),
188200
"relay_link_local": str(dhcp_relay['uplink_interface_link_local']),
189201
"vlan_ip": str(dhcp_relay['downlink_vlan_iface']['addr'])},
190202
log_file="/tmp/dhcpv6_relay_test.DHCPCounterTest.log")
@@ -247,7 +259,7 @@ def test_dhcp_relay_after_link_flap(ptfhost, duthosts, rand_one_dut_hostname, du
247259
duthost.shell('ifconfig {} up'.format(iface))
248260

249261
# Sleep a bit to ensure uplinks are up
250-
time.sleep(20)
262+
wait_all_bgp_up(duthost)
251263

252264
# Run the DHCP relay test on the PTF host
253265
ptf_runner(ptfhost,
@@ -302,7 +314,7 @@ def test_dhcp_relay_start_with_uplinks_down(ptfhost, duthosts, rand_one_dut_host
302314
duthost.shell('ifconfig {} up'.format(iface))
303315

304316
# Sleep a bit to ensure uplinks are up
305-
time.sleep(20)
317+
wait_all_bgp_up(duthost)
306318

307319
# Run the DHCP relay test on the PTF host
308320
ptf_runner(ptfhost,

0 commit comments

Comments
 (0)