-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Labels
- Developer -Torrust Improvement ExperienceTorrust Improvement ExperienceCode Cleanup / RefactoringTidying and Making NeatTidying and Making NeatQuality & AssuranceRelates to QA, Testing, and CIRelates to QA, Testing, and CI
Description
Parent: #384
The bash function:
wait_for_container_to_be_healthy() {
local container_name="$1"
local max_retries="$2"
local retry_interval="$3"
local retry_count=0
while [ $retry_count -lt "$max_retries" ]; do
container_health="$(docker inspect --format='{{json .State.Health}}' "$container_name")"
if [ "$container_health" != "{}" ]; then
container_status="$(echo "$container_health" | jq -r '.Status')"
if [ "$container_status" == "healthy" ]; then
echo "Container $container_name is healthy"
return 0
fi
fi
retry_count=$((retry_count + 1))
echo "Waiting for container $container_name to become healthy (attempt $retry_count of $max_retries)..."
sleep "$retry_interval"
done
echo "Timeout reached, container $container_name is not healthy"
return 1
}is duplicated in two bash scripts:
- https://github.com/torrust/torrust-index/blob/develop/contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh#L14-L37
- https://github.com/torrust/torrust-index/blob/develop/contrib/dev-tools/container/e2e/sqlite/run-e2e-tests.sh#L14-L37
It's used to check if a container is healthy. Maybe, we should use the docker API instead of parsing the docker commands output.
Metadata
Metadata
Assignees
Labels
- Developer -Torrust Improvement ExperienceTorrust Improvement ExperienceCode Cleanup / RefactoringTidying and Making NeatTidying and Making NeatQuality & AssuranceRelates to QA, Testing, and CIRelates to QA, Testing, and CI
Type
Projects
Status
No status