This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from SUSE/f0rmiga/run-cats-ci
Add CATS to run on CI
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset | ||
|
||
# shellcheck disable=SC1090 | ||
source "$(bazel info workspace)/.gitlab/pipelines/runtime/config.sh" | ||
# shellcheck disable=SC1090 | ||
source "$(bazel info workspace)/.gitlab/pipelines/runtime/binaries.sh" | ||
|
||
# Trigger cf-acceptance-tests. | ||
bazel run //testing/acceptance_tests | ||
|
||
cf_acceptance_tests_pod_name() { | ||
"${KUBECTL}" get pods --namespace "${KUBECF_NAMESPACE}" --output name 2> /dev/null | grep "acceptance-tests" | ||
} | ||
|
||
# Wait for cf-acceptance-tests to start. | ||
wait_for_cf_acceptance_tests_pod() { | ||
local timeout="300" | ||
until "${KUBECTL}" get pods --namespace "${KUBECF_NAMESPACE}" --output name 2> /dev/null | grep --quiet "acceptance-tests" || [[ "$timeout" == "0" ]]; do sleep 1; timeout=$((timeout - 1)); done | ||
if [[ "${timeout}" == 0 ]]; then return 1; fi | ||
pod_name="$(cf_acceptance_tests_pod_name)" | ||
until [[ "$("${KUBECTL}" get "${pod_name}" --namespace "${KUBECF_NAMESPACE}" --output jsonpath='{.status.containerStatuses[?(@.name == "acceptance-tests-acceptance-tests")].state.running}' 2> /dev/null)" != "" ]] || [[ "$timeout" == "0" ]]; do sleep 1; timeout=$((timeout - 1)); done | ||
if [[ "${timeout}" == 0 ]]; then return 1; fi | ||
return 0 | ||
} | ||
|
||
echo "Waiting for the cf-acceptance-tests pod to start..." | ||
wait_for_cf_acceptance_tests_pod || { | ||
>&2 echo "Timed out waiting for the cf-acceptance-tests pod" | ||
exit 1 | ||
} | ||
|
||
# Follow the logs. If the tests fail, the logs command will also fail. | ||
pod_name="$(cf_acceptance_tests_pod_name)" | ||
"${KUBECTL}" logs --follow "${pod_name}" --namespace "${KUBECF_NAMESPACE}" --container acceptance-tests-acceptance-tests | ||
|
||
# Wait for the container to terminate and then exit the script with the container's exit code. | ||
jsonpath='{.status.containerStatuses[?(@.name == "acceptance-tests-acceptance-tests")].state.terminated.exitCode}' | ||
while true; do | ||
exit_code="$("${KUBECTL}" get "${pod_name}" --namespace "${KUBECF_NAMESPACE}" --output "jsonpath=${jsonpath}")" | ||
if [[ -n "${exit_code}" ]]; then | ||
exit "${exit_code}" | ||
fi | ||
sleep 1 | ||
done |