Skip to content

Commit 08d46e4

Browse files
tests: add rollout restart of operator after ingress tests
1 parent e359d7d commit 08d46e4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/post/steps/test_ingress.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@
1414

1515
MAIN_CC_NAME = "main"
1616

17+
OPERATOR_DEPLOYMENT = "metalk8s-operator-controller-manager"
18+
OPERATOR_NAMESPACE = "kube-system"
19+
20+
21+
@pytest.fixture(autouse=True, scope="module")
22+
def restart_operator_after_ingress_tests(host):
23+
"""Reset the operator CrashLoopBackOff timer after all ingress tests.
24+
25+
Ingress tests heavily modify the ClusterConfig, which can cause the
26+
operator to panic and enter CrashLoopBackOff with increasing backoff
27+
delays. A rollout restart at the end of this module ensures the
28+
operator pod starts fresh (restartCount=0) before subsequent test
29+
modules (e.g. test_operator) that depend on quick operator recovery.
30+
"""
31+
yield
32+
with host.sudo():
33+
host.check_output(
34+
"kubectl --kubeconfig=/etc/kubernetes/admin.conf "
35+
f"rollout restart deployment/{OPERATOR_DEPLOYMENT} --namespace {OPERATOR_NAMESPACE}"
36+
)
37+
host.check_output(
38+
"kubectl --kubeconfig=/etc/kubernetes/admin.conf "
39+
f"rollout status deployment/{OPERATOR_DEPLOYMENT} --namespace {OPERATOR_NAMESPACE} --timeout=120s"
40+
)
41+
1742

1843
@scenario("../features/ingress.feature", "Access HTTP services")
1944
def test_access_http_services(host):

0 commit comments

Comments
 (0)