Skip to content

Commit c5448a2

Browse files
Andrea Barbassoatarix83
authored andcommitted
Merged in task/main-cris/DSC-2592 (pull request DSpace#3808)
[DSC-2592] add pipeline step to check for runners to be up and running before e2e tests Approved-by: Giuseppe Digilio
2 parents f1b0087 + 1f5540c commit c5448a2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

bitbucket-pipelines.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ definitions:
105105
- node-2024-02-x
106106
- cypress-2024-02-x
107107
script:
108+
- apt-get update && apt-get install -y curl
108109
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
109110
- echo "Running tests for commit $HASH_COMMIT"
110111
- export DSPACE_REST_HOST=${E2E_RUNNER_HOST}
@@ -120,6 +121,27 @@ definitions:
120121
- export CYPRESS_CACHE_FOLDER=~/.cache/Cypress
121122
- export CHROME_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu"
122123
- export NODE_OPTIONS="--max-old-space-size=4096"
124+
- |
125+
MAX_RETRIES=10
126+
RETRY_COUNT=0
127+
SUCCESS=false
128+
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
129+
echo "Pinging REST endpoint... (Attempt $((RETRY_COUNT+1)))"
130+
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://$DSPACE_REST_HOST$DSPACE_REST_NAMESPACE")
131+
if [ "$STATUS_CODE" -lt 400 ]; then
132+
echo "REST endpoint is up! Status code: $STATUS_CODE"
133+
SUCCESS=true
134+
break
135+
else
136+
echo "REST endpoint not ready (Status code: $STATUS_CODE). Retrying in 60 seconds..."
137+
RETRY_COUNT=$((RETRY_COUNT+1))
138+
sleep 60
139+
fi
140+
done
141+
if [ "$SUCCESS" = "false" ]; then
142+
echo "REST endpoint did not become available after $MAX_RETRIES attempts. Failing the build."
143+
exit 1
144+
fi
123145
- npx cypress install
124146
- yarn serve:ssr &
125147
- echo "Waiting for server to start..."

0 commit comments

Comments
 (0)