From f9816210ba825c98801a949cf829fe09abc9581f Mon Sep 17 00:00:00 2001 From: averevki Date: Thu, 26 Sep 2024 14:00:50 +0200 Subject: [PATCH] Fix geo load balancing test after the api change Signed-off-by: averevki --- testsuite/kuadrant/policy/dns.py | 2 +- .../tests/multicluster/load_balanced/conftest.py | 6 +++--- .../load_balanced/test_load_balanced_geo.py | 7 ------- .../load_balanced/test_unsupported_geocode.py | 14 +++++++------- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/testsuite/kuadrant/policy/dns.py b/testsuite/kuadrant/policy/dns.py index 57a237d3..55059596 100644 --- a/testsuite/kuadrant/policy/dns.py +++ b/testsuite/kuadrant/policy/dns.py @@ -28,7 +28,7 @@ class LoadBalancing: defaultGeo: bool # pylint: disable=invalid-name geo: str - weight: Optional[int] + weight: Optional[int] = None class DNSPolicy(Policy): diff --git a/testsuite/tests/multicluster/load_balanced/conftest.py b/testsuite/tests/multicluster/load_balanced/conftest.py index 22dfa7ed..d4771165 100644 --- a/testsuite/tests/multicluster/load_balanced/conftest.py +++ b/testsuite/tests/multicluster/load_balanced/conftest.py @@ -31,16 +31,16 @@ def dns_server2(dns_config): @pytest.fixture(scope="module") def dns_policy(blame, cluster, gateway, dns_server, module_label, dns_provider_secret): """DNSPolicy with load-balancing for the first cluster""" - load_balancing = LoadBalancing(defaultGeo=True, geo=dns_server["geo_code"], weight=10) + load_balancing = LoadBalancing(defaultGeo=True, geo=dns_server["geo_code"]) return DNSPolicy.create_instance( cluster, blame("dns"), gateway, dns_provider_secret, load_balancing, labels={"app": module_label} ) @pytest.fixture(scope="module") -def dns_policy2(blame, cluster2, gateway2, dns_server, module_label, dns_provider_secret): +def dns_policy2(blame, cluster2, gateway2, dns_server2, module_label, dns_provider_secret): """DNSPolicy with load-balancing for the second cluster""" - load_balancing = LoadBalancing(defaultGeo=True, geo=dns_server["geo_code"], weight=10) + load_balancing = LoadBalancing(defaultGeo=False, geo=dns_server2["geo_code"]) return DNSPolicy.create_instance( cluster2, blame("dns"), gateway2, dns_provider_secret, load_balancing, labels={"app": module_label} ) diff --git a/testsuite/tests/multicluster/load_balanced/test_load_balanced_geo.py b/testsuite/tests/multicluster/load_balanced/test_load_balanced_geo.py index b02615b0..076e1d73 100644 --- a/testsuite/tests/multicluster/load_balanced/test_load_balanced_geo.py +++ b/testsuite/tests/multicluster/load_balanced/test_load_balanced_geo.py @@ -7,13 +7,6 @@ pytestmark = [pytest.mark.multicluster] -@pytest.fixture(scope="module") -def gateway2(gateway2, dns_server2): - """Overwrite second gateway to have a different geocode""" - gateway2.label({"kuadrant.io/lb-attribute-geo-code": dns_server2["geo_code"]}) - return gateway2 - - def test_load_balanced_geo(client, hostname, gateway, gateway2, dns_server, dns_server2): """ - Verify that request to the hostname is successful diff --git a/testsuite/tests/multicluster/load_balanced/test_unsupported_geocode.py b/testsuite/tests/multicluster/load_balanced/test_unsupported_geocode.py index 18896ff0..8d983b2f 100644 --- a/testsuite/tests/multicluster/load_balanced/test_unsupported_geocode.py +++ b/testsuite/tests/multicluster/load_balanced/test_unsupported_geocode.py @@ -8,12 +8,12 @@ pytestmark = [pytest.mark.multicluster] -def test_unsupported_geocode(dns_policy): +def test_unsupported_geocode(dns_policy2): """Change default geocode to not existent one and verify that policy became not enforced""" - dns_policy.model.spec.loadBalancing.geo = "XX" - dns_policy.apply() + dns_policy2.model.spec.loadBalancing.geo = "XX" + dns_policy2.apply() - assert dns_policy.wait_until(has_condition("Enforced", "False")) - assert dns_policy.wait_until( - has_record_condition("Ready", "False", "ProviderError", "Cannot find location") - ), f"DNSPolicy did not reach expected record status, instead it was: {dns_policy.model.status.recordConditions}" + assert dns_policy2.wait_until(has_condition("Enforced", "False")) + assert dns_policy2.wait_until( + has_record_condition("Ready", "False", "ProviderError") + ), f"DNSPolicy did not reach expected record status, instead it was: {dns_policy2.model.status.recordConditions}"