Add integration tests for default launch script

This commit adds a suit of integration tests for the launch script. See
the accompanying README.adoc for further details.

Closes gh-4872
This commit is contained in:
Andy Wilkinson
2016-01-11 18:01:15 +00:00
parent c39a55a270
commit d1b47c8a8f
27 changed files with 753 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
source ./test-functions.sh
install_service
start_service
await_app
curl -s http://127.0.0.1:8080/

View File

@@ -0,0 +1,5 @@
source ./test-functions.sh
install_service
start_service --server.port=8081 --server.context-path=/test
await_app http://127.0.0.1:8081/test/
curl -s http://127.0.0.1:8081/test/

View File

@@ -0,0 +1,6 @@
source ./test-functions.sh
echo 'JAVA_OPTS="-Dserver.port=8081 -Dserver.context-path=/test"' > /spring-boot-app.conf
install_service
start_service
await_app http://127.0.0.1:8081/test/
curl -s http://127.0.0.1:8081/test/

View File

@@ -0,0 +1,6 @@
source ./test-functions.sh
echo 'RUN_ARGS="--server.port=8081 --server.context-path=/test"' > /spring-boot-app.conf
install_service
start_service
await_app http://127.0.0.1:8081/test/
curl -s http://127.0.0.1:8081/test/

View File

@@ -0,0 +1,5 @@
source ./test-functions.sh
install_service
start_service --server.port=8081
await_app http://127.0.0.1:8081/
curl -s http://127.0.0.1:8081/

View File

@@ -0,0 +1,6 @@
source ./test-functions.sh
echo 'JAVA_OPTS=-Dserver.port=8081' > /spring-boot-app.conf
install_service
start_service
await_app http://127.0.0.1:8081/
curl -s http://127.0.0.1:8081/

View File

@@ -0,0 +1,6 @@
source ./test-functions.sh
echo 'RUN_ARGS=--server.port=8081' > /spring-boot-app.conf
install_service
start_service
await_app http://127.0.0.1:8081/
curl -s http://127.0.0.1:8081/

View File

@@ -0,0 +1,7 @@
source ./test-functions.sh
install_service
start_service
echo "PID1: $(cat /var/run/spring-boot-app/spring-boot-app.pid)"
restart_service
echo "Status: $?"
echo "PID2: $(cat /var/run/spring-boot-app/spring-boot-app.pid)"

View File

@@ -0,0 +1,5 @@
source ./test-functions.sh
install_service
restart_service
echo "Status: $?"
echo "PID: $(cat /var/run/spring-boot-app/spring-boot-app.pid)"

View File

@@ -0,0 +1,6 @@
source ./test-functions.sh
install_service
start_service
echo "PID: $(cat /var/run/spring-boot-app/spring-boot-app.pid)"
start_service
echo "Status: $?"

View File

@@ -0,0 +1,5 @@
source ./test-functions.sh
install_service
start_service
echo "Status: $?"
echo "PID: $(cat /var/run/spring-boot-app/spring-boot-app.pid)"

View File

@@ -0,0 +1,8 @@
source ./test-functions.sh
install_service
start_service
pid=$(cat /var/run/spring-boot-app/spring-boot-app.pid)
echo "PID: $pid"
kill -9 $pid
status_service
echo "Status: $?"

View File

@@ -0,0 +1,6 @@
source ./test-functions.sh
install_service
start_service
status_service
echo "Status: $?"
echo "PID: $(cat /var/run/spring-boot-app/spring-boot-app.pid)"

View File

@@ -0,0 +1,4 @@
source ./test-functions.sh
install_service
status_service
echo "Status: $?"

View File

@@ -0,0 +1,4 @@
source ./test-functions.sh
install_service
stop_service
echo "Status: $?"

View File

@@ -0,0 +1,40 @@
install_service() {
mv /spring-boot-launch-script-tests-*.jar /spring-boot-app.jar
chmod +x /spring-boot-app.jar
ln -s /spring-boot-app.jar /etc/init.d/spring-boot-app
}
start_service() {
service spring-boot-app start $@
}
restart_service() {
service spring-boot-app restart
}
status_service() {
service spring-boot-app status
}
stop_service() {
service spring-boot-app stop
}
await_app() {
if [ -z $1 ]
then
url=http://127.0.0.1:8080
else
url=$1
fi
end=$(date +%s)
let "end+=30"
until curl -s $url > /dev/null
do
now=$(date +%s)
if [[ $now -ge $end ]]; then
break
fi
sleep 1
done
}