2020-07-11 19:09:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-01-04 03:59:19 +00:00
|
|
|
# go to script root directory
|
2021-12-05 00:42:03 +00:00
|
|
|
cd "$(dirname "$0")" || exit 1
|
2020-07-11 19:09:08 +00:00
|
|
|
|
2022-01-04 03:59:19 +00:00
|
|
|
# compose down function for reuse
|
2021-12-05 00:42:03 +00:00
|
|
|
down() {
|
2022-01-04 03:59:19 +00:00
|
|
|
docker-compose down -v --remove-orphans
|
2021-12-05 00:42:03 +00:00
|
|
|
}
|
|
|
|
|
2022-01-04 03:59:19 +00:00
|
|
|
fullMinecraftUpTest(){
|
|
|
|
name=$1
|
|
|
|
failed=false
|
|
|
|
# run the monitor to validate the Minecraft image is healthy
|
|
|
|
docker-compose run monitor || failed=true
|
|
|
|
echo "${name} Result: failed=$failed"
|
2020-07-11 19:26:47 +00:00
|
|
|
|
2022-01-04 03:59:19 +00:00
|
|
|
# docker-compose logs outputs messages from the specified container
|
|
|
|
if $failed; then
|
|
|
|
docker-compose logs mc
|
|
|
|
down
|
|
|
|
exit 2
|
|
|
|
fi
|
2021-12-05 00:42:03 +00:00
|
|
|
down
|
2022-01-04 03:59:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setupOnlyMinecraftTest(){
|
|
|
|
folder=$1
|
|
|
|
failed=false
|
|
|
|
# run the monitor to validate the Minecraft image is healthy
|
|
|
|
docker-compose --log-level ERROR up --quiet-pull --exit-code-from mc 2>/dev/null || failed=true
|
|
|
|
echo "${folder} Result: failed=$failed"
|
|
|
|
|
|
|
|
# docker-compose logs outputs messages from the specified container
|
|
|
|
if $failed; then
|
|
|
|
docker-compose logs mc
|
|
|
|
down
|
|
|
|
cd ..
|
|
|
|
exit 2
|
|
|
|
fi
|
2021-12-05 00:42:03 +00:00
|
|
|
down
|
2022-01-04 03:59:19 +00:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
# run tests on base docker compose and validate mc service with monitor
|
|
|
|
fullMinecraftUpTest 'Full Vanilla Test'
|
2020-07-11 19:09:08 +00:00
|
|
|
|
2022-01-04 03:59:19 +00:00
|
|
|
# go through each folder to test builds
|
|
|
|
FOLDERS=$(ls)
|
|
|
|
for folder in $FOLDERS; do
|
|
|
|
# If folder is a directory
|
|
|
|
if [ -d "$folder" ]; then
|
|
|
|
cd "$folder"
|
|
|
|
setupOnlyMinecraftTest $folder
|
|
|
|
fi
|
|
|
|
done
|