From 30d734021763f45f839a4a7051da006acd0d9582 Mon Sep 17 00:00:00 2001 From: Mateusz Szostok Date: Wed, 25 Sep 2019 10:33:48 +0200 Subject: [PATCH] Update the run-migration-tests.sh script --- contrib/hack/ci/lib/deps_ver.sh | 3 +- contrib/hack/ci/lib/utilities.sh | 68 +++++++++++++++++++++++--- contrib/hack/ci/run-e2e-tests.sh | 1 + contrib/hack/ci/run-migration-tests.sh | 15 ++++-- 4 files changed, 77 insertions(+), 10 deletions(-) diff --git a/contrib/hack/ci/lib/deps_ver.sh b/contrib/hack/ci/lib/deps_ver.sh index 3b48e4b450c..15d26972537 100644 --- a/contrib/hack/ci/lib/deps_ver.sh +++ b/contrib/hack/ci/lib/deps_ver.sh @@ -14,5 +14,6 @@ # Upgrade binary versions in a controlled fashion # along with the script contents (config, flags...) -readonly STABLE_KIND_VERSION=v0.4.0 +readonly STABLE_KUBERNETES_VERSION=v1.15.3 +readonly STABLE_KIND_VERSION=v0.5.1 readonly STABLE_HELM_VERSION=v2.14.3 diff --git a/contrib/hack/ci/lib/utilities.sh b/contrib/hack/ci/lib/utilities.sh index 52427cd33f1..e87a1127115 100644 --- a/contrib/hack/ci/lib/utilities.sh +++ b/contrib/hack/ci/lib/utilities.sh @@ -28,7 +28,8 @@ shout() { " } -# Installs kind and helm dependencies locally. + +# Installs kind dependency locally. # Required envs: # - KIND_VERSION # - INSTALL_DIR @@ -40,12 +41,68 @@ install::local::kind() { pushd "${INSTALL_DIR}" - shout "- Install kind ${KIND_VERSION} locally to a tempdir GOPATH..." - env "GOPATH=${INSTALL_DIR}" GO111MODULE="on" go get "sigs.k8s.io/kind@${KIND_VERSION}" + os=$(host::os) + arch=$(host::arch) + + shout "- Install kind ${KIND_VERSION} locally to a tempdir..." + + curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-${os}-${arch}" + chmod +x kind + mv kind "${INSTALL_DIR}/bin" popd } +host::os() { + local host_os + case "$(uname -s)" in + Darwin) + host_os=darwin + ;; + Linux) + host_os=linux + ;; + *) + kube::log::error "Unsupported host OS. Must be Linux or Mac OS X." + exit 1 + ;; + esac + echo "${host_os}" +} + +host::arch() { + local host_arch + case "$(uname -m)" in + x86_64*) + host_arch=amd64 + ;; + i?86_64*) + host_arch=amd64 + ;; + amd64*) + host_arch=amd64 + ;; + aarch64*) + host_arch=arm64 + ;; + arm64*) + host_arch=arm64 + ;; + arm*) + host_arch=arm + ;; + ppc64le*) + host_arch=ppc64le + ;; + *) + kube::log::error "Unsupported host arch. Must be x86_64, arm, arm64, or ppc64le." + exit 1 + ;; + esac + echo "${host_arch}" +} + + # Installs kind and helm dependencies locally. # Required envs: # - HELM_VERSION @@ -82,9 +139,8 @@ install::cluster::tiller() { install::cluster::service_catalog_v2() { shout "- Installing Service Catalog in version 0.2.x" helm repo add svc-cat https://svc-catalog-charts.storage.googleapis.com - # TODO: After https://github.com/kyma-project/kyma/issues/5217, change `helm install svc-cat/catalog` to `helm install svc-cat/catalog-apiserver` # install always the newest service catalog with apiserver - helm install svc-cat/catalog --name ${SC_CHART_NAME} --namespace ${SC_NAMESPACE} --wait + helm install svc-cat/catalog-v0.2 --name ${SC_CHART_NAME} --namespace ${SC_NAMESPACE} --wait } # @@ -94,7 +150,7 @@ readonly KIND_CLUSTER_NAME="kind-ci" kind::create_cluster() { shout "- Create k8s cluster..." - kind create cluster --name=${KIND_CLUSTER_NAME} --wait=5m + kind create cluster --name=${KIND_CLUSTER_NAME} --image=kindest/node:${KUBERNETES_VERSION} --wait=5m export KUBECONFIG="$(kind get kubeconfig-path --name=${KIND_CLUSTER_NAME})" } diff --git a/contrib/hack/ci/run-e2e-tests.sh b/contrib/hack/ci/run-e2e-tests.sh index e90e1ee832f..f786c778e3c 100755 --- a/contrib/hack/ci/run-e2e-tests.sh +++ b/contrib/hack/ci/run-e2e-tests.sh @@ -105,6 +105,7 @@ main() { echo "Skipping kind and helm installation cause SKIP_DEPS_INSTALLATION is set to true." fi + export KUBERNETES_VERSION=${STABLE_KUBERNETES_VERSION} kind::create_cluster install::cluster::tiller diff --git a/contrib/hack/ci/run-migration-tests.sh b/contrib/hack/ci/run-migration-tests.sh index c359a2b4c6c..7d32e820c31 100755 --- a/contrib/hack/ci/run-migration-tests.sh +++ b/contrib/hack/ci/run-migration-tests.sh @@ -30,9 +30,11 @@ set -E # needs to be set if we want the ERR trap readonly CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) readonly REPO_ROOT_DIR=${CURRENT_DIR}/../../../ readonly TMP_DIR=$(mktemp -d) + source "${CURRENT_DIR}/lib/utilities.sh" || { echo 'Cannot load CI utilities.'; exit 1; } -source "${CURRENT_DIR}/deps_ver.sh" || { echo 'Cannot load dependencies versions.'; exit 1; } +source "${CURRENT_DIR}/lib/deps_ver.sh" || { echo 'Cannot load dependencies versions.'; exit 1; } +SKIP_DEPS_INSTALLATION=${SKIP_DEPS_INSTALLATION:-} SC_CHART_NAME="catalog" export SC_NAMESPACE="catalog" @@ -91,8 +93,15 @@ examiner::execute_test() { main() { shout "Starting migration test" - export INSTALL_DIR=${TMP_DIR} KIND_VERSION=${STABLE_KIND_VERSION} HELM_VERSION=${STABLE_HELM_VERSION} - install::local::kind_and_helm + if [[ "${SKIP_DEPS_INSTALLATION}" == "" ]]; then + export INSTALL_DIR=${TMP_DIR} KIND_VERSION=${STABLE_KIND_VERSION} HELM_VERSION=${STABLE_HELM_VERSION} + install::local::kind + install::local::helm + else + echo "Skipping kind and helm installation cause SKIP_DEPS_INSTALLATION is set to true." + fi + + export KUBERNETES_VERSION=${STABLE_KUBERNETES_VERSION} kind::create_cluster install::cluster::tiller