From 5edd9d0fdba6c350ec9f9a87972ba17d33a8ee17 Mon Sep 17 00:00:00 2001 From: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Date: Wed, 14 Jul 2021 16:40:48 +0530 Subject: [PATCH] Wait for server to start before Cypress tests (#5846) --- .github/workflows/client-test.yml | 6 +++++- app/client/cypress/setup-test.sh | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/client-test.yml b/.github/workflows/client-test.yml index d40d419150..b682840a9f 100644 --- a/.github/workflows/client-test.yml +++ b/.github/workflows/client-test.yml @@ -333,7 +333,11 @@ jobs: APPSMITH_ENCRYPTION_SALT: "salt" APPSMITH_IS_SELF_HOSTED: false run: | - ./scripts/start-dev-server.sh > /dev/null 2>&1 & + ./scripts/start-dev-server.sh > /dev/null 2>&1 & + + - name: Wait for 30 seconds for server to start + run: sleep 30s + shell: bash - name: Use Node.js 14.15.4 uses: actions/setup-node@v1 diff --git a/app/client/cypress/setup-test.sh b/app/client/cypress/setup-test.sh index 5572a71fe3..e359f5a624 100755 --- a/app/client/cypress/setup-test.sh +++ b/app/client/cypress/setup-test.sh @@ -41,6 +41,23 @@ sleep 30 echo "Checking if the containers have started" sudo docker ps -a +echo "Checking if the server has started" +status_code=$(curl -o /dev/null -s -w "%{http_code}\n" https://dev.appsmith.com/api/v1/users) + +retry_count=1 + +while [ "$retry_count" -le "3" -a "$status_code" -eq "502" ]; do + echo "Hit 502.Server not started retrying..." + retry_count=$((1 + $retry_count)) + sleep 30 + status_code=$(curl -o /dev/null -s -w "%{http_code}\n" https://dev.appsmith.com/api/v1/users) +done + +if [ "$status_code" -eq "502" ]; then + echo "Unable to connect to server" + exit 1 +fi + # Create the test user curl -k --request POST -v 'https://dev.appsmith.com/api/v1/users' \ --header 'Content-Type: application/json' \