Skip to content

Commit

Permalink
Merge pull request #548 from averevki/fix-geo-test
Browse files Browse the repository at this point in the history
Fix geo load balancing test after the api change
  • Loading branch information
averevki authored Oct 2, 2024
2 parents 8ee50f1 + f981621 commit 6f54c6c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion testsuite/kuadrant/policy/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LoadBalancing:

defaultGeo: bool # pylint: disable=invalid-name
geo: str
weight: Optional[int]
weight: Optional[int] = None


class DNSPolicy(Policy):
Expand Down
6 changes: 3 additions & 3 deletions testsuite/tests/multicluster/load_balanced/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 6f54c6c

Please sign in to comment.