From b8902f2a0b313fdb577c75d4325cbb639ca03d15 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 4 Aug 2016 13:15:05 -0400 Subject: [PATCH 1/6] Process attempts to start but hangs --- Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e110912..6187fa0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,14 @@ -FROM bigfleet/shibboleth_idp +FROM bigfleet/shibboleth_idp:master ARG maintainer=tier ARG imagename=shibboleth_idp ARG version=3.2.1 ENV VERSION=$version -RUN chown -R root:root /opt/shibboleth/shibboleth-identity-provider-$version +RUN chown -R root:root /opt/shibboleth/shibboleth-identity-provider-$version && \ + ANT_OPTS="-Didp.target.dir=/opt/shibboleth/current" /opt/shibboleth/current/bin/build.sh && \ + ln -s /opt/shibboleth/current /opt/shibboleth-idp && \ + ln -s /opt/shibboleth-idp/war/idp.war $CATALINA_HOME/webapps/idp.war EXPOSE 8080 CMD ["catalina.sh", "run"] \ No newline at end of file From 92d47f98e170f6de0bc1a67aadfc5118597bc11c Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 4 Aug 2016 13:45:28 -0400 Subject: [PATCH 2/6] Shib IDP boots --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 6187fa0..61aef7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ ARG maintainer=tier ARG imagename=shibboleth_idp ARG version=3.2.1 ENV VERSION=$version +ENV JAVA_OPTS=-Xmx1500m -XX:MaxPermSize=128m RUN chown -R root:root /opt/shibboleth/shibboleth-identity-provider-$version && \ ANT_OPTS="-Didp.target.dir=/opt/shibboleth/current" /opt/shibboleth/current/bin/build.sh && \ From 20d363ed4cd17f553f8f5289ea77e19d51a88088 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 4 Aug 2016 14:12:25 -0400 Subject: [PATCH 3/6] Adding first test of Tomcat service in container, let's get the test host ready --- Jenkinsfile | 8 ++++++++ bin/ci-run.sh | 6 ++++++ bin/ci-stop.sh | 9 +++++++++ tests/running.bats | 11 ++++++----- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100755 bin/ci-run.sh create mode 100755 bin/ci-stop.sh diff --git a/Jenkinsfile b/Jenkinsfile index 15e20f8..97ab163 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,10 +36,18 @@ node { } sh 'bin/rebuild.sh' + + stage 'Start container' + + sh 'bin/ci-run.sh' stage 'Tests' sh 'bin/test.sh' + // should build a finally construct here + stage 'Stop container' + + sh 'bin/ci-stop.sh' } diff --git a/bin/ci-run.sh b/bin/ci-run.sh new file mode 100755 index 0000000..755e216 --- /dev/null +++ b/bin/ci-run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# This file will run a container in the background +source common.bash . + +docker run -d --name=$imagename -p 8080:8080 $maintainer/$imagename \ No newline at end of file diff --git a/bin/ci-stop.sh b/bin/ci-stop.sh new file mode 100755 index 0000000..2ac6a32 --- /dev/null +++ b/bin/ci-stop.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# This file will run a container in the background +source common.bash . + +echo "Cleaning up Docker image($maintainer/$imagename)" +docker stop $imagename >> /dev/null +docker rm $imagename +exit 0 \ No newline at end of file diff --git a/tests/running.bats b/tests/running.bats index 00c9e23..15421a4 100644 --- a/tests/running.bats +++ b/tests/running.bats @@ -2,14 +2,15 @@ load ../common -setup() { - bin/start.sh -} +# These tests assume the pipeline will start and stop the container. @test "Leaves running process" { result="$(docker ps | grep $imagename)" [ "$result" != '' ] } -teardown() { - bin/stop.sh + +@test "Exposes running Tomcat service" { + result="$(docker exec -i $imagename curl http://localhost:8080/)" + [ "$result" != '' ] } + From 8f81a4a2e6a9642a74a258bd971df4e87805978f Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 4 Aug 2016 14:12:48 -0400 Subject: [PATCH 4/6] Ensuring we run on worker --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 97ab163..06d5e19 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -node { +node('docker') { stage 'Checkout' From 4fe18da91a052686a782e1f8323d408d19054e83 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 4 Aug 2016 16:34:06 -0400 Subject: [PATCH 5/6] Tests run, include Shibboleth running --- Dockerfile | 3 ++- tests/image.bats | 5 +++++ tests/running.bats | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 61aef7e..a71e161 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,10 @@ ENV VERSION=$version ENV JAVA_OPTS=-Xmx1500m -XX:MaxPermSize=128m RUN chown -R root:root /opt/shibboleth/shibboleth-identity-provider-$version && \ + rm -rf /usr/local/tomcat/webapps/* && \ ANT_OPTS="-Didp.target.dir=/opt/shibboleth/current" /opt/shibboleth/current/bin/build.sh && \ ln -s /opt/shibboleth/current /opt/shibboleth-idp && \ - ln -s /opt/shibboleth-idp/war/idp.war $CATALINA_HOME/webapps/idp.war + ln -s /opt/shibboleth-idp/war/idp.war $CATALINA_HOME/webapps/ROOT.war EXPOSE 8080 CMD ["catalina.sh", "run"] \ No newline at end of file diff --git a/tests/image.bats b/tests/image.bats index 81a7bee..e3d24d2 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -21,3 +21,8 @@ load ../common result="$(docker run -i $maintainer/$imagename stat -c '%U' /opt/shibboleth/current/logs)" [ "$result" != 'UNKNOWN' ] } + +@test "Other Tomcat webapps removed" { + result="$(docker run -i $maintainer/$imagename find /usr/local/tomcat/webapps -type d -print0)" + [ "$result" == '/usr/local/tomcat/webapps' ] +} diff --git a/tests/running.bats b/tests/running.bats index 15421a4..d1c9b16 100644 --- a/tests/running.bats +++ b/tests/running.bats @@ -14,3 +14,6 @@ load ../common [ "$result" != '' ] } +@test "Service is Shibboleth" { + docker exec -i $imagename curl -silent http://localhost:8080/ | grep 'Shibboleth' +} From 1c3cd6a12e2ff0eea77a7132c141f7649eb04ad5 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 4 Aug 2016 16:36:59 -0400 Subject: [PATCH 6/6] 60 seconds to wait for boot-- we should replace this --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 06d5e19..cff36c8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,7 +39,7 @@ node('docker') { stage 'Start container' - sh 'bin/ci-run.sh' + sh 'bin/ci-run.sh && sleep 60' stage 'Tests'