From bda496ed26662eaee0b3dce9809abd85ddfb9f99 Mon Sep 17 00:00:00 2001 From: Brendon Lloyd Date: Wed, 1 Sep 2021 15:19:48 -1000 Subject: [PATCH] Add script to wait for mattermost custom resources to come up --- tests/wait.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 tests/wait.sh diff --git a/tests/wait.sh b/tests/wait.sh new file mode 100755 index 0000000..3a9db22 --- /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 +} -- GitLab