From eb6ac9b882701cc1b797ff5824eeb120a607056f Mon Sep 17 00:00:00 2001 From: lwpk110 Date: Fri, 16 Aug 2024 13:59:40 +0800 Subject: [PATCH] test: update chainsaw to v0.2.6 --- .chainsaw.yaml | 2 +- Makefile | 25 +++++-------- test/e2e/default/00-assert.yaml | 22 ------------ test/e2e/default/chainsaw-test.yaml | 36 +++++++++++++++++++ .../{04-assert.yaml => kafka-assert.yaml} | 4 +-- .../e2e/default/{04-kafka.yaml => kafka.yaml} | 1 - test/e2e/setup/olm-assert.yaml | 14 ++++++++ .../{default/00-olm.yaml => setup/olm.yaml} | 18 ++-------- .../secret-assert.yaml} | 1 - .../02-secret.yaml => setup/secret.yaml} | 9 ++--- .../01-assert.yaml => setup/subs-assert.yaml} | 3 -- .../{default/01-subs.yaml => setup/subs.yaml} | 16 ++++----- .../zookeeper-assert.yaml} | 2 -- .../zookeeper.yaml} | 3 -- 14 files changed, 73 insertions(+), 83 deletions(-) delete mode 100644 test/e2e/default/00-assert.yaml create mode 100644 test/e2e/default/chainsaw-test.yaml rename test/e2e/default/{04-assert.yaml => kafka-assert.yaml} (66%) rename test/e2e/default/{04-kafka.yaml => kafka.yaml} (97%) create mode 100644 test/e2e/setup/olm-assert.yaml rename test/e2e/{default/00-olm.yaml => setup/olm.yaml} (67%) rename test/e2e/{default/02-assert.yaml => setup/secret-assert.yaml} (94%) rename test/e2e/{default/02-secret.yaml => setup/secret.yaml} (89%) rename test/e2e/{default/01-assert.yaml => setup/subs-assert.yaml} (77%) rename test/e2e/{default/01-subs.yaml => setup/subs.yaml} (67%) rename test/e2e/{default/03-assert.yaml => setup/zookeeper-assert.yaml} (76%) rename test/e2e/{default/03-zookeeper.yaml => setup/zookeeper.yaml} (94%) diff --git a/.chainsaw.yaml b/.chainsaw.yaml index 9a0e7d0..7182725 100644 --- a/.chainsaw.yaml +++ b/.chainsaw.yaml @@ -10,5 +10,5 @@ spec: delete: 240s error: 120s exec: 45s - skipDelete: true + skipDelete: false failFast: true diff --git a/Makefile b/Makefile index 740a517..974eeda 100644 --- a/Makefile +++ b/Makefile @@ -385,22 +385,14 @@ kind-delete: kind ## Delete a kind cluster. # chainsaw -CHAINSAW_VERSION ?= v0.1.8 +CHAINSAW_VERSION ?= v0.2.6 +CHAINSAW = $(LOCALBIN)/chainsaw .PHONY: chainsaw -CHAINSAW = $(LOCALBIN)/chainsaw -chainsaw: ## Download chainsaw locally if necessary. -ifeq (,$(shell which $(CHAINSAW))) -ifeq (,$(shell which chainsaw 2>/dev/null)) - @{ \ - set -e ;\ - go install github.com/kyverno/chainsaw@$(CHAINSAW_VERSION) ;\ - } -CHAINSAW = $(GOBIN)/chainsaw -else -CHAINSAW = $(shell which chainsaw) -endif -endif +chainsaw: $(CHAINSAW) ## Download chainsaw locally if necessary. +$(CHAINSAW): $(LOCALBIN) + test -s $(LOCALBIN)/chainsaw && $(LOCALBIN)/chainsaw version | grep -q $(CHAINSAW_VERSION) || \ + GOBIN=$(LOCALBIN) go install github.com/kyverno/chainsaw@$(CHAINSAW_VERSION) # chainsaw setup logical # - Build the operator docker image @@ -414,11 +406,10 @@ chainsaw-setup: manifests kustomize ## Run the chainsaw setup make docker-build $(KIND) --name $(KIND_CLUSTER_NAME) load docker-image $(IMG) KUBECONFIG=$(KIND_KUBECONFIG) make deploy - + .PHONY: chainsaw-test chainsaw-test: chainsaw ## Run the chainsaw test - $(CHAINSAW) test --cluster cluster-1=$(KIND_KUBECONFIG) --test-dir ./test/e2e - + KUBECONFIG=$(KIND_KUBECONFIG) $(CHAINSAW) test --cluster cluster-1=$(KIND_KUBECONFIG) --test-dir ./test/e2e/ .PHONY: chainsaw-cleanup chainsaw-cleanup: manifests kustomize ## Run the chainsaw cleanup diff --git a/test/e2e/default/00-assert.yaml b/test/e2e/default/00-assert.yaml deleted file mode 100644 index 9f37ead..0000000 --- a/test/e2e/default/00-assert.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: kubedatastack-operators -status: - phase: Active ---- -apiVersion: v1 -kind: Namespace -metadata: - name: kubedatastack -status: - phase: Active ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: CatalogSource -metadata: - name: kubedata-catalog - namespace: olm -status: - connectionState: - lastObservedState: READY diff --git a/test/e2e/default/chainsaw-test.yaml b/test/e2e/default/chainsaw-test.yaml new file mode 100644 index 0000000..dbec839 --- /dev/null +++ b/test/e2e/default/chainsaw-test.yaml @@ -0,0 +1,36 @@ +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: default +spec: + steps: + - try: + - apply: + file: ../setup/olm.yaml + - assert: + file: ../setup/olm-assert.yaml + - try: + - apply: + file: ../setup/subs.yaml + - assert: + file: ../setup/subs-assert.yaml + - apply: + file: ../setup/secret.yaml + - assert: + file: ../setup/secret-assert.yaml + - try: + - apply: + file: ../setup/zookeeper.yaml + - assert: + file: ../setup/zookeeper-assert.yaml + cleanup: + - sleep: + duration: 30s + - try: + - apply: + file: kafka.yaml + - assert: + file: kafka-assert.yaml + cleanup: + - sleep: + duration: 10s \ No newline at end of file diff --git a/test/e2e/default/04-assert.yaml b/test/e2e/default/kafka-assert.yaml similarity index 66% rename from test/e2e/default/04-assert.yaml rename to test/e2e/default/kafka-assert.yaml index b076d0f..6b4d2c5 100644 --- a/test/e2e/default/04-assert.yaml +++ b/test/e2e/default/kafka-assert.yaml @@ -2,12 +2,10 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: kafkacluster-sample-default-broker - namespace: kubedatastack status: replicas: 3 --- apiVersion: v1 kind: ConfigMap metadata: - name: kafkacluster-sample - namespace: kubedatastack \ No newline at end of file + name: kafkacluster-sample \ No newline at end of file diff --git a/test/e2e/default/04-kafka.yaml b/test/e2e/default/kafka.yaml similarity index 97% rename from test/e2e/default/04-kafka.yaml rename to test/e2e/default/kafka.yaml index 8ef48bb..b849143 100644 --- a/test/e2e/default/04-kafka.yaml +++ b/test/e2e/default/kafka.yaml @@ -8,7 +8,6 @@ metadata: app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: kafka-operator name: kafkacluster-sample - namespace: kubedatastack spec: clusterConfig: tls: diff --git a/test/e2e/setup/olm-assert.yaml b/test/e2e/setup/olm-assert.yaml new file mode 100644 index 0000000..0925c4c --- /dev/null +++ b/test/e2e/setup/olm-assert.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: operators.coreos.com/v1 +kind: OperatorGroup +metadata: + name: kubedoop-system +--- +apiVersion: operators.coreos.com/v1alpha1 +kind: CatalogSource +metadata: + name: kubedoop-catalog +status: + connectionState: + lastObservedState: READY + diff --git a/test/e2e/default/00-olm.yaml b/test/e2e/setup/olm.yaml similarity index 67% rename from test/e2e/default/00-olm.yaml rename to test/e2e/setup/olm.yaml index 622c06c..043fe94 100644 --- a/test/e2e/default/00-olm.yaml +++ b/test/e2e/setup/olm.yaml @@ -1,29 +1,17 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: kubedatastack-operators ---- -apiVersion: v1 -kind: Namespace -metadata: - name: kubedatastack ---- apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: - name: zncdata-stack - namespace: kubedatastack-operators + name: kubedoop-system spec: # if not specified, the operator group will target all namespaces # so the operator will be able to watch and manage resources in all namespaces targetNamespaces: - - kubedatastack + - ($namespace) --- apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: - name: kubedata-catalog - namespace: olm + name: kubedoop-catalog spec: sourceType: grpc grpcPodConfig: diff --git a/test/e2e/default/02-assert.yaml b/test/e2e/setup/secret-assert.yaml similarity index 94% rename from test/e2e/default/02-assert.yaml rename to test/e2e/setup/secret-assert.yaml index 5e36a04..875bbb4 100644 --- a/test/e2e/default/02-assert.yaml +++ b/test/e2e/setup/secret-assert.yaml @@ -12,7 +12,6 @@ apiVersion: apps/v1 kind: DaemonSet metadata: name: secretcsi-sample-csi - namespace: kubedatastack status: currentNumberScheduled: 1 desiredNumberScheduled: 1 diff --git a/test/e2e/default/02-secret.yaml b/test/e2e/setup/secret.yaml similarity index 89% rename from test/e2e/default/02-secret.yaml rename to test/e2e/setup/secret.yaml index 9ae897d..1eb7a46 100644 --- a/test/e2e/default/02-secret.yaml +++ b/test/e2e/setup/secret.yaml @@ -2,7 +2,6 @@ apiVersion: secrets.zncdata.dev/v1alpha1 kind: SecretClass metadata: name: tls - namespace: kubedatastack spec: backend: autoTls: @@ -11,14 +10,13 @@ spec: caCertificateLifeTime: 730h secret: name: tls-hdfs-ca - namespace: kubedatastack + nameSpace: ($namespace) maxCertificateLifeTime: 360h --- apiVersion: secrets.zncdata.dev/v1alpha1 kind: SecretClass metadata: name: kafka-internal-tls - namespace: kubedatastack spec: backend: autoTls: @@ -27,7 +25,7 @@ spec: caCertificateLifeTime: 730h secret: name: tls-hdfs-ca - namespace: kubedatastack + nameSpace: ($namespace) maxCertificateLifeTime: 360h --- apiVersion: secrets.zncdata.dev/v1alpha1 @@ -40,7 +38,6 @@ metadata: app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: secret-operator name: secretcsi-sample - namespace: kubedatastack spec: csiDriver: repository: quay.io/zncdatadev/secret-csi-driver @@ -65,4 +62,4 @@ spec: tag: v2.11.0 pullPolicy: IfNotPresent logging: - level: "10" \ No newline at end of file + level: "10" diff --git a/test/e2e/default/01-assert.yaml b/test/e2e/setup/subs-assert.yaml similarity index 77% rename from test/e2e/default/01-assert.yaml rename to test/e2e/setup/subs-assert.yaml index 9214f78..e355774 100644 --- a/test/e2e/default/01-assert.yaml +++ b/test/e2e/setup/subs-assert.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: Deployment metadata: name: zookeeper-operator-controller-manager - namespace: kubedatastack-operators status: availableReplicas: 1 --- @@ -10,7 +9,6 @@ apiVersion: apps/v1 kind: Deployment metadata: name: listener-operator-controller-manager - namespace: kubedatastack-operators status: availableReplicas: 1 --- @@ -18,6 +16,5 @@ apiVersion: apps/v1 kind: Deployment metadata: name: secret-operator-controller-manager - namespace: kubedatastack-operators status: availableReplicas: 1 \ No newline at end of file diff --git a/test/e2e/default/01-subs.yaml b/test/e2e/setup/subs.yaml similarity index 67% rename from test/e2e/default/01-subs.yaml rename to test/e2e/setup/subs.yaml index 84b5477..bf30916 100644 --- a/test/e2e/default/01-subs.yaml +++ b/test/e2e/setup/subs.yaml @@ -2,34 +2,32 @@ apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: listener-sub - namespace: kubedatastack-operators spec: channel: stable name: listener-operator - source: kubedata-catalog - sourceNamespace: olm + source: kubedoop-catalog + sourceNamespace: ($namespace) installPlanApproval: Automated --- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: secret-sub - namespace: kubedatastack-operators spec: channel: stable name: secret-operator - source: kubedata-catalog - sourceNamespace: olm + source: kubedoop-catalog + sourceNamespace: ($namespace) installPlanApproval: Automated --- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: zookeeper-sub - namespace: kubedatastack-operators spec: channel: stable name: zookeeper-operator - source: kubedata-catalog - sourceNamespace: olm + source: kubedoop-catalog + sourceNamespace: ($namespace) installPlanApproval: Automated + diff --git a/test/e2e/default/03-assert.yaml b/test/e2e/setup/zookeeper-assert.yaml similarity index 76% rename from test/e2e/default/03-assert.yaml rename to test/e2e/setup/zookeeper-assert.yaml index 97b47f6..94ca5a2 100644 --- a/test/e2e/default/03-assert.yaml +++ b/test/e2e/setup/zookeeper-assert.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: zookeepercluster-sample-default - namespace: kubedatastack status: replicas: 1 --- @@ -10,4 +9,3 @@ apiVersion: v1 kind: ConfigMap metadata: name: kafka-znode - namespace: kubedatastack diff --git a/test/e2e/default/03-zookeeper.yaml b/test/e2e/setup/zookeeper.yaml similarity index 94% rename from test/e2e/default/03-zookeeper.yaml rename to test/e2e/setup/zookeeper.yaml index 09ccfad..b6fecef 100644 --- a/test/e2e/default/03-zookeeper.yaml +++ b/test/e2e/setup/zookeeper.yaml @@ -8,7 +8,6 @@ metadata: app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: zookeeper-operator name: zookeepercluster-sample - namespace: kubedatastack spec: image: repository: docker.io/bitnami/zookeeper @@ -47,9 +46,7 @@ metadata: app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: zookeeper-operator name: kafka-znode - namespace: kubedatastack spec: clusterRef: name: zookeepercluster-sample - namespace: kubedatastack