Skip to content

Commit

Permalink
debugging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
varshaprasad96 committed Jun 3, 2024
1 parent 5fd302f commit 0b54b7f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0b54b7f

Please sign in to comment.