Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for dnsmasq lease state propagation #116

Open
lukasjuhrich opened this issue Jul 7, 2022 · 1 comment
Open

Unit tests for dnsmasq lease state propagation #116

lukasjuhrich opened this issue Jul 7, 2022 · 1 comment

Comments

@lukasjuhrich
Copy link
Collaborator

lukasjuhrich commented Jul 7, 2022

dnsmasq's internal knowledge about the leases is hidden in memory.

For that reason, we use a --dhcp-script to persistently mirror this state in the auth_dhcp_leases table (also for unauth).
Furthermore, dnsmasq bootstraps this state by passing said script the init command.

To ensure correctness of this synchronization, we should add unit tests for the lease_server.

Mainly, this means extending test stubs like the following:

def test_add_lease():
pass

The lease server is not completely untested, however: Some bats tests check whether the lease invalidation on refresh works correctly, which at least uses

  • the capability of dnsmasq to correctly reconstruct the lease state using the init command
  • the capability of the lease server to accept the delete command and delete the corresponding row in the leases table
@lukasjuhrich
Copy link
Collaborator Author

lukasjuhrich commented Jul 7, 2022

A low-hanging fruit would be to extend the existing {un,}auth-dhcp integration tests to check that e.g. a successful lease makes its way to the auth-dhcp-lease table, like for instance in here:

@test "check that client can acquire DHCP lease" {
run ns dhcpcd \
--config /dev/null \
--script "$dhcpcd_script" \
--env script_output_dir="$script_output_dir" \
--env variable=env \
--option domain_name_servers,domain_name,domain_search,host_name \
--timeout 10 \
--noipv4ll \
--ipv4only \
--oneshot eth0 \
;
echo "$output" >&2
[[ $status = 0 ]]
[[ -f "${script_output_dir}/BOUND" ]]
source "${script_output_dir}/BOUND"
declare -p env
[[ "${env[new_broadcast_address]}" = "$(netaddr.broadcast "$gateway_ip_address")" ]]
[[ "${env[new_dhcp_lease_time]}" = "86400" ]]
[[ "${env[new_dhcp_rebinding_time]}" = "75600" ]]
[[ "${env[new_dhcp_renewal_time]}" = "43200" ]]
[[ "${env[new_dhcp_server_identifier]}" = "$(netaddr.ip "$auth_ip")" ]]
[[ "${env[new_domain_name]}" = users.agdsn.de ]]
[[ "${env[new_domain_name_servers]}" = "$(netaddr.ip "$auth_ip")" ]]
[[ "${env[new_ip_address]}" = "$(netaddr.ip "$client_ip_address")" ]]
[[ "${env[new_network_number]}" = "$(netaddr.network "$gateway_ip_address")" ]]
[[ "${env[new_routers]}" = "$(netaddr.ip "$gateway_ip_address")" ]]
[[ "${env[new_subnet_cidr]}" = "$(netaddr.prefixlen "$gateway_ip_address")" ]]
[[ "${env[new_subnet_mask]}" = "$(netaddr.netmask "$gateway_ip_address")" ]]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant