From 0b54b7f4ddd3afb50d6fadcd8b107c3e96162bda Mon Sep 17 00:00:00 2001 From: Varsha Prasad Narsing Date: Mon, 3 Jun 2024 11:51:43 -0700 Subject: [PATCH] debugging tests --- Makefile | 9 ++- .../build-push-e2e-bundle.sh | 76 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100755 testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh diff --git a/Makefile b/Makefile index 2c4475ebf..38f53bc72 100644 --- a/Makefile +++ b/Makefile @@ -122,6 +122,8 @@ e2e: #EXHELP Run the e2e tests. E2E_REGISTRY_NAME := docker-registry E2E_REGISTRY_NAMESPACE := operator-controller-e2e +DNS_NAME := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc.cluster.local + export REG_PKG_NAME := registry-operator export CATALOG_IMG := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000/test-catalog:e2e .PHONY: test-ext-dev-e2e @@ -150,7 +152,7 @@ build-push-e2e-catalog: ## Build the testdata catalog used for e2e tests and pus test-e2e: KIND_CLUSTER_NAME := operator-controller-e2e test-e2e: KUSTOMIZE_BUILD_DIR := config/e2e test-e2e: GO_BUILD_FLAGS := -cover -test-e2e: run image-registry build-push-e2e-catalog kind-load-test-artifacts e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster +test-e2e: run image-registry build-push-e2e-catalog kind-load-test-artifacts registry-load-bundles e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster .PHONY: extension-developer-e2e extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster @@ -199,6 +201,11 @@ kind-load-test-artifacts: $(KIND) #EXHELP Load the e2e testdata container images $(CONTAINER_RUNTIME) build testdata/bundles/registry-v1/package-with-webhooks.v1.0.0 -t localhost/testdata/bundles/registry-v1/package-with-webhooks:v1.0.0 $(KIND) load docker-image localhost/testdata/bundles/registry-v1/package-with-webhooks:v1.0.0 --name $(KIND_CLUSTER_NAME) +registry-load-bundles: ## Load selected e2e testdata container images created in kind-load-bundles into registry + testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-operator:v1.0.0 + testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-operator:v1.0.1 + testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-operator:v1.2.0 + testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-operator:v2.0.0 #SECTION Build diff --git a/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh new file mode 100755 index 000000000..a8d4751fb --- /dev/null +++ b/testdata/bundles/registry-v1/prometheus-operator.v1.0.0/build-push-e2e-bundle.sh @@ -0,0 +1,76 @@ +#! /bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +help=" +build-push-e2e-bundle.sh is a script to build and push the e2e bundle image using kaniko. +Usage: + build-push-e2e-bundle.sh [NAMESPACE] [TAG] [BUNDLE_DIR] [BUNDLE_NAME] + +Argument Descriptions: + - NAMESPACE is the namespace the kaniko Job should be created in + - TAG is the full tag used to build and push the catalog image +" + +if [[ "$#" -ne 2 ]]; then + echo "Illegal number of arguments passed" + echo "${help}" + exit 1 +fi + + +namespace=$1 +tag=$2 +bundle_dir="testdata/bundles/registry-v1/prometheus-operator.v1.0.0" +bundle_name="prometheus-operator.v1.0.0" + +echo "${namespace}" "${tag}" + +kubectl create configmap -n "${namespace}" --from-file="${bundle_dir}/" operator-controller-e2e-${bundle_name}.root +kubectl create configmap -n "${namespace}" --from-file="${bundle_dir}/manifests" operator-controller-${bundle_name}.manifests + +kubectl apply -f - << EOF +apiVersion: batch/v1 +kind: Job +metadata: + name: "kaniko-${bundle_name}" + namespace: "${namespace}" +spec: + template: + spec: + initContainers: + - name: copy-manifests + image: busybox + command: ['sh', '-c', 'cp /manifests-data/* /manifests'] + volumeMounts: + - name: manifests + mountPath: /manifests + - name: manifests-data + mountPath: /manifests-data + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:latest + args: ["--dockerfile=/workspace/Dockerfile", + "--context=/workspace/", + "--destination=${tag}", + "--skip-tls-verify"] + volumeMounts: + - name: dockerfile + mountPath: /workspace/ + - name: manifests + mountPath: /workspace/manifests/ + restartPolicy: Never + volumes: + - name: dockerfile + configMap: + name: operator-controller-e2e-${bundle_name}.root + - name: manifests + emptyDir: {} + - name: manifests-data + configMap: + name: operator-controller-${bundle_name}.manifests +EOF + +kubectl wait --for=condition=Complete -n "${namespace}" jobs/kaniko-${bundle_name} --timeout=60s