Files
git 86fba4f43f modified: default-environment.env
modified:   monitoring/node-red/Dockerfile
	modified:   monitoring/node-red/data/.flows.json.backup
	modified:   monitoring/node-red/data/context/00b02bbd01c91485/flow.json
	modified:   monitoring/node-red/data/flows.json
	modified:   monitoring/node-red/data/test-container.sh
	modified:   monitoring/node-red/docker-compose.yml
	modified:   services-up.sh
	monitoring/node-red/data/update-events.ndjson
2026-04-13 09:41:16 +10:00

48 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# test-container.sh
# Usage: ./test-container.sh container_name host
container="$1"
host="$2"
test_name="testing-${container}"
compose_script="/compose/${host}/services-up.sh"
# Run container in detached mode
$compose_script --profile all run -d --name "$test_name" --build "$container"
# Poll health status
timeout=60 # seconds
interval=2 # seconds
elapsed=0
result=1 # default to failure
while [ $elapsed -lt $timeout ]; do
status=$(docker inspect --format='{{.State.Health.Status}}' "$test_name" 2>/dev/null)
if [ "$status" == "healthy" ]; then
# echo "healthy"
result=0 # success
break
elif [ "$status" == "unhealthy" ]; then
# echo "unhealthy"
result=1 # failure
break
fi
sleep $interval
elapsed=$((elapsed + interval))
done
# Timeout case
if [ $elapsed -ge $timeout ]; then
# echo "timeout"
result=1
fi
# Cleanup
docker rm "$test_name" --force >/dev/null 2>&1
#echo "Exiting with $result" >&2
echo $result
exit $result