Skip to content

Commit

Permalink
test: show operator logs on e2e test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Oct 20, 2023
1 parent 7526c78 commit bbe074c
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ tests/_build

.kubeconfig
kubeconfig

# Go workspace files
go.work
go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ 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
- selector: control-plane=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 ]"
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/modified/operator/pod-with-annotations/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/modified/operator/pod-with-annotations/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
Expand Down
6 changes: 6 additions & 0 deletions tests/modified/operator/pod-with-cr/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
Expand Down
6 changes: 6 additions & 0 deletions tests/modified/operator/pod-with-cr/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ 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
- selector: control-plane=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 ]"
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/operator/daemonset-with-annotations/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/operator/deployment-with-annotations/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/operator/deployment-with-annotations/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/operator/pod-with-annotations/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/operator/pod-with-annotations/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
Expand Down
6 changes: 6 additions & 0 deletions tests/operator/pod-with-cr/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"
Expand Down
6 changes: 6 additions & 0 deletions tests/operator/pod-with-cr/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/operator/statefulset-with-annotations/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ 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
- selector: control-plane=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 ]"
6 changes: 6 additions & 0 deletions tests/sidecar/pod-with-sidecar/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ 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
- selector: control-plane=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 ]"

0 comments on commit bbe074c

Please sign in to comment.