Adds tests \o/

This commit is contained in:
pierreozoux 2014-11-07 15:33:54 +00:00
parent 5d6d254461
commit 11cf094cb5
4 changed files with 77 additions and 0 deletions

8
tests/clean-image.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash -eux
image=$1
/data/indiehosters/tests/runtime-clean-image.sh $image
rm -rf /data/domains/$image.test
ssh core@backup.dev "rm -rf $image.test"

40
tests/image.sh Executable file
View file

@ -0,0 +1,40 @@
#!/bin/bash -eux
cp /data/indiehosters/unit-files/* /etc/systemd/system && sudo systemctl daemon-reload
image=$1
# prepare data
mkdir -p /data/import/$image.test/TLS
cp /data/indiehosters/scripts/unsecure-certs/example.dev.pem /data/import/$image.test/TLS/$image.test.pem
if [ "$image" == "static-git" ]; then
mkdir -p /data/import/$image.test/static-git
echo "https://github.com/indiehosters/website.git" > /data/import/$image.test/static-git/GITURL
fi
# start image from import
systemctl start $image@$image.test
if [ "$image" == "wordpress" ]; then
sleep 40
else
sleep 10
fi
# tests
systemctl list-units | grep "$image\.test" | grep -c failed | grep 0
ip=`docker inspect --format {{.NetworkSettings.IPAddress}} $image-$image.test`
curl -L $ip
# start image from backup
/data/indiehosters/tests/runtime-clean-image.sh $image
if [ "$image" == "wordpress" ]; then
echo should fail until implementation of mysql backup importer
fi
systemctl start $image@$image.test
sleep 10
# tests
systemctl list-units | grep "$image\.test" | grep -c failed | grep 0
ip=`docker inspect --format {{.NetworkSettings.IPAddress}} $image-$image.test`
curl $ip

19
tests/main.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash -eux
# testing static
/data/indiehosters/tests/image.sh static
# clean static tests
/data/indiehosters/tests/clean-image.sh static
# testing static-git
/data/indiehosters/tests/image.sh static-git
# clean static tests
/data/indiehosters/tests/clean-image.sh static-git
# testing wordpress
/data/indiehosters/tests/image.sh wordpress
# clean static tests
/data/indiehosters/tests/clean-image.sh wordpress

10
tests/runtime-clean-image.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash -eux
image=$1
systemctl stop *@$image.test.timer
systemctl stop *@$image.test
systemctl reset-failed
systemctl list-units | grep -c "$image\.test" | grep 0
rm -rf /data/import/$image.test
rm -rf /data/runtime/domains/$image.test