diff --git a/Makefile b/Makefile index 3d9ad56..fb77938 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,8 @@ GO111MODULE = on # ==================================================================================== # Setup Kubernetes tools -KIND_VERSION = v0.7.0 +KIND_VERSION ?= v0.11.1 +KIND_NODE_IMAGE_TAG ?= v1.19.11 USE_HELM3 = true -include build/makelib/k8s_tools.mk @@ -81,7 +82,7 @@ e2e.run: test-integration # Run integration tests. test-integration: $(KIND) $(KUBECTL) $(HELM3) @$(INFO) running integration tests using kind $(KIND_VERSION) - @$(ROOT_DIR)/cluster/integration/integration_tests.sh || $(FAIL) + @KIND_NODE_IMAGE_TAG=${KIND_NODE_IMAGE_TAG} $(ROOT_DIR)/cluster/integration/integration_tests.sh || $(FAIL) @$(OK) integration tests passed # Update the submodules, such as the common build scripts. diff --git a/build b/build index a6cd5ea..b9e5c80 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit a6cd5ea19f2b85e724656eb0f1e6a2f810069c1a +Subproject commit b9e5c80250983700f027b27505046f53f3d219f6 diff --git a/cluster/integration/integration_tests.sh b/cluster/integration/integration_tests.sh index 603e0b2..2613d35 100755 --- a/cluster/integration/integration_tests.sh +++ b/cluster/integration/integration_tests.sh @@ -32,103 +32,6 @@ echo_error(){ exit 1 } -# k8s watchers - -wait_for_pods_in_namespace(){ - local timeout=$1 - shift - namespace=$1 - shift - arr=("$@") - local counter=0 - for i in "${arr[@]}"; - do - echo -n "waiting for pod $i in namespace $namespace..." >&2 - while ! ("${KUBECTL}" -n $namespace get pod $i) &>/dev/null; do - if [ "$counter" -ge "$timeout" ]; then echo "TIMEOUT"; exit -1; else (( counter+=5 )); fi - echo -n "." >&2 - sleep 5 - done - echo "FOUND POD!" >&2 - done -} - -check_deployments(){ - for name in $1; do - echo_sub_step "inspecting deployment '${name}'" - local dep_stat=$("${KUBECTL}" -n "$2" get deployments/"${name}") - - echo_info "check if is deployed" - if $(echo "$dep_stat" | grep -iq 'No resources found'); then - echo "is not deployed" - exit -1 - else - echo_step_completed - fi - - echo_info "check if is ready" - IFS='/' read -ra ready_status_parts <<< "$(echo "$dep_stat" | awk ' FNR > 1 {print $2}')" - if (("${ready_status_parts[0]}" < "${ready_status_parts[1]}")); then - echo "is not Ready" - exit -1 - else - echo_step_completed - fi - echo - done -} - -check_pods(){ - pods=$("${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" get pods) - count=$(echo "$pods" | wc -l) - if (("${count}"-1 != "${1}")); then - sleep 10 - "${KUBECTL}" get events -A - sleep 20 - echo_error "unexpected number of pods" - exit -1 - fi - echo "$pods" - while read -r pod_stat; do - name=$(echo "$pod_stat" | awk '{print $1}') - echo_sub_step "inspecting pod '${name}'" - - if $(echo "$pod_stat" | awk '{print $3}' | grep -ivq 'Completed'); then - echo_info "is not completed, continuing with further checks" - else - echo_info "is completed, foregoing further checks" - echo_step_completed - continue - fi - - echo_info "check if is ready" - IFS='/' read -ra ready_status_parts <<< "$(echo "$pod_stat" | awk '{print $2}')" - if (("${ready_status_parts[0]}" < "${ready_status_parts[1]}")); then - echo_error "is not ready" - exit -1 - else - echo_step_completed - fi - - echo_info "check if is running" - if $(echo "$pod_stat" | awk '{print $3}' | grep -ivq 'Running'); then - echo_error "is not running" - exit -1 - else - echo_step_completed - fi - - echo_info "check if has restarts" - if (( $(echo "$pod_stat" | awk '{print $4}') > 0 )); then - echo_error "has restarts" - exit -1 - else - echo_step_completed - fi - echo - done <<< "$(echo "$pods" | awk 'FNR>1')" -} - # ------------------------------ projectdir="$( cd "$( dirname "${BASH_SOURCE[0]}")"/../.. && pwd )" @@ -144,7 +47,7 @@ CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-controller-${SAFEHOSTARCH}" version_tag="$(cat ${projectdir}/_output/version)" # tag as latest version to load into kind cluster PACKAGE_CONTROLLER_IMAGE="${DOCKER_REGISTRY}/${PROJECT_NAME}-controller:${VERSION}" -K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-INTTESTS}" +K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}" CROSSPLANE_NAMESPACE="crossplane-system" PACKAGE_NAME="provider-helm" @@ -168,7 +71,8 @@ echo "created cache dir at ${CACHE_PATH}" docker save "${BUILD_IMAGE}" -o "${CACHE_PATH}/${PACKAGE_NAME}.xpkg" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.xpkg" # create kind cluster with extra mounts -echo_step "creating k8s cluster using kind" +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!"