Skip to content

Commit fd9fd6d

Browse files
authored
Merge pull request #1059 from snyk/fix/operator_tests
fix: operator upgrade tests
2 parents b12bea9 + b3cd384 commit fd9fd6d

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

.circleci/config.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -600,21 +600,18 @@ jobs:
600600
SLEEP_SECONDS_BETWEEN_ATTEMPTS=5
601601
# total = 10 minutes wait time
602602
603-
EXPECTED_TAG="${LATEST_TAG}-ubi8"
604603
# Periodically poll if the snyk-monitor has upgraded
605604
for (( attempt=1; attempt<ATTEMPTS; attempt++))
606605
do
607-
# Grab the tag of the snyk-monitor container image.
608-
SNYK_MONITOR_POD=$(kubectl get pods -n snyk-monitor --no-headers | grep "snyk-monitor")
609-
if [[ ! -z "${SNYK_MONITOR_POD}" ]]; then
610-
VERSION=$(echo "${SNYK_MONITOR_POD}" | \
611-
awk 'END { print $1 }' | \
606+
# Grab the tag of the snyk-monitor container image. If snyk-monitor is not deployed for some reason, we exit immediately.
607+
VERSION=$(kubectl get pods -n snyk-monitor --no-headers | \
608+
grep "snyk-monitor" | \
609+
awk 'END { if (NR==0) exit 1; else print $1 }' | \
612610
xargs '-I{}' kubectl get pod '{}' -n snyk-monitor -o 'jsonpath={..containers[*].image}' | \
613-
grep -oE "[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,3}$")
614-
fi
611+
awk '{print $1}' | grep -oE "[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,3}$")
615612
616613
# Break out of the polling if the tag matches the one we want to upgrade to.
617-
if [[ "${VERSION}" == "${EXPECTED_TAG}" ]]; then
614+
if [[ "${VERSION}" == "${LATEST_TAG}" ]]; then
618615
break
619616
fi
620617
@@ -627,8 +624,8 @@ jobs:
627624
awk 'END { if (NR==0) exit 101; else print $1 }')
628625
629626
# If we polled for 5 minutes and the snyk-monitor still hasn't upgraded, fail the current job.
630-
if [[ "${VERSION}" != "${EXPECTED_TAG}" ]]; then
631-
&>2 echo "versions (${VERSION}) does not match expected (${EXPECTED_TAG})!"
627+
if [[ "${VERSION}" != "${LATEST_TAG}" ]]; then
628+
&>2 echo "versions (${VERSION}) does not match expected (${LATEST_TAG})!"
632629
633630
kubectl describe pod ${SNYK_MONITOR_POD} -n snyk-monitor
634631
kubectl describe catalogsource snyk-operator -n openshift-marketplace

.circleci/config/jobs/operator_upgrade_tests.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,18 @@ steps:
175175
SLEEP_SECONDS_BETWEEN_ATTEMPTS=5
176176
# total = 10 minutes wait time
177177
178-
EXPECTED_TAG="${LATEST_TAG}-ubi8"
179178
# Periodically poll if the snyk-monitor has upgraded
180179
for (( attempt=1; attempt<ATTEMPTS; attempt++))
181180
do
182-
# Grab the tag of the snyk-monitor container image.
183-
SNYK_MONITOR_POD=$(kubectl get pods -n snyk-monitor --no-headers | grep "snyk-monitor")
184-
if [[ ! -z "${SNYK_MONITOR_POD}" ]]; then
185-
VERSION=$(echo "${SNYK_MONITOR_POD}" | \
186-
awk 'END { print $1 }' | \
181+
# Grab the tag of the snyk-monitor container image. If snyk-monitor is not deployed for some reason, we exit immediately.
182+
VERSION=$(kubectl get pods -n snyk-monitor --no-headers | \
183+
grep "snyk-monitor" | \
184+
awk 'END { if (NR==0) exit 1; else print $1 }' | \
187185
xargs '-I{}' kubectl get pod '{}' -n snyk-monitor -o 'jsonpath={..containers[*].image}' | \
188-
grep -oE "[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,3}$")
189-
fi
186+
awk '{print $1}' | grep -oE "[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,3}$")
190187
191188
# Break out of the polling if the tag matches the one we want to upgrade to.
192-
if [[ "${VERSION}" == "${EXPECTED_TAG}" ]]; then
189+
if [[ "${VERSION}" == "${LATEST_TAG}" ]]; then
193190
break
194191
fi
195192
@@ -202,8 +199,8 @@ steps:
202199
awk 'END { if (NR==0) exit 101; else print $1 }')
203200
204201
# If we polled for 5 minutes and the snyk-monitor still hasn't upgraded, fail the current job.
205-
if [[ "${VERSION}" != "${EXPECTED_TAG}" ]]; then
206-
&>2 echo "versions (${VERSION}) does not match expected (${EXPECTED_TAG})!"
202+
if [[ "${VERSION}" != "${LATEST_TAG}" ]]; then
203+
&>2 echo "versions (${VERSION}) does not match expected (${LATEST_TAG})!"
207204
208205
kubectl describe pod ${SNYK_MONITOR_POD} -n snyk-monitor
209206
kubectl describe catalogsource snyk-operator -n openshift-marketplace

0 commit comments

Comments
 (0)