From 5fa002557e2c71cf2219af2eb5d5bd4677038321 Mon Sep 17 00:00:00 2001 From: Matt Hagenbuch Date: Fri, 10 May 2024 09:41:56 -0400 Subject: [PATCH] e2e tests --- ...ntelemetry.io_opentelemetrycollectors.yaml | 1 - config/manager/kustomization.yaml | 6 ---- tests/e2e/managed-reconcile/02-assert.yaml | 2 +- tests/e2e/multiple-configmaps/00-assert.yaml | 2 +- .../e2e/smoke-targetallocator/00-assert.yaml | 2 +- tests/e2e/statefulset-features/00-assert.yaml | 2 +- tests/e2e/statefulset-features/01-assert.yaml | 2 +- tests/e2e/versioned-configmaps/00-assert.yaml | 28 ++++++++++++++++ .../e2e/versioned-configmaps/00-install.yaml | 27 +++++++++++++++ tests/e2e/versioned-configmaps/01-assert.yaml | 33 +++++++++++++++++++ tests/e2e/versioned-configmaps/01-update.yaml | 27 +++++++++++++++ tests/e2e/versioned-configmaps/02-error.yaml | 5 +++ tests/e2e/versioned-configmaps/02-update.yaml | 27 +++++++++++++++ .../versioned-configmaps/chainsaw-test.yaml | 28 ++++++++++++++++ 14 files changed, 180 insertions(+), 12 deletions(-) create mode 100644 tests/e2e/versioned-configmaps/00-assert.yaml create mode 100644 tests/e2e/versioned-configmaps/00-install.yaml create mode 100644 tests/e2e/versioned-configmaps/01-assert.yaml create mode 100644 tests/e2e/versioned-configmaps/01-update.yaml create mode 100644 tests/e2e/versioned-configmaps/02-error.yaml create mode 100644 tests/e2e/versioned-configmaps/02-update.yaml create mode 100755 tests/e2e/versioned-configmaps/chainsaw-test.yaml diff --git a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 5d02664177..938f63344a 100644 --- a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -5558,7 +5558,6 @@ spec: configVersions: format: int32 type: integer - default: 3 configmaps: items: properties: diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 79a1399047..5c5f0b84cb 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,8 +1,2 @@ resources: - manager.yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: controller - newName: localhost:5001/opentelemetry-operator - newTag: matth-dev-1714590016 diff --git a/tests/e2e/managed-reconcile/02-assert.yaml b/tests/e2e/managed-reconcile/02-assert.yaml index 0a6a83b1a3..0847c94ed8 100644 --- a/tests/e2e/managed-reconcile/02-assert.yaml +++ b/tests/e2e/managed-reconcile/02-assert.yaml @@ -52,7 +52,7 @@ spec: apiVersion: v1 kind: ConfigMap metadata: - name: simplest-collector + name: simplest-collector-17ca6c13 data: collector.yaml: | receivers: diff --git a/tests/e2e/multiple-configmaps/00-assert.yaml b/tests/e2e/multiple-configmaps/00-assert.yaml index 14c929470a..b040f87074 100644 --- a/tests/e2e/multiple-configmaps/00-assert.yaml +++ b/tests/e2e/multiple-configmaps/00-assert.yaml @@ -25,7 +25,7 @@ spec: volumes: - name: otc-internal configMap: - name: simplest-with-configmaps-collector + name: simplest-with-configmaps-collector-17ca6c13 items: - key: collector.yaml path: collector.yaml diff --git a/tests/e2e/smoke-targetallocator/00-assert.yaml b/tests/e2e/smoke-targetallocator/00-assert.yaml index 35a1d6356f..53d8bc5a89 100644 --- a/tests/e2e/smoke-targetallocator/00-assert.yaml +++ b/tests/e2e/smoke-targetallocator/00-assert.yaml @@ -45,4 +45,4 @@ data: - jaeger kind: ConfigMap metadata: - name: stateful-collector + name: stateful-collector-fb278632 diff --git a/tests/e2e/statefulset-features/00-assert.yaml b/tests/e2e/statefulset-features/00-assert.yaml index 744ba76e26..5363d785b9 100644 --- a/tests/e2e/statefulset-features/00-assert.yaml +++ b/tests/e2e/statefulset-features/00-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector + name: stateful-collector-f0fa6faa name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e/statefulset-features/01-assert.yaml b/tests/e2e/statefulset-features/01-assert.yaml index fdccb0fadd..c68dc9aa80 100644 --- a/tests/e2e/statefulset-features/01-assert.yaml +++ b/tests/e2e/statefulset-features/01-assert.yaml @@ -20,7 +20,7 @@ spec: items: - key: collector.yaml path: collector.yaml - name: stateful-collector + name: stateful-collector-f0fa6faa name: otc-internal - emptyDir: {} name: testvolume diff --git a/tests/e2e/versioned-configmaps/00-assert.yaml b/tests/e2e/versioned-configmaps/00-assert.yaml new file mode 100644 index 0000000000..a363c65a68 --- /dev/null +++ b/tests/e2e/versioned-configmaps/00-assert.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: simple-collector +spec: + template: + spec: + volumes: + - name: otc-internal + configMap: + name: simple-collector-d6f40475 + items: + - key: collector.yaml + path: collector.yaml + defaultMode: 420 + containers: + - name: otc-container + volumeMounts: + - name: otc-internal + mountPath: /conf +status: + readyReplicas: 1 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: simple-collector-d6f40475 diff --git a/tests/e2e/versioned-configmaps/00-install.yaml b/tests/e2e/versioned-configmaps/00-install.yaml new file mode 100644 index 0000000000..a34135e7f0 --- /dev/null +++ b/tests/e2e/versioned-configmaps/00-install.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: simple +spec: + mode: "deployment" + configVersions: 1 + config: + receivers: + otlp: + protocols: + grpc: {} + http: {} + processors: + batch: + send_batch_size: 10000 + timeout: 10s + exporters: + debug: {} + + service: + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [debug] diff --git a/tests/e2e/versioned-configmaps/01-assert.yaml b/tests/e2e/versioned-configmaps/01-assert.yaml new file mode 100644 index 0000000000..cfbb27c31c --- /dev/null +++ b/tests/e2e/versioned-configmaps/01-assert.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: simple-collector +spec: + template: + spec: + volumes: + - name: otc-internal + configMap: + name: simple-collector-8cd615bf + items: + - key: collector.yaml + path: collector.yaml + defaultMode: 420 + containers: + - name: otc-container + volumeMounts: + - name: otc-internal + mountPath: /conf +status: + readyReplicas: 1 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: simple-collector-d6f40475 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: simple-collector-8cd615bf diff --git a/tests/e2e/versioned-configmaps/01-update.yaml b/tests/e2e/versioned-configmaps/01-update.yaml new file mode 100644 index 0000000000..8004c4ef55 --- /dev/null +++ b/tests/e2e/versioned-configmaps/01-update.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: simple +spec: + mode: "deployment" + configVersions: 1 + config: + receivers: + otlp: + protocols: + grpc: {} + http: {} + processors: + batch: + send_batch_size: 10000 + timeout: 20s + exporters: + debug: {} + + service: + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [debug] diff --git a/tests/e2e/versioned-configmaps/02-error.yaml b/tests/e2e/versioned-configmaps/02-error.yaml new file mode 100644 index 0000000000..2b63829a6c --- /dev/null +++ b/tests/e2e/versioned-configmaps/02-error.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: simple-collector-d6f40475 diff --git a/tests/e2e/versioned-configmaps/02-update.yaml b/tests/e2e/versioned-configmaps/02-update.yaml new file mode 100644 index 0000000000..7cb8f19060 --- /dev/null +++ b/tests/e2e/versioned-configmaps/02-update.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: simple +spec: + mode: "deployment" + configVersions: 1 + config: + receivers: + otlp: + protocols: + grpc: {} + http: {} + processors: + batch: + send_batch_size: 10000 + timeout: 30s + exporters: + debug: {} + + service: + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [debug] \ No newline at end of file diff --git a/tests/e2e/versioned-configmaps/chainsaw-test.yaml b/tests/e2e/versioned-configmaps/chainsaw-test.yaml new file mode 100755 index 0000000000..f837498100 --- /dev/null +++ b/tests/e2e/versioned-configmaps/chainsaw-test.yaml @@ -0,0 +1,28 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: versioned-configmaps +spec: + steps: + - name: step-00 + try: + - apply: + file: 00-install.yaml + - assert: + file: 00-assert.yaml + # Update the collector config and ensure both the new and old confmaps are present + - name: step-01 + try: + - apply: + file: 01-update.yaml + - assert: + file: 01-assert.yaml + # Update the collector config again and ensure the oldest confmap is deleted + - name: step-02 + try: + - apply: + file: 02-update.yaml + - error: + file: 02-error.yaml \ No newline at end of file