Skip to content

Commit

Permalink
Adding first test of Tomcat service in container, let's get the test …
Browse files Browse the repository at this point in the history
…host ready
  • Loading branch information
Jim Van Fleet committed Aug 4, 2016
1 parent 92d47f9 commit 20d363e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

}

Expand Down
6 changes: 6 additions & 0 deletions bin/ci-run.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions bin/ci-stop.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 6 additions & 5 deletions tests/running.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" != '' ]
}

0 comments on commit 20d363e

Please sign in to comment.