diff --git a/tests/templates/kuttl/restarter/10-assert.yaml b/tests/templates/kuttl/restarter/10-assert.yaml index dbf238f..038fa75 100644 --- a/tests/templates/kuttl/restarter/10-assert.yaml +++ b/tests/templates/kuttl/restarter/10-assert.yaml @@ -2,11 +2,26 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert timeout: 120 ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: test -status: - readyReplicas: 1 - replicas: 1 +commands: + - script: | + # N.B. due to breaking change https://github.com/kudobuilder/kuttl/pull/519 + # version >=0.17 of Kuttl is required for paths to be resolved consistently. + # For local testing, either use nix-shell before running the test script + # or upgrade kuttl as needed (with e.g. kubectl krew upgrade kuttl) + . ./test-script.sh + + # Wait for the StatefulSet to be deployed + kubectl rollout status statefulset/test --namespace "$NAMESPACE" + + # Check the initial status to detect some typos in the test setup + + assert_revision 1 configmap-not-ignored-subpath + assert_revision 1 secret-not-ignored-subpath + assert_revision 1 configmap-self-ignored-subpath + assert_revision 1 secret-self-ignored-subpath + assert_revision 1 configmap-self-ignored + assert_revision 1 secret-self-ignored + assert_revision 1 configmap-ignored-in-statefulset-subpath + assert_revision 1 secret-ignored-in-statefulset-subpath + assert_revision 1 configmap-ignored-in-statefulset + assert_revision 1 secret-ignored-in-statefulset diff --git a/tests/templates/kuttl/restarter/10-create-test-resources.yaml b/tests/templates/kuttl/restarter/10-create-test-resources.yaml index 0bc86fc..ba24fa7 100644 --- a/tests/templates/kuttl/restarter/10-create-test-resources.yaml +++ b/tests/templates/kuttl/restarter/10-create-test-resources.yaml @@ -17,7 +17,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: configmap-self-ignored - annotations: + labels: restarter.stackable.tech/ignore: "true" data: revision: "1" @@ -26,7 +26,7 @@ apiVersion: v1 kind: Secret metadata: name: secret-self-ignored - annotations: + labels: restarter.stackable.tech/ignore: "true" stringData: revision: "1" @@ -51,6 +51,7 @@ metadata: name: test labels: restarter.stackable.tech/enabled: "true" + annotations: restarter.stackable.tech/ignore-configmap.0: configmap-ignored-in-statefulset restarter.stackable.tech/ignore-secret.0: secret-ignored-in-statefulset spec: diff --git a/tests/templates/kuttl/restarter/20-assert.yaml b/tests/templates/kuttl/restarter/20-assert.yaml index 42f197f..6ae76e5 100644 --- a/tests/templates/kuttl/restarter/20-assert.yaml +++ b/tests/templates/kuttl/restarter/20-assert.yaml @@ -4,7 +4,14 @@ kind: TestAssert timeout: 180 commands: - script: | - . ../../../../templates/kuttl/restarter/test-script.sh + . ./test-script.sh + + # Wait for a possible restart of the test pod. + # The restarter controller is expected to ignore the changes in this step, so no restart + # should occur. However, if a restart does happen (due to a controller bug or test issue), + # wait here so we can verify assertions after the restart and ensure this test step fails + # reliably. + sleep 10 # Resources mounted via subPath are not hot-reloaded by Kubernetes. # It is expected, that the restart controller ignored the annotated resources and that only diff --git a/tests/templates/kuttl/restarter/21-assert.yaml b/tests/templates/kuttl/restarter/21-assert.yaml index 974de6f..dc66b6a 100644 --- a/tests/templates/kuttl/restarter/21-assert.yaml +++ b/tests/templates/kuttl/restarter/21-assert.yaml @@ -4,7 +4,7 @@ kind: TestAssert timeout: 180 commands: - script: | - . ../../../../templates/kuttl/restarter/test-script.sh + . ./test-script.sh # After a restart, all resources should have been updated.