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,11 @@
FROM centos:5.11
RUN yum install -y wget && \
yum install -y system-config-services && \
yum install -y curl && \
wget --no-cookies \
--no-check-certificate \
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
--output-document jdk.rpm \
http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.rpm && \
yum --nogpg localinstall -y jdk.rpm && \
rm -f jdk.rpm

View File

@@ -0,0 +1,11 @@
FROM centos:6.7
RUN yum install -y wget && \
yum install -y system-config-services && \
yum install -y curl && \
wget --no-cookies \
--no-check-certificate \
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
--output-document jdk.rpm \
http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.rpm && \
yum --nogpg localinstall -y jdk.rpm && \
rm -f jdk.rpm

View File

@@ -0,0 +1,8 @@
FROM ubuntu:14.04.3
RUN apt-get install -y software-properties-common && \
add-apt-repository ppa:webupd8team/java -y && \
apt-get update && \
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y oracle-java8-installer && \
apt-get install -y curl && \
apt-get clean

View File

@@ -0,0 +1,13 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

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
}