Skip to content

Commit

Permalink
Fix Jenkinsfile and tests
Browse files Browse the repository at this point in the history
1) There's now a cleanup step before and after running the tests
2) Tests check their results more thoroughly
3) Until MariaDB is changed, a temporary solution for down-up issue is present
  • Loading branch information
mederly committed Sep 26, 2018
1 parent 2c7854a commit 9162ece
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ pipeline {
sh 'midpoint/download-midpoint'
docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") {
def baseImg = docker.build("$maintainer/$imagename", "--no-cache midpoint/midpoint-server")
sh 'env NOCOLOR=true ./test.sh'
try {
sh 'env NOCOLOR=true ./test.sh'
} finally {
sh './cleanup.sh'
}
baseImg.push("$tag")
}
}
Expand Down
3 changes: 3 additions & 0 deletions cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

midpoint/cleanup.sh
6 changes: 6 additions & 0 deletions midpoint/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cd "$(dirname "$0")"
echo "Cleaning up containers and images in `pwd`"

docker-compose down -v
4 changes: 2 additions & 2 deletions midpoint/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ services:
volumes:
- midpoint_mysql:/var/lib/mysql
- midpoint_data:/var/lib/mysqlmounted
environment:
- CREATE_NEW_DATABASE=if_needed
# environment:
# - CREATE_NEW_DATABASE=if_needed

midpoint-server:
build: ./midpoint-server/
Expand Down
5 changes: 5 additions & 0 deletions midpoint/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ trap 'exitcode=$? ; error "Exiting midpoint/test.sh because of an error ($exitco
cd "$(dirname "$0")"
. ../test/common.sh

heading "Cleaning up containers and volumes if they exist"
docker-compose down -v || true
ok "Done"
echo

heading "Composing midPoint..."
docker-compose up --no-start
ok "midPoint composed OK"
Expand Down
3 changes: 3 additions & 0 deletions midpoint/test/t110-get-administrator.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR
. ../test/common.sh

curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/users/00000000-0000-0000-0000-000000000002" >/tmp/admin.xml
grep -q "<name>administrator</name>" </tmp/admin.xml || (echo "User 'administrator' was not found or not retrieved correctly" ; exit 1)
rm /tmp/admin.xml
2 changes: 1 addition & 1 deletion midpoint/test/t120-add-get-user.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

trap 'exitcode=$? ; error "Exiting because of an error ($exitcode) occurred" ; exit $exitcode' ERR
trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR
. ../test/common.sh

echo "Adding user 'test120'..."
Expand Down
2 changes: 1 addition & 1 deletion midpoint/test/t200-stop-start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

trap 'exitcode=$? ; error "Exiting because of an error ($exitcode) occurred" ; exit $exitcode' ERR
trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR
. ../test/common.sh

echo "Stopping containers..."
Expand Down
2 changes: 1 addition & 1 deletion midpoint/test/t300-repository-preservation.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

USER=test300
trap 'exitcode=$? ; error "Exiting because of an error ($exitcode) occurred" ; exit $exitcode' ERR
trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR
. ../test/common.sh

echo "Adding user '${USER}'..."
Expand Down

0 comments on commit 9162ece

Please sign in to comment.