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

Fix multicluster tests #604

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions testsuite/tests/multicluster/load_balanced/test_change_strategy.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
"""Test changing load-balancing strategy in DNSPolicy"""

from time import sleep

import pytest
import dns.resolver

from testsuite.kuadrant.policy.dns import has_record_condition

pytestmark = [pytest.mark.multicluster]


def test_change_lb_strategy(dns_policy2):
"""Verify that changing load-balancing strategy is not allowed"""
def test_change_lb_strategy(hostname, gateway, gateway2, dns_policy2, dns_server, dns_server2, wildcard_domain):
"""Verify that removing DNSPolicy load-balancing configuration removes GEO load-balancing endpoint from the pool"""
resolver = dns.resolver.Resolver(configure=False)
resolver.nameservers = [dns_server["address"]]
assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]

resolver.nameservers = [dns_server2["address"]]
assert resolver.resolve(hostname.hostname)[0].address == gateway2.external_ip().split(":")[0]

dns_policy2.model.spec.pop("loadBalancing")
res = dns_policy2.apply()
dns_policy2.apply()
assert dns_policy2.wait_until(
has_record_condition(
"Ready",
"False",
"ProviderError",
"The DNS provider failed to ensure the record: record type conflict, cannot update endpoint "
f"'{wildcard_domain}' with record type 'A' when endpoint already exists with record type 'CNAME'",
)
)

assert res.status() == 1
assert "loadBalancing is immutable" in res.err()
sleep(300) # wait for DNS propagation on providers
assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]
9 changes: 7 additions & 2 deletions testsuite/tests/multicluster/test_simple_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ def test_simple_strategy(client, hostname, gateway, gateway2):
gw1_ip, gw2_ip = gateway.external_ip().split(":")[0], gateway2.external_ip().split(":")[0]
assert gw1_ip != gw2_ip

gw1_ip_resolved = dns.resolver.resolve(hostname.hostname)[0].address
gw2_ip_resolved = dns.resolver.resolve(hostname.hostname)[0].address
assert gw1_ip_resolved != gw2_ip_resolved, "Simple routing strategy should return IPs in a round-robin fashion"
assert {gw1_ip_resolved, gw2_ip_resolved} == {gw1_ip, gw2_ip}

for i in range(10):
assert (
dns.resolver.resolve(hostname.hostname)[0].address == gw1_ip
dns.resolver.resolve(hostname.hostname)[0].address == gw1_ip_resolved
), f"Simple routing strategy should return IPs in a round-robin fashion (iteration {i + 1})"
assert (
dns.resolver.resolve(hostname.hostname)[0].address == gw2_ip
dns.resolver.resolve(hostname.hostname)[0].address == gw2_ip_resolved
), f"Simple routing strategy should return IPs in a round-robin fashion (iteration {i + 1})"
Loading