diff --git a/tests/wait.sh b/tests/wait.sh new file mode 100755 index 0000000000000000000000000000000000000000..3a9db2265caf69cee457b9203b40d527f9d98d6f --- /dev/null +++ b/tests/wait.sh @@ -0,0 +1,26 @@ +#!/bin/bash +wait_project() { + # interval and timeout are in seconds + interval=5 + timeout=600 + # + resourcename=mattermost + counter=0 + # need to remove the default "set -e" to allow commands to return nonzero exit codes without the script failing + set +e + while true; do + if kubectl get $resourcename -o json --namespace=$resourcename -o jsonpath='{.items[0].status.state}' | \ + grep "^stable" 1>/dev/null + then + echo "$resourcename custom resource creation finished" + break + fi + sleep $interval + let counter++ + if [[ $(($counter * $interval)) -ge $timeout ]]; then + echo "$resourcename timeout waiting $timeout seconds for resource creation" 1>&2 + exit 1 + fi + done + set -e +}