I’m setting up an AutoDevops pipeline on gitlab.com (Simplicite Software / gitlab-cicd · GitLab) with an additional automated UI testing (with Selenium) stage (uitest) between the staging stage and the production stage.
The thing is, my tests need the app to be fully started so they can work properly, so I don’t want to consider that a deploy job is finished before the app has finished warming up. As it can take some time, so I’ve added a HEALTHCHECK command to my Dockerfile
HEALTHCHECK --interval=30s --timeout=1s --start-period=300s CMD curl -sf http://localhost:8080/ping || exit 1
When I run my container locally, I have the correct states returned by the docker daemon:
> docker ps CONTAINER ID CREATED STATUS 8d4d4d07ec6b 17 seconds ago Up 16 seconds (health: starting) > docker ps CONTAINER ID CREATED STATUS 8d4d4d07ec6b 7 minutes ago Up 7 minutes (healthy)
I was expecting the staging stage to implement a health verification loop at the and to enable the job :
- not to finish before the container is out of the starting state,
- to succeed if the container falls in the healthy state,
- to fail if the container falls in the unhealthy state,
but apparently gitlab doesn’t care about the container health.
I might have misconfigured something, but as a troubleshooting step, to exclude other factors that could make my uitest fail, I’ve added a curl healthcheck at the beginning of the script that runs the tests, which should systematically be positive: either the staging job fails and the uitest job should not run, or the staging job succeeds and the healthcheck can’t be negative.
The following would help me:
- confirmation that gitlab doesn’t check the container health before finishing a deploy job (I couldn’t find any such step in the Deploy template
- advice on how to customize the staging job to implement the described health verification loop.
Thank you for reading