Skip to content

Commit

Permalink
Refactor helm logic in test_cluster.sh (#463)
Browse files Browse the repository at this point in the history
This fixes a bug in the smoketester wherein we attempted to 'upgrade' a
helm package that had previously been removed during some mid-execution
cleanup.
  • Loading branch information
gerlowskija committed Aug 7, 2022
1 parent 735e826 commit 4c2ed79
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions hack/release/smoke_test/test_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ if [[ "${SOLR_IMAGE}" != *":"* ]]; then
SOLR_IMAGE="solr:${SOLR_IMAGE}"
fi

export LOCATION="$LOCATION"
export VERSION="$VERSION"

function add_solr_helm_repo() {
if (echo "${LOCATION}" | grep "http"); then
helm repo add --force-update "apache-solr-test-${VERSION}" "${LOCATION}/helm-charts"
fi
}

function remove_solr_helm_repo() {
if (echo "${LOCATION}" | grep "http"); then
helm repo remove "apache-solr-test-${VERSION}"
fi
}

# If LOCATION is not a URL, then get the absolute path
if ! (echo "${LOCATION}" | grep "http"); then
LOCATION=$(cd "${LOCATION}"; pwd)
Expand All @@ -94,9 +109,6 @@ else
# If LOCATION is a URL, then we want to make sure we have the up-to-date docker image.
docker pull "${IMAGE}"

# Add the Test Helm Repo
helm repo add --force-update "apache-solr-test-${VERSION}" "${LOCATION}/helm-charts"

OP_HELM_CHART="apache-solr-test-${VERSION}/solr-operator"
SOLR_HELM_CHART="apache-solr-test-${VERSION}/solr"
fi
Expand Down Expand Up @@ -147,6 +159,8 @@ if [[ -n "${GPG_KEY:-}" ]]; then
fi
fi

add_solr_helm_repo

# Install the Solr Operator
kubectl create -f "${LOCATION}/crds/all-with-dependencies.yaml" || kubectl replace -f "${LOCATION}/crds/all-with-dependencies.yaml"
helm install --kube-context "${KUBE_CONTEXT}" ${VERIFY_OR_NOT} solr-operator "${OP_HELM_CHART}" \
Expand All @@ -169,9 +183,7 @@ helm install --kube-context "${KUBE_CONTEXT}" ${VERIFY_OR_NOT} example "${SOLR_H
--set "backupRepositories[0].volume.source.hostPath.path=/tmp/backup"

# If LOCATION is a URL, then remove the helm repo after use
if (echo "${LOCATION}" | grep "http"); then
helm repo remove "apache-solr-test-${VERSION}"
fi
remove_solr_helm_repo

# Wait for solrcloud to be ready
printf '\nWait for all 3 Solr nodes to become ready.\n\n'
Expand Down Expand Up @@ -277,11 +289,12 @@ fi


printf "\nDo a rolling restart and make sure the cluster is healthy afterwards\n"

add_solr_helm_repo
helm upgrade --kube-context "${KUBE_CONTEXT}" ${VERIFY_OR_NOT} example "${SOLR_HELM_CHART}" --reuse-values \
--set-string podOptions.annotations.restart="true"
printf '\nWait for the rolling restart to begin.\n\n'
grep -q "3 [[:digit:]] [[:digit:]] 0" <(exec kubectl get solrcloud example -w); kill $!
remove_solr_helm_repo

printf '\nWait 5 minutes for all 3 Solr nodes to become ready.\n\n'
grep -q "3 3 3 3" <(exec kubectl get solrcloud example -w --request-timeout 300); kill $!
Expand Down

0 comments on commit 4c2ed79

Please sign in to comment.