Skip to content

Commit 7ff30c8

Browse files
author
Jakub Smolar
authored
Merge pull request #596 from averevki/fix-reconciliation-tests
Fix gateway reconciliation tests
2 parents 938aed4 + a51777a commit 7ff30c8

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

testsuite/tests/singlecluster/gateway/reconciliation/test_affected_by.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def test_route_status(route, rate_limit, authorization):
2525
assert route.is_affected_by(authorization)
2626

2727
rate_limit.delete()
28-
assert not route.wait_until(lambda obj: obj.is_affected_by(rate_limit))
28+
assert route.wait_until(lambda obj: not obj.is_affected_by(rate_limit))
2929

3030
authorization.delete()
31-
assert not route.wait_until(lambda obj: obj.is_affected_by(authorization))
31+
assert route.wait_until(lambda obj: not obj.is_affected_by(authorization))
3232

3333

3434
@pytest.mark.dnspolicy
@@ -40,7 +40,7 @@ def test_gateway_status(gateway, dns_policy, tls_policy):
4040
assert gateway.is_affected_by(tls_policy)
4141

4242
dns_policy.delete()
43-
assert not gateway.wait_until(lambda obj: obj.is_affected_by(dns_policy))
43+
assert gateway.wait_until(lambda obj: not obj.is_affected_by(dns_policy))
4444

4545
tls_policy.delete()
46-
assert not gateway.wait_until(lambda obj: obj.is_affected_by(tls_policy))
46+
assert gateway.wait_until(lambda obj: not obj.is_affected_by(tls_policy))

testsuite/tests/singlecluster/gateway/reconciliation/test_same_target.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111

1212
@pytest.mark.parametrize(
13-
"policy_cr, issuer_or_secret",
13+
"policy_cr, policy_affected, issuer_or_secret",
1414
[
15-
pytest.param(DNSPolicy, "dns_provider_secret", id="DNSPolicy", marks=[pytest.mark.dnspolicy]),
16-
pytest.param(TLSPolicy, "cluster_issuer", id="TLSPolicy", marks=[pytest.mark.tlspolicy]),
15+
pytest.param(DNSPolicy, "dns_policy", "dns_provider_secret", id="DNSPolicy", marks=[pytest.mark.dnspolicy]),
16+
pytest.param(TLSPolicy, "tls_policy", "cluster_issuer", id="TLSPolicy", marks=[pytest.mark.tlspolicy]),
1717
],
1818
)
19-
def test_two_policies_one_gw(request, policy_cr, issuer_or_secret, gateway, client, blame, module_label, auth):
19+
def test_two_policies_one_gw(
20+
request, policy_cr, policy_affected, issuer_or_secret, gateway, client, blame, module_label, auth
21+
):
2022
"""Tests that policy is rejected when the Gateway already has a DNSPolicy"""
2123

2224
# test that it works before the policy
@@ -25,20 +27,26 @@ def test_two_policies_one_gw(request, policy_cr, issuer_or_secret, gateway, clie
2527

2628
# depending on if DNSPolicy or TLSPolicy is tested the right object for the 4th parameter is passed
2729
issuer_or_secret_obj = request.getfixturevalue(issuer_or_secret)
28-
policy = policy_cr.create_instance(
30+
policy_new = policy_cr.create_instance(
2931
gateway.cluster,
3032
blame("dns2"),
3133
gateway,
3234
issuer_or_secret_obj,
3335
labels={"app": module_label},
3436
)
35-
request.addfinalizer(policy.delete)
36-
policy.commit()
37-
38-
# Wait for expected status
39-
assert policy.wait_until(
40-
has_condition("Accepted", "False", "Conflicted", "is already referenced by policy"), timelimit=20
41-
), f"Policy did not reach expected status, instead it was: {policy.refresh().model.status.conditions}"
37+
request.addfinalizer(policy_new.delete)
38+
policy_new.commit()
39+
40+
policy = request.getfixturevalue(policy_affected)
41+
assert policy_new.wait_until(
42+
has_condition(
43+
"Accepted",
44+
"False",
45+
"Conflicted",
46+
f"{policy_new.model.kind} is conflicted by {policy.namespace()}/{policy.name()}: conflicting policy",
47+
),
48+
timelimit=20,
49+
), f"Policy did not reach expected status, instead it was: {policy_new.refresh().model.status.conditions}"
4250

4351
# Test that the original policy still works
4452
response = client.get("get", auth=auth)

0 commit comments

Comments
 (0)