Skip to content

Commit

Permalink
Merge pull request #2779 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2776-to-release-1.23

[release-1.23] Bound variables in run-e2e.sh
  • Loading branch information
k8s-ci-robot committed Nov 16, 2022
2 parents 24d187a + 1f2a3f3 commit 1406af7
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions .pipelines/scripts/run-e2e.sh
Expand Up @@ -20,12 +20,12 @@ set -o pipefail

REPO_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/../..)
export GOPATH="/home/vsts/go"
export PATH="${PATH}:${GOPATH}/bin"
export AKS_CLUSTER_ID="/subscriptions/${AZURE_SUBSCRIPTION_ID}/resourcegroups/${RESOURCE_GROUP}/providers/Microsoft.ContainerService/managedClusters/${CLUSTER_NAME}"
export PATH="${PATH:-}:${GOPATH}/bin"
export AKS_CLUSTER_ID="/subscriptions/${AZURE_SUBSCRIPTION_ID:-}/resourcegroups/${RESOURCE_GROUP:-}/providers/Microsoft.ContainerService/managedClusters/${CLUSTER_NAME:-}"

if [[ -z "${RELEASE_PIPELINE}" ]]; then
if [[ -z "${RELEASE_PIPELINE:-}" ]]; then
az extension add -n aks-preview
az login --service-principal -u "${AZURE_CLIENT_ID}" -p "${AZURE_CLIENT_SECRET}" --tenant "${AZURE_TENANT_ID}"
az login --service-principal -u "${AZURE_CLIENT_ID:-}" -p "${AZURE_CLIENT_SECRET:-}" --tenant "${AZURE_TENANT_ID:-}"
fi

get_random_location() {
Expand All @@ -42,20 +42,22 @@ cleanup() {
echo "gc the aks cluster"
# It is possible that kubetest2-aks is not built before cleanup(), so the following command
# is fine to fail.
kubetest2 aks --down --rgName "${RESOURCE_GROUP}" --clusterName "${CLUSTER_NAME}" || true
kubetest2 aks --down --rgName "${RESOURCE_GROUP:-}" --clusterName "${CLUSTER_NAME:-}" || true
}
trap cleanup EXIT

export AZURE_LOCATION="$(get_random_location)"
if [[ -z "${AZURE_LOCATION:-}" ]]; then
export AZURE_LOCATION="$(get_random_location)"
fi

if [[ -z "${IMAGE_TAG}" ]]; then
if [[ -z "${IMAGE_TAG:-}" ]]; then
IMAGE_TAG="$(git rev-parse --short=7 HEAD)"
fi
CLUSTER_CONFIG_PATH="${REPO_ROOT}/.pipelines/templates/basic-lb.json"
if [[ "${CLUSTER_TYPE}" == "autoscaling" ]]; then
if [[ "${CLUSTER_TYPE:-}" == "autoscaling" ]]; then
CLUSTER_CONFIG_PATH="${REPO_ROOT}/.pipelines/templates/autoscaling.json"
export AZURE_LOADBALANCER_SKU=standard
elif [[ "${CLUSTER_TYPE}" == "autoscaling-multipool" ]]; then
elif [[ "${CLUSTER_TYPE:-}" == "autoscaling-multipool" ]]; then
CLUSTER_CONFIG_PATH="${REPO_ROOT}/.pipelines/templates/autoscaling-multipool.json"
export AZURE_LOADBALANCER_SKU=standard
fi
Expand All @@ -70,28 +72,28 @@ go get -d sigs.k8s.io/kubetest2@latest
go install sigs.k8s.io/kubetest2@latest
go mod tidy
make deployer
if [[ -n "${RELEASE_PIPELINE}" ]]; then
if [[ -n "${RELEASE_PIPELINE:-}" ]]; then
make install
else
sudo GOPATH="/home/vsts/go" make install
fi
popd
if [[ -n "${RELEASE_PIPELINE}" ]]; then
if [[ -n "${RELEASE_PIPELINE:-}" ]]; then
rm -rf kubetest2-aks
go mod tidy
go mod vendor
fi

kubetest2 aks --up --rgName "${RESOURCE_GROUP}" \
--location "${AZURE_LOCATION}" \
--config "${CLUSTER_CONFIG_PATH}" \
kubetest2 aks --up --rgName "${RESOURCE_GROUP:-}" \
--location "${AZURE_LOCATION:-}" \
--config "${CLUSTER_CONFIG_PATH:-}" \
--customConfig "${REPO_ROOT}/.pipelines/templates/customconfiguration.json" \
--clusterName "${CLUSTER_NAME}" \
--ccmImageTag "${IMAGE_TAG}" \
--k8sVersion "${KUBERNETES_VERSION}"
--clusterName "${CLUSTER_NAME:-}" \
--ccmImageTag "${IMAGE_TAG:-}" \
--k8sVersion "${KUBERNETES_VERSION:-}"

export KUBECONFIG="${REPO_ROOT}/_kubeconfig/${RESOURCE_GROUP}_${CLUSTER_NAME}.kubeconfig"
if [[ ! -f "${KUBECONFIG}" ]]; then
export KUBECONFIG="${REPO_ROOT}/_kubeconfig/${RESOURCE_GROUP:-}_${CLUSTER_NAME:-}.kubeconfig"
if [[ ! -f "${KUBECONFIG:-}" ]]; then
echo "kubeconfig not exists"
exit 1
fi
Expand All @@ -108,12 +110,12 @@ kubectl get node -owide
echo "Running e2e"

# TODO: We should do it in autoscaling-multipool.json
if [[ "${CLUSTER_TYPE}" == "autoscaling-multipool" ]]; then
az aks update --subscription ${AZURE_SUBSCRIPTION_ID} --resource-group "${RESOURCE_GROUP}" --name "${CLUSTER_NAME}" --cluster-autoscaler-profile balance-similar-node-groups=true
if [[ "${CLUSTER_TYPE:-}" == "autoscaling-multipool" ]]; then
az aks update --subscription ${AZURE_SUBSCRIPTION_ID:-} --resource-group "${RESOURCE_GROUP:-}" --name "${CLUSTER_NAME:-}" --cluster-autoscaler-profile balance-similar-node-groups=true
fi

export E2E_ON_AKS_CLUSTER=true
if [[ "${CLUSTER_TYPE}" =~ "autoscaling" ]]; then
if [[ "${CLUSTER_TYPE:-}" =~ "autoscaling" ]]; then
export LABEL_FILTER="Feature:Autoscaling || !Serial && !Slow"
fi
make test-ccm-e2e

0 comments on commit 1406af7

Please sign in to comment.