Skip to content

Commit 4c2ed79

Browse files
committed
Refactor helm logic in test_cluster.sh (#463)
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.
1 parent 735e826 commit 4c2ed79

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

hack/release/smoke_test/test_cluster.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ if [[ "${SOLR_IMAGE}" != *":"* ]]; then
8383
SOLR_IMAGE="solr:${SOLR_IMAGE}"
8484
fi
8585

86+
export LOCATION="$LOCATION"
87+
export VERSION="$VERSION"
88+
89+
function add_solr_helm_repo() {
90+
if (echo "${LOCATION}" | grep "http"); then
91+
helm repo add --force-update "apache-solr-test-${VERSION}" "${LOCATION}/helm-charts"
92+
fi
93+
}
94+
95+
function remove_solr_helm_repo() {
96+
if (echo "${LOCATION}" | grep "http"); then
97+
helm repo remove "apache-solr-test-${VERSION}"
98+
fi
99+
}
100+
86101
# If LOCATION is not a URL, then get the absolute path
87102
if ! (echo "${LOCATION}" | grep "http"); then
88103
LOCATION=$(cd "${LOCATION}"; pwd)
@@ -94,9 +109,6 @@ else
94109
# If LOCATION is a URL, then we want to make sure we have the up-to-date docker image.
95110
docker pull "${IMAGE}"
96111

97-
# Add the Test Helm Repo
98-
helm repo add --force-update "apache-solr-test-${VERSION}" "${LOCATION}/helm-charts"
99-
100112
OP_HELM_CHART="apache-solr-test-${VERSION}/solr-operator"
101113
SOLR_HELM_CHART="apache-solr-test-${VERSION}/solr"
102114
fi
@@ -147,6 +159,8 @@ if [[ -n "${GPG_KEY:-}" ]]; then
147159
fi
148160
fi
149161

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

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

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

278290

279291
printf "\nDo a rolling restart and make sure the cluster is healthy afterwards\n"
280-
292+
add_solr_helm_repo
281293
helm upgrade --kube-context "${KUBE_CONTEXT}" ${VERIFY_OR_NOT} example "${SOLR_HELM_CHART}" --reuse-values \
282294
--set-string podOptions.annotations.restart="true"
283295
printf '\nWait for the rolling restart to begin.\n\n'
284296
grep -q "3 [[:digit:]] [[:digit:]] 0" <(exec kubectl get solrcloud example -w); kill $!
297+
remove_solr_helm_repo
285298

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

0 commit comments

Comments
 (0)