Skip to content

adding dynamic dns tests#8415

Draft
danlavu wants to merge 1 commit intoSSSD:masterfrom
danlavu:tests-dyndns
Draft

adding dynamic dns tests#8415
danlavu wants to merge 1 commit intoSSSD:masterfrom
danlavu:tests-dyndns

Conversation

@danlavu
Copy link

@danlavu danlavu commented Feb 2, 2026

No description provided.

@danlavu danlavu marked this pull request as draft February 2, 2026 16:12
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +75 to +89

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
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The test function test_dyndns__update_creates_forward_ipv4_records is defined twice. This duplicate definition on lines 76-89 should be removed, as it overwrites the original definition on lines 60-73. Python does not allow duplicate function names in the same module.

Comment on lines +111 to +129

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
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The test function test_dyndns__updates_all_forward_records is defined twice. This duplicate definition on lines 112-129 should be removed, as it overwrites the original definition on lines 92-109. Python does not allow duplicate function names in the same module.

Comment on lines 54 to 57
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!"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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!"

"""


def test_dyndns__updates_all_forward_records(client: Client, provider: GenericProvider):

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning test

This assignment to 'test_dyndns__updates_all_forward_records' is unnecessary as it is
redefined
before this value is used.
@joakim-tjernlund
Copy link

Would be great with a test that simulates a working LAN connection and then LAN goes offline and WiFi comes up.
In my experience it can take minutes to update DNS and RDNS updates leaves the old LAN entry in RDNS

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

Successfully merging this pull request may close these issues.

2 participants