From 15d47c38b6551002926c2136424fe9408d94af97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Fri, 20 Oct 2023 12:05:07 +0200 Subject: [PATCH] test: show operator logs on e2e test failure --- .gitignore | 4 ++++ .../operator/daemonset-with-annotations/00-assert.yaml | 3 +++ .../operator/deployment-with-annotations/00-assert.yaml | 3 +++ .../operator/deployment-with-annotations/01-assert.yaml | 3 +++ tests/modified/operator/pod-with-annotations/00-assert.yaml | 3 +++ tests/modified/operator/pod-with-annotations/01-assert.yaml | 3 +++ tests/modified/operator/pod-with-cr/00-assert.yaml | 3 +++ tests/modified/operator/pod-with-cr/01-assert.yaml | 3 +++ .../operator/statefulset-with-annotations/00-assert.yaml | 3 +++ tests/operator/daemonset-with-annotations/00-assert.yaml | 3 +++ tests/operator/deployment-with-annotations/00-assert.yaml | 3 +++ tests/operator/deployment-with-annotations/01-assert.yaml | 3 +++ tests/operator/pod-with-annotations/00-assert.yaml | 3 +++ tests/operator/pod-with-annotations/01-assert.yaml | 3 +++ tests/operator/pod-with-cr/00-assert.yaml | 3 +++ tests/operator/pod-with-cr/01-assert.yaml | 3 +++ tests/operator/statefulset-with-annotations/00-assert.yaml | 3 +++ tests/sidecar/pod-with-sidecar/00-assert.yaml | 3 +++ 18 files changed, 55 insertions(+) diff --git a/.gitignore b/.gitignore index dd7a887b..78d6f863 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ tests/_build .kubeconfig kubeconfig + +# Go workspace files +go.work +go.work.sum \ No newline at end of file diff --git a/tests/modified/operator/daemonset-with-annotations/00-assert.yaml b/tests/modified/operator/daemonset-with-annotations/00-assert.yaml index 4a8baa77..c8a7d8fc 100644 --- a/tests/modified/operator/daemonset-with-annotations/00-assert.yaml +++ b/tests/modified/operator/daemonset-with-annotations/00-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - selector: app=daemonset-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs -l app=daemonset-with-annotations -c tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" - script: "[ $(kubectl logs -l app=daemonset-with-annotations -c tailing-sidecar-1 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/modified/operator/deployment-with-annotations/00-assert.yaml b/tests/modified/operator/deployment-with-annotations/00-assert.yaml index f9f072d7..928eff82 100644 --- a/tests/modified/operator/deployment-with-annotations/00-assert.yaml +++ b/tests/modified/operator/deployment-with-annotations/00-assert.yaml @@ -10,6 +10,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - selector: app=deployment-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs -l app=deployment-with-annotations -c tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" - script: "[ $(kubectl logs -l app=deployment-with-annotations -c tailing-sidecar-1 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/modified/operator/deployment-with-annotations/01-assert.yaml b/tests/modified/operator/deployment-with-annotations/01-assert.yaml index 6169af4f..b6123cc6 100644 --- a/tests/modified/operator/deployment-with-annotations/01-assert.yaml +++ b/tests/modified/operator/deployment-with-annotations/01-assert.yaml @@ -18,5 +18,8 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - selector: app=deployment-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs -l app=deployment-with-annotations -c tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/modified/operator/pod-with-annotations/00-assert.yaml b/tests/modified/operator/pod-with-annotations/00-assert.yaml index f3fdf96e..c83eb68c 100644 --- a/tests/modified/operator/pod-with-annotations/00-assert.yaml +++ b/tests/modified/operator/pod-with-annotations/00-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-annotations tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" - script: "[ $(kubectl logs pod-with-annotations named-container -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/modified/operator/pod-with-annotations/01-assert.yaml b/tests/modified/operator/pod-with-annotations/01-assert.yaml index 93390119..83d0e08a 100644 --- a/tests/modified/operator/pod-with-annotations/01-assert.yaml +++ b/tests/modified/operator/pod-with-annotations/01-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-annotations-updated +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-annotations-updated tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" - script: "[ $(kubectl logs pod-with-annotations-updated named-sidecar -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/modified/operator/pod-with-cr/00-assert.yaml b/tests/modified/operator/pod-with-cr/00-assert.yaml index 0dc0fe14..6bc4e027 100644 --- a/tests/modified/operator/pod-with-cr/00-assert.yaml +++ b/tests/modified/operator/pod-with-cr/00-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-tailing-sidecar-config +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-tailing-sidecar-config sidecar-0 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" - script: "[ $(kubectl logs pod-with-tailing-sidecar-config sidecar-1 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/modified/operator/pod-with-cr/01-assert.yaml b/tests/modified/operator/pod-with-cr/01-assert.yaml index 3e6970ec..65d692f2 100644 --- a/tests/modified/operator/pod-with-cr/01-assert.yaml +++ b/tests/modified/operator/pod-with-cr/01-assert.yaml @@ -12,5 +12,8 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-tailing-sidecar-config +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-tailing-sidecar-config sidecar-2 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/modified/operator/statefulset-with-annotations/00-assert.yaml b/tests/modified/operator/statefulset-with-annotations/00-assert.yaml index 5478a408..1e98d4bc 100644 --- a/tests/modified/operator/statefulset-with-annotations/00-assert.yaml +++ b/tests/modified/operator/statefulset-with-annotations/00-assert.yaml @@ -10,6 +10,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: statefulset-with-annotations-0 +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs statefulset-with-annotations-0 my-named-sidecar -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" - script: "[ $(kubectl logs statefulset-with-annotations-0 tailing-sidecar-1 -n ${NAMESPACE} --tail 5 | grep modified | wc -l) -eq 5 ]" diff --git a/tests/operator/daemonset-with-annotations/00-assert.yaml b/tests/operator/daemonset-with-annotations/00-assert.yaml index 3758548d..e97078d7 100644 --- a/tests/operator/daemonset-with-annotations/00-assert.yaml +++ b/tests/operator/daemonset-with-annotations/00-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - selector: app=daemonset-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs -l app=daemonset-with-annotations -c tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" - script: "[ $(kubectl logs -l app=daemonset-with-annotations -c tailing-sidecar-1 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/operator/deployment-with-annotations/00-assert.yaml b/tests/operator/deployment-with-annotations/00-assert.yaml index b333e566..201538d2 100644 --- a/tests/operator/deployment-with-annotations/00-assert.yaml +++ b/tests/operator/deployment-with-annotations/00-assert.yaml @@ -10,6 +10,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - selector: app=deployment-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs -l app=deployment-with-annotations -c tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" - script: "[ $(kubectl logs -l app=deployment-with-annotations -c tailing-sidecar-1 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/operator/deployment-with-annotations/01-assert.yaml b/tests/operator/deployment-with-annotations/01-assert.yaml index 6ededf9b..df7e470a 100644 --- a/tests/operator/deployment-with-annotations/01-assert.yaml +++ b/tests/operator/deployment-with-annotations/01-assert.yaml @@ -18,5 +18,8 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - selector: app=deployment-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs -l app=deployment-with-annotations -c tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/operator/pod-with-annotations/00-assert.yaml b/tests/operator/pod-with-annotations/00-assert.yaml index 27a7fb43..f4156c33 100644 --- a/tests/operator/pod-with-annotations/00-assert.yaml +++ b/tests/operator/pod-with-annotations/00-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-annotations +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-annotations tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" - script: "[ $(kubectl logs pod-with-annotations named-container -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/operator/pod-with-annotations/01-assert.yaml b/tests/operator/pod-with-annotations/01-assert.yaml index 97edee12..acf45cbb 100644 --- a/tests/operator/pod-with-annotations/01-assert.yaml +++ b/tests/operator/pod-with-annotations/01-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-annotations-updated +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-annotations-updated tailing-sidecar-0 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" - script: "[ $(kubectl logs pod-with-annotations-updated named-sidecar -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/operator/pod-with-cr/00-assert.yaml b/tests/operator/pod-with-cr/00-assert.yaml index a717d3e7..3f279393 100644 --- a/tests/operator/pod-with-cr/00-assert.yaml +++ b/tests/operator/pod-with-cr/00-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-tailing-sidecar-config +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-tailing-sidecar-config sidecar-0 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" - script: "[ $(kubectl logs pod-with-tailing-sidecar-config sidecar-1 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/operator/pod-with-cr/01-assert.yaml b/tests/operator/pod-with-cr/01-assert.yaml index eb71ec74..9a01443f 100644 --- a/tests/operator/pod-with-cr/01-assert.yaml +++ b/tests/operator/pod-with-cr/01-assert.yaml @@ -12,5 +12,8 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: pod-with-tailing-sidecar-config +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs pod-with-tailing-sidecar-config sidecar-2 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/operator/statefulset-with-annotations/00-assert.yaml b/tests/operator/statefulset-with-annotations/00-assert.yaml index c3d7ae0f..f581fe16 100644 --- a/tests/operator/statefulset-with-annotations/00-assert.yaml +++ b/tests/operator/statefulset-with-annotations/00-assert.yaml @@ -10,6 +10,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: statefulset-with-annotations-0 +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs statefulset-with-annotations-0 my-named-sidecar -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" - script: "[ $(kubectl logs statefulset-with-annotations-0 tailing-sidecar-1 -n ${NAMESPACE} --tail 5 | grep example | wc -l) -eq 5 ]" diff --git a/tests/sidecar/pod-with-sidecar/00-assert.yaml b/tests/sidecar/pod-with-sidecar/00-assert.yaml index 81283a5a..9bbc45b0 100644 --- a/tests/sidecar/pod-with-sidecar/00-assert.yaml +++ b/tests/sidecar/pod-with-sidecar/00-assert.yaml @@ -9,6 +9,9 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: - pod: example-with-tailling-sidecars +- selector: app.kubernetes.io/name=tailing-sidecar-operator + namespace: tailing-sidecar-system + tail: 100 commands: - script: "[ $(kubectl logs -n $NAMESPACE --tail 5 example-with-tailling-sidecars sidecar1 | grep example1 | wc -l) -eq 5 ]" - script: "[ $(kubectl logs -n $NAMESPACE --tail 5 example-with-tailling-sidecars sidecar2 | grep example2 | wc -l) -eq 5 ]"