You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see there a proper health check is implemented only for the MySQL container.
When we start the container, we should wait until they are "healthy" before using them.
There is no health check for the tracker and index backend container. We only wait for 20 seconds.
Problem
Sometimes workflows are broken because there are broken tests but the reason they are broken is because the service is not up and running (for example the tracker).
We should detect that problem before even running the tests.
Solution 1: Implement health-check for all container
The best one.
Solution 2: Detect that container are not running parsing the docker output
We can run docker ps and check that at least all containers are running.
Cons:
Volatile solution.
Solution 3: Add some custom checks to the bash script
We can make some basic requests to the public endpoints to check that the service is up.
For example, for the tracker:
TRACKER_STATUS_ENDPOINT="http://localhost:1212/api/v1/stats?token=MyAccessToken"# Use curl to get the HTTP status code
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}"$API_ENDPOINT)# Check the status codeif [ $HTTP_STATUS-ne 200 ];thenecho"Error: Tracker service is not available"exit 1
fi
In the future, we should add a new status endpoint.
Conclusion
I would implement solution 3 now to avoid misleading error messages on workflow executions. And solution 1 in the long term.
We should do the same in the Tracker and Frontend projects, wherever we need to wait until the containers are ready.
Relates to: #254
Context
We use docker-compose to start the E2E testing environment.
The bash script to start the environment is: https://github.com/torrust/torrust-index-backend/blob/develop/docker/bin/e2e/run-e2e-tests.sh
As you can see there a proper health check is implemented only for the MySQL container.
When we start the container, we should wait until they are "healthy" before using them.
There is no health check for the tracker and index backend container. We only wait for 20 seconds.
Problem
Sometimes workflows are broken because there are broken tests but the reason they are broken is because the service is not up and running (for example the tracker).
We should detect that problem before even running the tests.
Solution 1: Implement health-check for all container
The best one.
Solution 2: Detect that container are not running parsing the docker output
We can run
docker ps
and check that at least all containers are running.Cons:
Solution 3: Add some custom checks to the bash script
We can make some basic requests to the public endpoints to check that the service is up.
For example, for the tracker:
In the future, we should add a new
status
endpoint.Conclusion
I would implement solution 3 now to avoid misleading error messages on workflow executions. And solution 1 in the long term.
We should do the same in the Tracker and Frontend projects, wherever we need to wait until the containers are ready.
cc @da2ce7
The text was updated successfully, but these errors were encountered: