From e3e140ff877985df37a6ddaf8f99aa7cf972e42f Mon Sep 17 00:00:00 2001 From: Ishwar Kanse Date: Fri, 22 Nov 2024 12:44:29 +0530 Subject: [PATCH] Test operator restart --- .../assert-operator-pod-deletion.yaml | 16 ++++++++ .../assert-operator-pod-running.yaml | 16 ++++++++ tests/e2e/operator-restart/chainsaw-test.yaml | 38 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 tests/e2e/operator-restart/assert-operator-pod-deletion.yaml create mode 100644 tests/e2e/operator-restart/assert-operator-pod-running.yaml create mode 100644 tests/e2e/operator-restart/chainsaw-test.yaml diff --git a/tests/e2e/operator-restart/assert-operator-pod-deletion.yaml b/tests/e2e/operator-restart/assert-operator-pod-deletion.yaml new file mode 100644 index 0000000000..44c54a9c51 --- /dev/null +++ b/tests/e2e/operator-restart/assert-operator-pod-deletion.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +count: 1 +involvedObject: + apiVersion: v1 + fieldPath: spec.containers{manager} + kind: Pod + namespace: ($OTEL_NAMESPACE) +kind: Event +message: Stopping container manager +metadata: + namespace: ($OTEL_NAMESPACE) +reason: Killing +reportingComponent: kubelet +source: + component: kubelet +type: Normal \ No newline at end of file diff --git a/tests/e2e/operator-restart/assert-operator-pod-running.yaml b/tests/e2e/operator-restart/assert-operator-pod-running.yaml new file mode 100644 index 0000000000..d8131db398 --- /dev/null +++ b/tests/e2e/operator-restart/assert-operator-pod-running.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Pod +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager + namespace: ($OTEL_NAMESPACE) +status: + containerStatuses: + - name: kube-rbac-proxy + ready: true + started: true + - name: manager + ready: true + started: true + phase: Running diff --git a/tests/e2e/operator-restart/chainsaw-test.yaml b/tests/e2e/operator-restart/chainsaw-test.yaml new file mode 100644 index 0000000000..9ad9070059 --- /dev/null +++ b/tests/e2e/operator-restart/chainsaw-test.yaml @@ -0,0 +1,38 @@ +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: operator-restart +spec: + # Running the test serially as its disruptive causing operator pod restart + concurrent: false + steps: + - name: Delete operator pod + try: + - command: + entrypoint: oc + args: + - get + - pods + - -A + - -l control-plane=controller-manager + - -l app.kubernetes.io/name=opentelemetry-operator + - -o + - jsonpath={.items[0].metadata.namespace} + outputs: + - name: OTEL_NAMESPACE + value: ($stdout) + - delete: + ref: + apiVersion: v1 + kind: Pod + namespace: ($OTEL_NAMESPACE) + labels: + control-plane: controller-manager + app.kubernetes.io/name: opentelemetry-operator + - assert: + file: assert-operator-pod-deletion.yaml + # Adding 10s sleep here cause sometimes the pod will be in running state for a while but can fail later if there is any issue with the component startup. + - sleep: + duration: 10s + - assert: + file: assert-operator-pod-running.yaml \ No newline at end of file