Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new test file for SSSD's dynamic DNS functionality, test_dyndns.py. It adds an initial test case and stubs for several others. The review identified some critical issues: there are two pairs of duplicated test function definitions, which will cause errors. I've suggested removing these duplicates. Additionally, the implemented test case uses a fixed time.sleep(), which is a common source of test flakiness. I've recommended replacing it with a polling mechanism to improve test reliability and efficiency.
|
|
||
| def test_dyndns__update_creates_forward_ipv4_records(client: Client, provider: GenericProvider): | ||
| """ | ||
| :title: Dynamic DNS updates IPV4 address only | ||
| :description: SSSD should create records for network addresses that are on the client | ||
| :setup: | ||
| 1. Remove IPV6 address from ethernet interface | ||
| 2. Create PTR zone for default network | ||
| 3. Start SSSD | ||
| :steps: | ||
| 1. Check forward zone for client's A record | ||
| :expectedresults: | ||
| 1. Client A record exists and is the only client record in the zone file | ||
| :customerscenario: True | ||
| """ |
There was a problem hiding this comment.
|
|
||
| def test_dyndns__updates_all_forward_records(client: Client, provider: GenericProvider): | ||
| """ | ||
| :title: Dynamic DNS updates AAAA records on all interfaces | ||
| :description: SSSD should update all records if the IP changes | ||
| :setup: | ||
| 1. Create PTR zone | ||
| 2. A/AAAA/PTR records that DO NOT match the client's IP Address | ||
| 3. Start SSSD | ||
| :steps: | ||
| 1. Check forward zone for client's A record | ||
| 2. Check forward zone for client's AAAA record | ||
| 3. Check reverse zone for client's pointer record | ||
| :expectedresults: | ||
| 1. Client A record exists in the zone file | ||
| 2. Client AAAA record exists in the zone file | ||
| 3. Client PTR record exists and points to the latest IP | ||
| :customerscenario: True | ||
| """ |
There was a problem hiding this comment.
| time.sleep(15) | ||
|
|
||
| assert client.net.nslookup([f"client.{provider.domain}", provider.server]) == 0, f"Host client.{provider.domain} was not found!" | ||
| assert client.net.nslookup([client.net.ip().address, provider.server]) == 0, f"Host address {client.net.ip().address} was not found!" |
There was a problem hiding this comment.
Using a fixed time.sleep(15) can lead to flaky tests. If the DNS update takes longer than 15 seconds, the test will fail. Conversely, if the update is much faster, the test waits unnecessarily, slowing down the test suite. A better approach is to poll for the desired state with a timeout. This makes the test more robust and potentially faster.
# Poll for DNS records to appear
hostname_found = False
ip_found = False
for _ in range(30): # Poll for up to 30 seconds
if not hostname_found and client.net.nslookup([f"client.{provider.domain}", provider.server]) == 0:
hostname_found = True
if not ip_found and client.net.nslookup([client.net.ip().address, provider.server]) == 0:
ip_found = True
if hostname_found and ip_found:
break
time.sleep(1)
assert hostname_found, f"Host client.{provider.domain} was not found!"
assert ip_found, f"Host address {client.net.ip().address} was not found!"|
Would be great with a test that simulates a working LAN connection and then LAN goes offline and WiFi comes up. |
544cee8 to
b4dd7cc
Compare
No description provided.