Skip to content

Commit 7d00a40

Browse files
authored
Merge pull request #670 from averevki/fix-healthcheck
Improve wait on health-check tests
2 parents abebfcf + bd6252e commit 7d00a40

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

testsuite/kuadrant/policy/dns.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ class HealthCheck: # pylint: disable=invalid-name
5656
class DNSHealthCheckProbe(KubernetesObject):
5757
"""DNSHealthCheckProbe object"""
5858

59-
def _status_ready(self):
60-
"""Returns True if DNSHealthCheckProbe status.healthy field has appeared"""
61-
return self.wait_until(lambda obj: obj.model.status.healthy is not oc.Missing)
62-
6359
def is_healthy(self) -> bool:
6460
"""Returns True if DNSHealthCheckProbe endpoint is healthy"""
65-
assert self._status_ready(), "DNSHealthCheckProbe status wasn't ready in time"
66-
return self.refresh().model.status.healthy
61+
return self.model.status.healthy
62+
63+
def wait_for_ready(self):
64+
"""Returns True if DNSHealthCheckProbe status.healthy field has appeared"""
65+
success = self.wait_until(lambda obj: obj.model.status.healthy is not oc.Missing)
66+
assert success, "DNSHealthCheckProbe status wasn't ready in time"
6767

6868

6969
class DNSPolicy(Policy):

testsuite/tests/singlecluster/gateway/dnspolicy/health_check/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def dns_policy(dns_policy, health_check):
4444
@pytest.fixture(scope="module")
4545
def dns_health_probe(dns_policy):
4646
"""Return DNSHealthCheckProbe object for created DNSPolicy"""
47-
return dns_policy.get_dns_health_probe()
47+
dns_health_probe = dns_policy.get_dns_health_probe()
48+
dns_health_probe.wait_for_ready()
49+
return dns_health_probe
4850

4951

5052
@pytest.fixture(scope="module", autouse=True)

testsuite/tests/singlecluster/gateway/dnspolicy/health_check/test_remove_endpoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ def test_remove_endpoint(backend, dns_policy, dns_health_probe, client, auth):
3131
has_record_condition("Healthy", "False", "HealthChecksFailed", "Not healthy addresses:")
3232
)
3333

34-
assert not dns_health_probe.is_healthy()
34+
assert dns_health_probe.wait_until(lambda obj: not obj.is_healthy())
3535
response = client.get("/get", auth=auth)
3636
assert response.status_code == 503
3737

3838
backend.deployment.self_selector().scale(1)
3939
assert dns_policy.wait_until(has_condition("SubResourcesHealthy", "True"), timelimit=120)
4040

41-
assert dns_health_probe.is_healthy()
41+
assert dns_health_probe.wait_until(lambda obj: obj.is_healthy())
4242
response = client.get("/get", auth=auth)
4343
assert response.status_code == 200

0 commit comments

Comments
 (0)