1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-16 10:59:53 +02:00
Mailu/tests/compose/test-script.sh

68 lines
1.2 KiB
Bash
Raw Normal View History

2018-10-04 13:42:34 +02:00
#!/bin/bash
2018-10-05 10:55:01 +02:00
containers=(
webmail_1
imap_1
smtp_1
antispam_1
admin_1
redis_1
antivirus_1
webdav_1
2018-10-05 14:04:04 +02:00
fetchmail_1
front_1
2018-10-05 10:55:01 +02:00
)
2018-10-06 14:52:39 +02:00
# Default to mailu for DOCKER_ORG
if [ -z "$DOCKER_ORG" ]; then
export DOCKER_ORG="mailu"
fi
2018-10-06 15:25:12 +02:00
# Verbose sleep, to prevent Travis to cancel the build
# First argument is desired sleep time in minutes
v_sleep() {
COUNT=$1
until [ $COUNT -eq 0 ]; do
echo "Sleep for $COUNT more minutes"
sleep 1m
((COUNT--))
done;
}
containers_check() {
2018-10-06 15:25:12 +02:00
v_sleep 1
2018-10-04 16:51:17 +02:00
STATUS=0
2018-10-05 10:55:01 +02:00
for container in "${containers[@]}"; do
echo "Checking ${DOCKER_ORG}_${container}"
docker inspect "${DOCKER_ORG}_${container}" | grep '"Status": "running"' || STATUS=1
done
2018-10-06 15:12:05 +02:00
docker ps -a
2018-10-04 16:51:17 +02:00
return $STATUS
}
2018-10-05 10:55:01 +02:00
container_logs() {
for container in "${containers[@]}"; do
echo "Showing logs for ${DOCKER_ORG}_${container}"
docker container logs "${DOCKER_ORG}_${container}"
2018-10-05 10:55:01 +02:00
done
}
2018-10-06 15:03:07 +02:00
clean() {
docker-compose -f tests/compose/run.yml -p $DOCKER_ORG down || exit 1
rm -fv .env
}
# Cleanup before callig exit
die() {
clean
exit $1
}
2018-10-04 14:19:40 +02:00
for file in tests/compose/*.env ; do
2018-10-04 13:42:34 +02:00
cp $file .env
docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d
2018-10-05 10:55:01 +02:00
container_logs
2018-10-06 15:03:07 +02:00
containers_check || die 1
clean
2018-10-04 13:42:34 +02:00
done