diff --git a/Makefile b/Makefile index b1d6cbe..aad3e56 100644 --- a/Makefile +++ b/Makefile @@ -336,6 +336,47 @@ catalog-buildx: ## Build and push a catalog image for cross-platform support ##@ E2E +##@ helm + +HELM_VERSION ?= v3.16.2 +HELM = $(LOCALBIN)/helm + +.PHONY: helm +helm: ## Download helm locally if necessary. +ifeq (,$(shell which $(HELM))) +ifeq (,$(shell which helm 2>/dev/null)) + @{ \ + set -e ;\ + mkdir -p $(dir $(HELM)) ;\ + OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ + curl -sSL https://get.helm.sh/helm-$(HELM_VERSION)-$${OS}-$${ARCH}.tar.gz | tar -xz -C $(LOCALBIN) --strip-components=1 $${OS}-$${ARCH}/helm ;\ + chmod +x $(HELM) ;\ + } +else +HELM = $(shell which helm) +endif +endif + +HELM_DEPENDS ?= commons-operator secret-operator listener-operator zookeeper-operator hdfs-operator +TEST_NAMESPACE = kubedoop-operators + +.PHONY: helm-install-depends +helm-install-depends: ## Install the helm chart depends. + $(HELM) repo add kubedoop https://zncdatadev.github.io/kubedoop-helm-charts/ +ifneq ($(strip $(HELM_DEPENDS)),) + for dep in $(HELM_DEPENDS); do \ + $(HELM) upgrade --install --create-namespace --namespace $(TEST_NAMESPACE) --wait $$dep kubedoop/$$dep --version $(VERSION); \ + done +endif + +.PHONY: helm-install +helm-install: helm-install-depends ## Install the helm chart. + $(HELM) upgrade --install --create-namespace --namespace $(TEST_NAMESPACE) --wait $(PROJECT_NAME) kubedoop/$(PROJECT_NAME) --version $(VERSION) + +.PHONY: helm-uninstall +helm-uninstall: ## Uninstall the helm chart. + $(HELM) uninstall --namespace $(TEST_NAMESPACE) $(PROJECT_NAME) + # kind KIND_VERSION ?= v0.23.0 @@ -364,18 +405,10 @@ endif OLM_VERSION ?= v0.28.0 KIND_CONFIG ?= test/e2e/kind-config.yaml -# Create a kind cluster, install ingress-nginx, and wait for it to be available. +# Create a kind cluster .PHONY: kind-create kind-create: kind ## Create a kind cluster. $(KIND) create cluster --config $(KIND_CONFIG) --image $(KIND_IMAGE) --name $(KIND_CLUSTER_NAME) --kubeconfig $(KIND_KUBECONFIG) --wait 120s - KUBECONFIG=$(KIND_KUBECONFIG) make kind-setup - -.PHONY: kind-setup -kind-setup: kind ## setup kind cluster base environment - @echo "Setup kind cluster base environment, install ingress-nginx and OLM" - kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml - kubectl -n ingress-nginx wait deployment ingress-nginx-controller --for=condition=available --timeout=300s - curl -sSL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/$(OLM_VERSION)/install.sh | bash -s $(OLM_VERSION) .PHONY: kind-delete kind-delete: kind ## Delete a kind cluster. @@ -386,9 +419,9 @@ kind-delete: kind ## Delete a kind cluster. CHAINSAW_VERSION ?= v0.2.8 CHAINSAW ?= $(LOCALBIN)/chainsaw -# Use `grep 0.2.6 > /dev/null` instead of `grep -q 0.2.6`. It will not be able to determine the version number, +# Use `grep 0.2.6 > /dev/null` instead of `grep -q 0.2.6`. It will not be able to determine the version number, # although the execution in the shell is normal, but in the makefile does fail to understand the mechanism in the makefile -# The operation ends by using `touch` to change the time of the file so that its timestamp is further back than the directory, +# The operation ends by using `touch` to change the time of the file so that its timestamp is further back than the directory, # so that no subsequent logic is performed after the `chainsaw` check is successful in relying on the `$(CHAINSAW)` target. .PHONY: chainsaw chainsaw: $(CHAINSAW) ## Download chainsaw locally if necessary. @@ -412,16 +445,15 @@ $(CHAINSAW): $(LOCALBIN) } .PHONY: chainsaw-setup -chainsaw-setup: manifests kustomize ## Run the chainsaw setup - @echo "\nSetup chainsaw test environment" +chainsaw-setup: ## Run the chainsaw setup make docker-build $(KIND) --name $(KIND_CLUSTER_NAME) load docker-image $(IMG) - KUBECONFIG=$(KIND_KUBECONFIG) make deploy + KUBECONFIG=$(KIND_KUBECONFIG) make helm-install .PHONY: chainsaw-test chainsaw-test: chainsaw ## Run the chainsaw test 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 - KUBECONFIG=$(KIND_KUBECONFIG) make undeploy +chainsaw-cleanup: ## Run the chainsaw cleanup + KUBECONFIG=$(KIND_KUBECONFIG) make helm-uninstall diff --git a/test/e2e/default/chainsaw-test.yaml b/test/e2e/default/chainsaw-test.yaml index 44d9c80..294d850 100644 --- a/test/e2e/default/chainsaw-test.yaml +++ b/test/e2e/default/chainsaw-test.yaml @@ -4,24 +4,6 @@ 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/listener.yaml - - assert: - file: ../setup/listener-assert.yaml - - apply: - file: ../setup/secret.yaml - - assert: - file: ../setup/secret-assert.yaml - try: - apply: file: ../setup/zookeeper.yaml diff --git a/test/e2e/kerberos/chainsaw-test.yaml b/test/e2e/kerberos/chainsaw-test.yaml index 38a6f34..00ec6b9 100644 --- a/test/e2e/kerberos/chainsaw-test.yaml +++ b/test/e2e/kerberos/chainsaw-test.yaml @@ -11,29 +11,10 @@ spec: - name: kadminKeytabSecret value: kadmin-keytab steps: - - try: - - apply: # deploy operator - file: ../setup/olm.yaml - - assert: - file: ../setup/olm-assert.yaml - - try: - - apply: - file: ../setup/subs.yaml - - assert: - file: ../setup/subs-assert.yaml - - try: # deploy listener and seret - - apply: - file: ../setup/listener.yaml - - assert: - file: ../setup/listener-assert.yaml - - apply: - file: ../setup/secret.yaml - - assert: - file: ../setup/secret-assert.yaml - try: # deploy kerberos - apply: # create a krb5 deployment and service, both named "krb5" file: ../setup/krb5.yaml - - assert: + - assert: file: ../setup/krb5-assert.yaml - try: # deploy krb5 SecretClass - script: @@ -57,7 +38,7 @@ spec: echo "pod not found" exit 1 fi - + # get kadmin keytab KADMIN_KEYTAB=$(kubectl exec -n $NAMESPACE $POD_NAME -- sh -c "cat /var/kerberos/krb5kdc/kadmin.keytab | base64 -w 0") diff --git a/test/e2e/oidc/chainsaw-test.yaml b/test/e2e/oidc/chainsaw-test.yaml index 073c495..0310137 100644 --- a/test/e2e/oidc/chainsaw-test.yaml +++ b/test/e2e/oidc/chainsaw-test.yaml @@ -15,20 +15,6 @@ spec: - name: KEYCLOAK_PASSWORD value: password 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/listener.yaml - - assert: - file: ../setup/listener-assert.yaml - try: - apply: file: ../setup/zookeeper.yaml diff --git a/test/e2e/setup/listener-assert.yaml b/test/e2e/setup/listener-assert.yaml deleted file mode 100644 index 1cd948a..0000000 --- a/test/e2e/setup/listener-assert.yaml +++ /dev/null @@ -1,44 +0,0 @@ -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: listenercsi-csi -status: - numberAvailable: 1 - numberMisscheduled: 0 - numberReady: 1 ---- -apiVersion: listeners.zncdata.dev/v1alpha1 -kind: ListenerClass -metadata: - labels: - app.kubernetes.io/created-by: listener-operator - name: cluster-internal -spec: - serviceAnnotations: - app.kubernetes.io/created-by: listener-operator - app.kubernetes.io/managed-by: csi-driver-listenercsi - serviceType: ClusterIP ---- -apiVersion: listeners.zncdata.dev/v1alpha1 -kind: ListenerClass -metadata: - labels: - app.kubernetes.io/created-by: listener-operator - name: external-unstable -spec: - serviceAnnotations: - app.kubernetes.io/created-by: listener-operator - app.kubernetes.io/managed-by: csi-driver-listenercsi - serviceType: NodePort ---- -apiVersion: listeners.zncdata.dev/v1alpha1 -kind: ListenerClass -metadata: - labels: - app.kubernetes.io/created-by: listener-operator - name: external-stable -spec: - serviceAnnotations: - app.kubernetes.io/created-by: listener-operator - app.kubernetes.io/managed-by: csi-driver-listenercsi - serviceType: NodePort diff --git a/test/e2e/setup/listener.yaml b/test/e2e/setup/listener.yaml deleted file mode 100644 index 384c639..0000000 --- a/test/e2e/setup/listener.yaml +++ /dev/null @@ -1,35 +0,0 @@ -apiVersion: listeners.zncdata.dev/v1alpha1 -kind: ListenerCSI -metadata: - labels: - app.kubernetes.io/name: listenercsi - app.kubernetes.io/instance: listenercsi - app.kubernetes.io/part-of: listener-operator - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: listener-operator - name: listenercsi -spec: - csiDriver: - repository: quay.io/zncdatadev/listener-csi-driver - tag: 0.0.0-dev - pullPolicy: IfNotPresent - logging: - level: "10" - nodeDriverRegistrar: - repository: registry.k8s.io/sig-storage/csi-node-driver-registrar - tag: v2.8.0 - pullPolicy: IfNotPresent - logging: - level: "10" - csiProvisioner: - repository: registry.k8s.io/sig-storage/csi-provisioner - tag: v3.5.0 - pullPolicy: IfNotPresent - logging: - level: "10" - livenessProbe: - repository: registry.k8s.io/sig-storage/livenessprobe - tag: v2.11.0 - pullPolicy: IfNotPresent - logging: - level: "10" diff --git a/test/e2e/setup/olm-assert.yaml b/test/e2e/setup/olm-assert.yaml deleted file mode 100644 index 0beb08c..0000000 --- a/test/e2e/setup/olm-assert.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -apiVersion: operators.coreos.com/v1 -kind: OperatorGroup -metadata: - name: kubedoop ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: CatalogSource -metadata: - name: kubedoop-catalog -status: - connectionState: - lastObservedState: READY diff --git a/test/e2e/setup/olm.yaml b/test/e2e/setup/olm.yaml deleted file mode 100644 index e854c9d..0000000 --- a/test/e2e/setup/olm.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: operators.coreos.com/v1 -kind: OperatorGroup -metadata: - name: kubedoop -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: - - ($namespace) ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: CatalogSource -metadata: - name: kubedoop-catalog -spec: - sourceType: grpc - image: quay.io/zncdatadev/kubedoop-catalog:latest - displayName: kubedoop-catalog - publisher: zncdatadev - updateStrategy: - registryPoll: - interval: 20m diff --git a/test/e2e/setup/secret-assert.yaml b/test/e2e/setup/secret-assert.yaml deleted file mode 100644 index 0e20cd7..0000000 --- a/test/e2e/setup/secret-assert.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: apps/v1 -kind: DaemonSet -metadata: - name: secretcsi-csi -status: - numberAvailable: 1 - numberMisscheduled: 0 - numberReady: 1 ---- -apiVersion: secrets.zncdata.dev/v1alpha1 -kind: SecretClass -metadata: - name: tls diff --git a/test/e2e/setup/secret.yaml b/test/e2e/setup/secret.yaml deleted file mode 100644 index 8c768c5..0000000 --- a/test/e2e/setup/secret.yaml +++ /dev/null @@ -1,50 +0,0 @@ -apiVersion: secrets.zncdata.dev/v1alpha1 -kind: SecretCSI -metadata: - labels: - app.kubernetes.io/name: secretcsi - app.kubernetes.io/instance: simple-secretcsi - app.kubernetes.io/part-of: secret-operator - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: secret-operator - name: secretcsi -spec: - csiDriver: - repository: quay.io/zncdatadev/secret-csi-driver - tag: 0.0.0-dev - pullPolicy: IfNotPresent - logging: - level: "10" - nodeDriverRegistrar: - repository: registry.k8s.io/sig-storage/csi-node-driver-registrar - tag: v2.8.0 - pullPolicy: IfNotPresent - logging: - level: "10" - csiProvisioner: - repository: registry.k8s.io/sig-storage/csi-provisioner - tag: v3.5.0 - pullPolicy: IfNotPresent - logging: - level: "10" - livenessProbe: - repository: registry.k8s.io/sig-storage/livenessprobe - tag: v2.11.0 - pullPolicy: IfNotPresent - logging: - level: "10" ---- -apiVersion: secrets.zncdata.dev/v1alpha1 -kind: SecretClass -metadata: - name: tls -spec: - backend: - autoTls: - ca: - autoGenerated: true - caCertificateLifeTime: 730h - secret: - name: tls-ca - namespace: ($namespace) - maxCertificateLifeTime: 360h diff --git a/test/e2e/setup/subs-assert.yaml b/test/e2e/setup/subs-assert.yaml deleted file mode 100644 index 17ca56e..0000000 --- a/test/e2e/setup/subs-assert.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: zookeeper-operator-controller-manager -status: - availableReplicas: 1 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: listener-operator-controller-manager -status: - availableReplicas: 1 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: hdfs-operator-controller-manager -status: - availableReplicas: 1 diff --git a/test/e2e/setup/subs.yaml b/test/e2e/setup/subs.yaml deleted file mode 100644 index 79ee87a..0000000 --- a/test/e2e/setup/subs.yaml +++ /dev/null @@ -1,55 +0,0 @@ ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: Subscription -metadata: - name: commons-sub -spec: - channel: stable - name: commons-operator - source: kubedoop-catalog - sourceNamespace: ($namespace) - installPlanApproval: Automated ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: Subscription -metadata: - name: listener-sub -spec: - channel: stable - name: listener-operator - source: kubedoop-catalog - sourceNamespace: ($namespace) - installPlanApproval: Automated ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: Subscription -metadata: - name: secret-sub -spec: - channel: stable - name: secret-operator - source: kubedoop-catalog - sourceNamespace: ($namespace) - installPlanApproval: Automated ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: Subscription -metadata: - name: zookeeper-sub -spec: - channel: stable - name: zookeeper-operator - source: kubedoop-catalog - sourceNamespace: ($namespace) - installPlanApproval: Automated ---- -apiVersion: operators.coreos.com/v1alpha1 -kind: Subscription -metadata: - name: hdfs-sub -spec: - channel: stable - name: hdfs-operator - source: kubedoop-catalog - sourceNamespace: ($namespace) - installPlanApproval: Automated