Skip to content

Commit 506502d

Browse files
test: Fix the restarter test
1 parent 2822e09 commit 506502d

4 files changed

Lines changed: 31 additions & 12 deletions

File tree

tests/templates/kuttl/restarter/10-assert.yaml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
44
timeout: 120
5-
---
6-
apiVersion: apps/v1
7-
kind: StatefulSet
8-
metadata:
9-
name: test
10-
status:
11-
readyReplicas: 1
12-
replicas: 1
5+
commands:
6+
- script: |
7+
. test-script.sh
8+
9+
# Wait for the StatefulSet to be deployed
10+
kubectl rollout status statefulset/test --namespace "$NAMESPACE"
11+
12+
# Check the initial status to detect some typos in the test setup
13+
14+
assert_revision 1 configmap-not-ignored-subpath
15+
assert_revision 1 secret-not-ignored-subpath
16+
assert_revision 1 configmap-self-ignored-subpath
17+
assert_revision 1 secret-self-ignored-subpath
18+
assert_revision 1 configmap-self-ignored
19+
assert_revision 1 secret-self-ignored
20+
assert_revision 1 configmap-ignored-in-statefulset-subpath
21+
assert_revision 1 secret-ignored-in-statefulset-subpath
22+
assert_revision 1 configmap-ignored-in-statefulset
23+
assert_revision 1 secret-ignored-in-statefulset

tests/templates/kuttl/restarter/10-create-test-resources.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ apiVersion: v1
1717
kind: ConfigMap
1818
metadata:
1919
name: configmap-self-ignored
20-
annotations:
20+
labels:
2121
restarter.stackable.tech/ignore: "true"
2222
data:
2323
revision: "1"
@@ -26,7 +26,7 @@ apiVersion: v1
2626
kind: Secret
2727
metadata:
2828
name: secret-self-ignored
29-
annotations:
29+
labels:
3030
restarter.stackable.tech/ignore: "true"
3131
stringData:
3232
revision: "1"
@@ -51,6 +51,7 @@ metadata:
5151
name: test
5252
labels:
5353
restarter.stackable.tech/enabled: "true"
54+
annotations:
5455
restarter.stackable.tech/ignore-configmap.0: configmap-ignored-in-statefulset
5556
restarter.stackable.tech/ignore-secret.0: secret-ignored-in-statefulset
5657
spec:

tests/templates/kuttl/restarter/20-assert.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ kind: TestAssert
44
timeout: 180
55
commands:
66
- script: |
7-
. ../../../../templates/kuttl/restarter/test-script.sh
7+
. test-script.sh
8+
9+
# Wait for a possible restart of the test pod.
10+
# The restarter controller is expected to ignore the changes in this step, so no restart
11+
# should occur. However, if a restart does happen (due to a controller bug or test issue),
12+
# wait here so we can verify assertions after the restart and ensure this test step fails
13+
# reliably.
14+
sleep 10
815
916
# Resources mounted via subPath are not hot-reloaded by Kubernetes.
1017
# It is expected, that the restart controller ignored the annotated resources and that only

tests/templates/kuttl/restarter/21-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: TestAssert
44
timeout: 180
55
commands:
66
- script: |
7-
. ../../../../templates/kuttl/restarter/test-script.sh
7+
. test-script.sh
88
99
# After a restart, all resources should have been updated.
1010

0 commit comments

Comments
 (0)