Skip to content

Conversation

@fabikova
Copy link
Contributor

Description

This PR implements the test scenarios defined in issue #811 to verify the new DNS Endpoint Provider functionality.

It validates the aggregation workflow where multiple "Source" DNSRecords (acting as endpoint feeders) merge their endpoints into a single central "Destination" DNSRecord (acting as a Zone), which then propagates the records to an upstream provider (e.g., AWS).

Scenarios covered:

  1. Creation of a Destination DNSRecord pointing to a real provider (AWS) with the required zone label.
  2. Creation of multiple Source DNSRecords pointing to the endpoint provider.
  3. Verification that source endpoints are correctly merged into the destination record by the operator.
  4. Verification that the merged records are successfully resolved via external DNS.

Closes #811

Changes

  • New Test: Added testsuite/tests/singlecluster/gateway/dnspolicy/dns_records/test_dns_endpoint_provider.py which implements the test cases specified in the issue.
  • Helper Methods: Updated DNSRecord class in testsuite/kuadrant/policy/dns.py with:
    • wait_for_endpoints_merged
    • wait_until_resolves

Signed-off-by: Martina Fabikova <mfabikov@redhat.com>
@fabikova fabikova force-pushed the feature/issue-811-dns-endpoint-provider-tests branch from ef5e5db to 25cd7db Compare December 16, 2025 12:18
@fabikova fabikova requested a review from averevki December 16, 2025 12:20
@fabikova fabikova self-assigned this Dec 16, 2025
@fabikova fabikova moved this to Ready For Review in Kuadrant Dec 16, 2025
Comment on lines 24 to 27
@pytest.fixture(scope="module")
def aws_provider_secret():
"""Returns the name of the AWS provider secret"""
return "aws-credentials"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this test dns provider agnostic? Use the default dns_provider_secret fixture instead.

Hardcoding secret names like this would mean that this test requires a secret named aws-credentials to be present on the cluster. Config-related things like this one should be configurable from the testsuite settings file

Comment on lines 18 to 21
@pytest.fixture(scope="module")
def endpoint_provider_secret():
"""Returns the name of the endpoint provider secret"""
return "dns-provider-credentials-endpoint"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with the hardcoded name here. Is this a secret you expect to be present on a cluster before test is executed?

Comment on lines 30 to 33
@pytest.fixture(scope="module")
def shared_hostname(base_domain, blame):
"""Returns the shared hostname used for aggregation"""
return f"{blame('app')}.{base_domain}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Try reusing the hostname fixture. We usually expose hostnames in the said fixture to not overwrite hostname for every test

Comment on lines +85 to +91
request.addfinalizer(destination_dnsrecord.delete)
destination_dnsrecord.commit()
destination_dnsrecord.wait_for_ready()

for record in source_dnsrecords:
request.addfinalizer(record.delete)
record.commit()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can merge these 2 blocks under a single loop. Why isn't there a wait-for-ready for source records?

Comment on lines 94 to 102
def test_endpoint_provider_configuration(destination_dnsrecord, source_dnsrecords, endpoint_provider_secret):
"""Verify configuration and labels"""
destination_dnsrecord.refresh()
assert destination_dnsrecord.model.metadata.labels.get("kuadrant.io/zone-record") == "true"

for record in source_dnsrecords:
record.refresh()
assert record.model.spec.providerRef.name == endpoint_provider_secret
assert record.model.spec.rootHost == destination_dnsrecord.model.spec.rootHost
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually don't check resource object fields in our tests, including values added by the kuadrant. We verify if something works or not with actual http requests instead

answers = resolver.resolve(hostname, "A")
found_ips = {ip.to_text() for ip in answers}
return expected_ip in found_ips
except Exception: # pylint: disable=broad-exception-caught
Copy link
Contributor

Choose a reason for hiding this comment

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

If pylint giving you warnings, it might be an indication to look for different solution than do disable this warning 😁

Look up why you shouldn't use broad exceptions in python

def test_records_accessible(destination_dnsrecord, shared_hostname):
"""Verify that endpoints are merged and accessible via DNS"""
# 1. Verify Merge
destination_dnsrecord.wait_for_endpoints_merged({SOURCE_IP1, SOURCE_IP2})
Copy link
Contributor

Choose a reason for hiding this comment

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

How long does it take for endpoints to merge that you need custom wait here?

Comment on lines 110 to 111
destination_dnsrecord.wait_until_resolves(f"src1.{shared_hostname}", SOURCE_IP1)
destination_dnsrecord.wait_until_resolves(f"src2.{shared_hostname}", SOURCE_IP2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing about wait-for-ready I've written on your other PR. How long does it take until endpoints resolve after dnsrecords report them as ready?

Signed-off-by: Martina Fabikova <mfabikov@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

Add tests for the dns endpoint provider

2 participants