Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ansible/roles/test/files/ptftests/dhcpv6_counter_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import ast
import time
import subprocess

# Packet Test Framework imports
Expand Down Expand Up @@ -56,6 +58,7 @@ def setUp(self):
self.server_ip = self.test_params['server_ip']
self.relay_iface_ip = self.test_params['relay_iface_ip']
self.relay_iface_mac = self.test_params['relay_iface_mac']
self.dut_mac = self.test_params['dut_mac']
self.vlan_ip = self.test_params['vlan_ip']
self.client_mac = self.dataplane.get_mac(0, self.client_port_index)

Expand Down Expand Up @@ -93,7 +96,7 @@ def create_packet(self, message):
return packet

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

def server_send(self):
server_messages = [DHCP6_Advertise, DHCP6_Reply]
for message in server_messages:
packet = self.create_server_packet(message)
packet.src = self.dataplane.get_mac(0, self.server_port_indices[0])
testutils.send_packet(self, self.server_port_indices[0], packet)
time.sleep(1)

def runTest(self):
self.client_send()
Expand Down
18 changes: 15 additions & 3 deletions tests/dhcp_relay/test_dhcpv6_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from tests.common.platform.processes_utils import wait_critical_processes
from tests.common.utilities import wait_until
from tests.common.helpers.assertions import pytest_assert
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor_m # noqa F401


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

logger = logging.getLogger(__name__)


def wait_all_bgp_up(duthost):
config_facts = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
bgp_neighbors = config_facts.get('BGP_NEIGHBOR', {})
if not wait_until(60, 10, 0, duthost.check_bgp_session_state, bgp_neighbors.keys()):
pytest.fail("not all bgp sessions are up after config change")


@pytest.fixture(scope="module", params=[SINGLE_TOR_MODE, DUAL_TOR_MODE])
def testing_config(request, duthosts, rand_one_dut_hostname, tbinfo):
testing_mode = request.param
Expand Down Expand Up @@ -160,7 +170,8 @@ def test_interface_binding(duthosts, rand_one_dut_hostname, dut_dhcp_relay_data)
for dhcp_relay in dut_dhcp_relay_data:
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")

def test_dhcpv6_relay_counter(ptfhost, duthosts, rand_one_dut_hostname, dut_dhcp_relay_data):
def test_dhcpv6_relay_counter(ptfhost, duthosts, rand_one_dut_hostname, dut_dhcp_relay_data,
toggle_all_simulator_ports_to_rand_selected_tor_m): # noqa F811
""" Test DHCPv6 Counter """
duthost = duthosts[rand_one_dut_hostname]
skip_release(duthost, ["201911", "202106"])
Expand All @@ -185,6 +196,7 @@ def test_dhcpv6_relay_counter(ptfhost, duthosts, rand_one_dut_hostname, dut_dhcp
"server_ip": str(dhcp_relay['downlink_vlan_iface']['dhcpv6_server_addrs'][0]),
"relay_iface_ip": str(dhcp_relay['downlink_vlan_iface']['addr']),
"relay_iface_mac": str(dhcp_relay['downlink_vlan_iface']['mac']),
"dut_mac": str(dhcp_relay['uplink_mac']),
"relay_link_local": str(dhcp_relay['uplink_interface_link_local']),
"vlan_ip": str(dhcp_relay['downlink_vlan_iface']['addr'])},
log_file="/tmp/dhcpv6_relay_test.DHCPCounterTest.log")
Expand Down Expand Up @@ -247,7 +259,7 @@ def test_dhcp_relay_after_link_flap(ptfhost, duthosts, rand_one_dut_hostname, du
duthost.shell('ifconfig {} up'.format(iface))

# Sleep a bit to ensure uplinks are up
time.sleep(20)
wait_all_bgp_up(duthost)

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

# Sleep a bit to ensure uplinks are up
time.sleep(20)
wait_all_bgp_up(duthost)

# Run the DHCP relay test on the PTF host
ptf_runner(ptfhost,
Expand Down