Skip to content

Commit

Permalink
refactor(e2e): migrate e2e test from olm to helm (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwpk110 authored Oct 28, 2024
1 parent a511f5e commit b8f9381
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 321 deletions.
64 changes: 48 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
18 changes: 0 additions & 18 deletions test/e2e/default/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 2 additions & 21 deletions test/e2e/kerberos/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down
14 changes: 0 additions & 14 deletions test/e2e/oidc/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 0 additions & 44 deletions test/e2e/setup/listener-assert.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions test/e2e/setup/listener.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions test/e2e/setup/olm-assert.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions test/e2e/setup/olm.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions test/e2e/setup/secret-assert.yaml

This file was deleted.

50 changes: 0 additions & 50 deletions test/e2e/setup/secret.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions test/e2e/setup/subs-assert.yaml

This file was deleted.

Loading

0 comments on commit b8f9381

Please sign in to comment.