diff --git a/testsuite/tests/multicluster/load_balanced/test_change_strategy.py b/testsuite/tests/multicluster/load_balanced/test_change_strategy.py index afc3cb7c..7e75ce76 100644 --- a/testsuite/tests/multicluster/load_balanced/test_change_strategy.py +++ b/testsuite/tests/multicluster/load_balanced/test_change_strategy.py @@ -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] diff --git a/testsuite/tests/multicluster/test_simple_strategy.py b/testsuite/tests/multicluster/test_simple_strategy.py index 9854df14..598ad0d9 100644 --- a/testsuite/tests/multicluster/test_simple_strategy.py +++ b/testsuite/tests/multicluster/test_simple_strategy.py @@ -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})"