Skip to content

Commit 133b244

Browse files
author
Jakub Smolar
authored
Merge pull request #604 from averevki/fix-multicluster-tests
Fix multicluster tests
2 parents 2f25b0f + 91e5831 commit 133b244

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
"""Test changing load-balancing strategy in DNSPolicy"""
22

3+
from time import sleep
4+
35
import pytest
6+
import dns.resolver
7+
8+
from testsuite.kuadrant.policy.dns import has_record_condition
49

510
pytestmark = [pytest.mark.multicluster]
611

712

8-
def test_change_lb_strategy(dns_policy2):
9-
"""Verify that changing load-balancing strategy is not allowed"""
13+
def test_change_lb_strategy(hostname, gateway, gateway2, dns_policy2, dns_server, dns_server2, wildcard_domain):
14+
"""Verify that removing DNSPolicy load-balancing configuration removes GEO load-balancing endpoint from the pool"""
15+
resolver = dns.resolver.Resolver(configure=False)
16+
resolver.nameservers = [dns_server["address"]]
17+
assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]
18+
19+
resolver.nameservers = [dns_server2["address"]]
20+
assert resolver.resolve(hostname.hostname)[0].address == gateway2.external_ip().split(":")[0]
21+
1022
dns_policy2.model.spec.pop("loadBalancing")
11-
res = dns_policy2.apply()
23+
dns_policy2.apply()
24+
assert dns_policy2.wait_until(
25+
has_record_condition(
26+
"Ready",
27+
"False",
28+
"ProviderError",
29+
"The DNS provider failed to ensure the record: record type conflict, cannot update endpoint "
30+
f"'{wildcard_domain}' with record type 'A' when endpoint already exists with record type 'CNAME'",
31+
)
32+
)
1233

13-
assert res.status() == 1
14-
assert "loadBalancing is immutable" in res.err()
34+
sleep(300) # wait for DNS propagation on providers
35+
assert resolver.resolve(hostname.hostname)[0].address == gateway.external_ip().split(":")[0]

testsuite/tests/multicluster/test_simple_strategy.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ def test_simple_strategy(client, hostname, gateway, gateway2):
2626
gw1_ip, gw2_ip = gateway.external_ip().split(":")[0], gateway2.external_ip().split(":")[0]
2727
assert gw1_ip != gw2_ip
2828

29+
gw1_ip_resolved = dns.resolver.resolve(hostname.hostname)[0].address
30+
gw2_ip_resolved = dns.resolver.resolve(hostname.hostname)[0].address
31+
assert gw1_ip_resolved != gw2_ip_resolved, "Simple routing strategy should return IPs in a round-robin fashion"
32+
assert {gw1_ip_resolved, gw2_ip_resolved} == {gw1_ip, gw2_ip}
33+
2934
for i in range(10):
3035
assert (
31-
dns.resolver.resolve(hostname.hostname)[0].address == gw1_ip
36+
dns.resolver.resolve(hostname.hostname)[0].address == gw1_ip_resolved
3237
), f"Simple routing strategy should return IPs in a round-robin fashion (iteration {i + 1})"
3338
assert (
34-
dns.resolver.resolve(hostname.hostname)[0].address == gw2_ip
39+
dns.resolver.resolve(hostname.hostname)[0].address == gw2_ip_resolved
3540
), f"Simple routing strategy should return IPs in a round-robin fashion (iteration {i + 1})"

0 commit comments

Comments
 (0)