I have a gitlab job in which I am running some cypress tests against a jboss and a postgresql. Both jboss and postgresql are declared as services in the job. Here is the job’s relevant part:
e2e-tests:
stage: test-images
before_script: []
services:
- name: ourdockerrepo/bitnami/postgresql:16-debian-12
alias: db
- name: ourdockerrepo/jboss-app-to-test:something
alias: eap
image:
name: cypress/included:13.6.4
entrypoint: [ "" ]
script:
- |
start=$EPOCHSECONDS
max_seconds_timeout=600
while [ $(wget --spider -S "http://eap/app" 2>&1 | grep "HTTP/" | grep -q 200 && echo "true" || echo "false") == "false" ];
do
echo ".";
sleep 1;
if (( EPOCHSECONDS-start > max_seconds_timeout )); then echo "timeout! eap not raised within $max_seconds_timeout seconds."; exit 1; fi
done
- npm install
- npm run (cypress stuff)
...
I am experiencing that gitlab’s healthcheck for both services expire and they both go in some sort of race condition. Sometimes db
starts before eap
and tests run as expected. Sometimes eap
fails to start properly because it came up before db
does, causing script’s while
check to timeout. I am a gitlab greenhorn, is there any way to prevent this behavior and start services in the order I declared in job? Thankyou!