From b93f913f401be7edde92338b549e5e23ce07dd8a Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 18 Sep 2023 12:22:57 +0300 Subject: [PATCH] PMM-12494 Wait for PMM to be ready (#640) * Update docker_way_upgrade.sh * Update docker_way_upgrade.sh * Update docker_way_upgrade.sh --- pmm-tests/docker_way_upgrade.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pmm-tests/docker_way_upgrade.sh b/pmm-tests/docker_way_upgrade.sh index 593c6e99..20230f9d 100644 --- a/pmm-tests/docker_way_upgrade.sh +++ b/pmm-tests/docker_way_upgrade.sh @@ -6,6 +6,20 @@ if [ $# -lt 1 ]; then exit 1 fi +wait-for-url() { + echo "Testing $1" + timeout -s TERM 240 bash -c \ + 'while [[ "$(curl -s -o /dev/null -L -w ''%{http_code}'' ${0})" != "200" ]];\ + do echo "Waiting for ${0}" && sleep 2;\ + done' ${1} + echo "OK!" + if curl -I $1; then + echo "PMM is ready" + else + echo "PMM is not ready" + fi +} + #check for Container Name To Stop before Upgrade export PMM_SERVER_DOCKER_CONTAINER=$(docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Names}}" | grep 'pmm-server' | awk '{print $3}') echo $PMM_SERVER_DOCKER_CONTAINER @@ -17,5 +31,5 @@ export PMM_SERVER_DOCKER_VOLUME=$(docker ps -a --format "table {{.ID}}\t{{.Image PWD=$(pwd) PMM_SERVER_IMAGE=$1 docker-compose up -d pmm-server docker network connect pmm-qa pmm-server || true -sleep 30 +wait-for-url http://127.0.0.1/v1/readyz docker logs pmm-server