miti.sh/test.sh

50 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# echo "hello"
# curl http://webdevcat.me:8080
image=miti.sh
echo "Starting test container..."
# Make sure to create 'no-internet' network, if it doesn't already exist:
# $ docker network create --internal no-internet
container_id=$(docker run --rm -d -v $(pwd):/opt/app --network no-internet \
--add-host=miti.sh=127.0.0.1 \
--add-host=apps.miti.sh=127.0.0.1 \
--add-host=git.miti.sh=127.0.0.1 \
--add-host=webdevcat.me=127.0.0.1 \
--add-host=apps.webdevcat.me=127.0.0.1 \
--add-host=git.webdevcat.me=127.0.0.1 \
$image)
echo "Test container started"
# docker exec -t $container_id cat /etc/hosts
# docker exec -t $container_id cat /opt/app/logs/error.log
docker exec -t $container_id busted
# echo "redirects webdevcat.me to miti.sh"
# response=$(docker exec -t $container_id curl -so /dev/null \
# -w "%{http_code} %{redirect_url}" http://webdevcat.me:8080)
# expected="301 http://miti.sh:8080/"
# if [[ $response != $expected ]]; then
# echo "TEST FAILED"
# printf "expected: $expected\ngot: $response\n"
# else
# echo "TEST PASSED"
# fi
echo "Stopping test container"
docker exec $container_id openresty -p /opt/app -s stop
is_running=$(docker inspect -f '{{.State.Running}}' $container_id)
if [[ $is_running == "true" ]]; then
echo "Warning: Docker reports test container is still running"
else
echo "Test container stopped"
fi