diff --git a/Makefile b/Makefile index b25524d..2a8f2ea 100644 --- a/Makefile +++ b/Makefile @@ -86,14 +86,26 @@ cobertura: grep -v zz_generated.deepcopy | \ $(GOCOVER_COBERTURA) > $(GO_TEST_OUTPUT)/cobertura-coverage.xml -# integration tests -e2e.run: test-integration - -# Run integration tests. -test-integration: $(KIND) $(KUBECTL) $(UP) $(HELM3) - @$(INFO) running integration tests using kind $(KIND_VERSION) - @KIND_NODE_IMAGE_TAG=${KIND_NODE_IMAGE_TAG} $(ROOT_DIR)/cluster/integration/integration_tests.sh || $(FAIL) - @$(OK) integration tests passed +# ==================================================================================== +# End to End Testing +CROSSPLANE_NAMESPACE = crossplane-system +-include build/makelib/local.xpkg.mk +-include build/makelib/controlplane.mk + +UPTEST_EXAMPLE_LIST ?= "examples/sample/release.yaml" +uptest: $(UPTEST) $(KUBECTL) $(KUTTL) + @$(INFO) running automated tests + @KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL) + @$(OK) running automated tests + +local-dev: controlplane.up +local-deploy: build controlplane.up local.xpkg.deploy.provider.$(PROJECT_NAME) + @$(INFO) running locally built provider + @$(KUBECTL) wait provider.pkg $(PROJECT_NAME) --for condition=Healthy --timeout 5m + @$(KUBECTL) -n crossplane-system wait --for=condition=Available deployment --all --timeout=5m + @$(OK) running locally built provider + +e2e: local-deploy uptest # Update the submodules, such as the common build scripts. submodules: diff --git a/build b/build index 7233e36..75a9fe3 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 7233e36491dc8298d33f1feb1bf8c5056a960cac +Subproject commit 75a9fe3ae6b6de82c5f7ddc6a267617940f16b83 diff --git a/cluster/integration/integration_tests.sh b/cluster/integration/integration_tests.sh deleted file mode 100755 index 523ff62..0000000 --- a/cluster/integration/integration_tests.sh +++ /dev/null @@ -1,213 +0,0 @@ -#!/usr/bin/env bash -set -e - -# setting up colors -BLU='\033[0;34m' -YLW='\033[0;33m' -GRN='\033[0;32m' -RED='\033[0;31m' -NOC='\033[0m' # No Color -echo_info(){ - printf "\n${BLU}%s${NOC}" "$1" -} -echo_step(){ - printf "\n${BLU}>>>>>>> %s${NOC}\n" "$1" -} -echo_sub_step(){ - printf "\n${BLU}>>> %s${NOC}\n" "$1" -} - -echo_step_completed(){ - printf "${GRN} [✔]${NOC}" -} - -echo_success(){ - printf "\n${GRN}%s${NOC}\n" "$1" -} -echo_warn(){ - printf "\n${YLW}%s${NOC}" "$1" -} -echo_error(){ - printf "\n${RED}%s${NOC}" "$1" - exit 1 -} - -# ------------------------------ -projectdir="$( cd "$( dirname "${BASH_SOURCE[0]}")"/../.. && pwd )" - -# get the build environment variables from the special build.vars target in the main makefile -eval $(make --no-print-directory -C ${projectdir} build.vars) - -# ------------------------------ - -SAFEHOSTARCH="${SAFEHOSTARCH:-amd64}" -CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}" - -version_tag="$(cat ${projectdir}/_output/version)" -K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}" - -CROSSPLANE_NAMESPACE="crossplane-system" -PACKAGE_NAME="provider-helm" - -# cleanup on exit -if [ "$skipcleanup" != true ]; then - function cleanup { - echo_step "Cleaning up..." - export KUBECONFIG= - "${KIND}" delete cluster --name="${K8S_CLUSTER}" - } - - trap cleanup EXIT -fi - -# setup package cache -echo_step "setting up local package cache" -CACHE_PATH="${projectdir}/.work/inttest-package-cache" -mkdir -p "${CACHE_PATH}" -echo "created cache dir at ${CACHE_PATH}" -"${UP}" alpha xpkg xp-extract --from-xpkg "${OUTPUT_DIR}"/xpkg/"${HOSTOS}"_"${SAFEHOSTARCH}"/"${PACKAGE_NAME}"-"${VERSION}".xpkg -o "${CACHE_PATH}/${PACKAGE_NAME}.gz" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.gz" - -# create kind cluster with extra mounts -KIND_NODE_IMAGE="kindest/node:${KIND_NODE_IMAGE_TAG}" -echo_step "creating k8s cluster using kind ${KIND_VERSION} and node image ${KIND_NODE_IMAGE}" -KIND_CONFIG="$( cat < $current ]]; then - echo_error "timeout of ${timeout}s has been reached" - fi - sleep $step; -done - -echo_success "Integration tests succeeded!" diff --git a/cluster/local/config/config.env b/cluster/local/config/config.env deleted file mode 100644 index c3c3e93..0000000 --- a/cluster/local/config/config.env +++ /dev/null @@ -1 +0,0 @@ -CROSSPLANE_VERSION="1.3.0" diff --git a/cluster/local/config/crossplane/.gitignore b/cluster/local/config/crossplane/.gitignore deleted file mode 100644 index e29f121..0000000 --- a/cluster/local/config/crossplane/.gitignore +++ /dev/null @@ -1 +0,0 @@ -value-overrides.yaml diff --git a/cluster/local/config/crossplane/config.env b/cluster/local/config/crossplane/config.env deleted file mode 100644 index 7c4275e..0000000 --- a/cluster/local/config/crossplane/config.env +++ /dev/null @@ -1,8 +0,0 @@ -REQUIRED_IMAGES+=("crossplane/crossplane:v${CROSSPLANE_VERSION}") - -HELM_REPOSITORY_NAME=crossplane-stable -HELM_REPOSITORY_URL=https://charts.crossplane.io/stable -HELM_CHART_VERSION="${CROSSPLANE_VERSION}" -HELM_RELEASE_NAME=crossplane -HELM_RELEASE_NAMESPACE=crossplane-system -HELM_REPOSITORY_FORCE_UPDATE=true \ No newline at end of file diff --git a/cluster/local/config/crossplane/value-overrides.yaml.tmpl b/cluster/local/config/crossplane/value-overrides.yaml.tmpl deleted file mode 100644 index 50c6f54..0000000 --- a/cluster/local/config/crossplane/value-overrides.yaml.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -image: - pullPolicy: Never - diff --git a/cluster/local/kind.yaml b/cluster/local/kind.yaml deleted file mode 100644 index e7992c7..0000000 --- a/cluster/local/kind.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -nodes: - - role: control-plane - image: kindest/node:v1.23.6 \ No newline at end of file diff --git a/cluster/test/setup.sh b/cluster/test/setup.sh new file mode 100755 index 0000000..affa41b --- /dev/null +++ b/cluster/test/setup.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -aeuo pipefail + +echo "Running setup.sh" + +echo "Creating the provider config with cluster admin permissions in cluster..." +SA=$(${KUBECTL} -n crossplane-system get sa -o name | grep provider-helm | sed -e 's|serviceaccount\/|crossplane-system:|g') +${KUBECTL} create clusterrolebinding provider-helm-admin-binding --clusterrole cluster-admin --serviceaccount="${SA}" --dry-run=client -o yaml | ${KUBECTL} apply -f - + +cat <