Skip to content

Commit

Permalink
[dhcp_relay] Add dhcpv6 relay bind test when dhcpv6_server is not con…
Browse files Browse the repository at this point in the history
…figured (sonic-net#14164)

What is the motivation for this PR?
Add test for sonic-net/sonic-dhcp-relay#46
Add test to make sure dhcp6relay would not bind to vlan that doesn't configure dhcpv6 servers, and it wouldn't affect bind to other vlan

How did you do it?
Add test to make sure dhcp6relay would not bind to vlan that doesn't configure dhcpv6 servers, and it wouldn't affect bind to other vlan

Add a new vlan and assign ipv6 address to it. But not add dhcpv6 server for it
Check interface bind status
How did you verify/test it?
Run test
  • Loading branch information
yaqiangz authored Aug 30, 2024
1 parent 9e3d09c commit 7b5156e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion tests/dhcp_relay/test_dhcpv6_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,33 @@ def check_interface_status(duthost):
return False


def test_interface_binding(duthosts, rand_one_dut_hostname, dut_dhcp_relay_data):
def restart_dhcp_relay_and_check_dhcp6relay(duthost):
duthost.shell("sudo systemctl reset-failed dhcp_relay")
duthost.shell("sudo systemctl restart dhcp_relay")
wait_until(60, 3, 0, lambda: ("RUNNING" in duthost.shell("docker exec dhcp_relay supervisorctl status " +
"dhcp-relay:dhcp6relay | awk '{print $2}'")["stdout"]))


@pytest.fixture(scope="function")
def setup_and_teardown_no_servers_vlan(duthosts, rand_one_dut_hostname):
duthost = duthosts[rand_one_dut_hostname]
new_vlan_id = 4001
new_vlan_ipv6 = "fc01:5000::1/64"
duthost.shell("sudo config vlan add {}".format(new_vlan_id))
duthost.shell("sudo config interface ip add Vlan{} {}".format(new_vlan_id, new_vlan_ipv6))
restart_dhcp_relay_and_check_dhcp6relay(duthost)

yield new_vlan_id

duthost.shell("sudo config interface ip remove Vlan{} {}".format(new_vlan_id, new_vlan_ipv6))
duthost.shell("sudo config vlan del {}".format(new_vlan_id))
restart_dhcp_relay_and_check_dhcp6relay(duthost)


def test_interface_binding(duthosts, rand_one_dut_hostname, dut_dhcp_relay_data, setup_and_teardown_no_servers_vlan):
# Add vlan without dhcpv6_server, which should not be binded
new_vlan_id = setup_and_teardown_no_servers_vlan

duthost = duthosts[rand_one_dut_hostname]
skip_release(duthost, ["201911", "202106"])
if not check_interface_status(duthost):
Expand All @@ -240,6 +266,10 @@ def test_interface_binding(duthosts, rand_one_dut_hostname, dut_dhcp_relay_data)
"{} is not found in {}".format("*:{}".format(dhcp_relay['downlink_vlan_iface']['name']), output)) or \
("*:*" in output, "dhcp6relay socket is not properly binded")

pytest_assert("Vlan{}".format(new_vlan_id) not in output,
"dhcp6relay bind to Vlan{} without dhcpv6_servers configured, which is unexpected"
.format(new_vlan_id))


@pytest.fixture
def setup_active_active_as_active_standby(
Expand Down

0 comments on commit 7b5156e

Please sign in to comment.