From e78ee51ebe8f6c01cba4bd8d3137c5358ffb67c0 Mon Sep 17 00:00:00 2001 From: Todd Short Date: Fri, 7 Jun 2024 14:22:20 -0400 Subject: [PATCH] ext-dev-e2e passes Signed-off-by: Todd Short --- Makefile | 1 + test/extension-developer-e2e/setup.sh | 64 +++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e32f6cb7..89588a0d 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,7 @@ DNS_NAME := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc.cluster export REG_PKG_NAME := registry-operator export CATALOG_IMG := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000/test-catalog:e2e +export REGISTRY_ROOT := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000 .PHONY: test-ext-dev-e2e test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension create, upgrade and delete tests. test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) $(KIND) $(KIND_CLUSTER_NAME) $(E2E_REGISTRY_NAMESPACE) diff --git a/test/extension-developer-e2e/setup.sh b/test/extension-developer-e2e/setup.sh index 77677045..ab8e48e7 100755 --- a/test/extension-developer-e2e/setup.sh +++ b/test/extension-developer-e2e/setup.sh @@ -13,6 +13,7 @@ a KinD cluster with the name specified in the arguments. The following environment variables are required for configuring this script: - \$CATALOG_IMG - the tag for the catalog image that contains the registry+v1 bundle. - \$REG_PKG_NAME - the name of the package for the extension that uses the registry+v1 bundle format. +- \$REGISTRY_ROOT - hostname:port of the local docker-registry setup.sh also takes 5 arguments. Usage: @@ -41,6 +42,12 @@ if [[ -z "${REG_PKG_NAME}" ]]; then exit 1 fi +if [[ -z "${REGISTRY_ROOT}" ]]; then + echo "\$REGISTRY_ROOT is required to be set" + echo "${help}" + exit 1 +fi + ######################################## # Setup temp dir and local variables ######################################## @@ -62,7 +69,7 @@ kcluster_name=$5 namespace=$6 reg_img="${DOMAIN}/registry:v0.0.1" -reg_bundle_img="${DOMAIN}/registry-bundle:v0.0.1" +reg_bundle_img="${REGISTRY_ROOT}/bundles/registry-v1/registry-bundle:v0.0.1" catalog_img="${CATALOG_IMG}" reg_pkg_name="${REG_PKG_NAME}" @@ -98,9 +105,6 @@ reg_pkg_name="${REG_PKG_NAME}" make bundle-build BUNDLE_IMG="${reg_bundle_img}" ) -$kind load docker-image "${reg_img}" --name "${kcluster_name}" -$kind load docker-image "${reg_bundle_img}" --name "${kcluster_name}" - ############################### # Create the FBC that contains # the registry+v1 extensions @@ -197,3 +201,55 @@ kubectl wait --for=condition=Complete -n "${namespace}" jobs/kaniko --timeout=60 # don't have write permissions so they can't be removed unless # we ensure they have the write permissions chmod -R +w "${REG_DIR}/bin" + +# Load the bundle image into the docker-registry + +kubectl create configmap -n "${namespace}" --from-file="${REG_DIR}/bundle.Dockerfile" operator-controller-e2e-${reg_pkg_name}.root + +tgz="${REG_DIR}/manifests.tgz" +tar czf "${tgz}" -C "${REG_DIR}" bundle +kubectl create configmap -n "${namespace}" --from-file="${tgz}" operator-controller-${reg_pkg_name}.manifests + +kubectl apply -f - << EOF +apiVersion: batch/v1 +kind: Job +metadata: + name: "kaniko-${reg_pkg_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/bundle.Dockerfile", + "--context=tar:///workspace/manifests/manifests.tgz", + "--destination=${reg_bundle_img}", + "--skip-tls-verify"] + volumeMounts: + - name: dockerfile + mountPath: /workspace/ + - name: manifests + mountPath: /workspace/manifests/ + restartPolicy: Never + volumes: + - name: dockerfile + configMap: + name: operator-controller-e2e-${reg_pkg_name}.root + - name: manifests + emptyDir: {} + - name: manifests-data + configMap: + name: operator-controller-${reg_pkg_name}.manifests +EOF + +kubectl wait --for=condition=Complete -n "${namespace}" jobs/kaniko-${reg_pkg_name} --timeout=60s