Skip to content

Commit

Permalink
Do first attempt at testing midPoint container
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 26, 2018
1 parent 91fd1bd commit 8a2e11c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ pipeline {
steps {
script {
sh 'midpoint/download-midpoint'
docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") {
docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") {
def baseImg = docker.build("$maintainer/$imagename", "--no-cache midpoint/midpoint-server")
// test the environment
// sh 'cd test-compose && ./compose.sh'
// bring down after testing
// sh 'cd test-compose && docker-compose down'
sh './test.sh'
baseImg.push("$tag")
}
}
Expand Down
22 changes: 22 additions & 0 deletions midpoint/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

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

cd "$(dirname "$0")"
. ../test/common.sh

yellow "*** Composing midPoint..."
docker-compose up --no-start
green "==> midPoint composed OK"
echo
yellow "*** Starting midPoint..."
docker-compose start
green "==> midPoint started OK"
echo
yellow "*** Waiting for midPoint to start..."
test/wait-for-start.sh
green "==> midPoint started"
echo
yellow "*** Checking health via HTTP..."
(set -o pipefail ; curl -k -f https://localhost:8443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"")
green "==> Health is OK"
16 changes: 16 additions & 0 deletions midpoint/test/wait-for-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

ATTEMPT=0
MAX_ATTEMPTS=20
DELAY=10

until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do
ATTEMPT=$((ATTEMPT+1))
echo "Waiting $DELAY seconds for midPoint to start (attempt $ATTEMPT) ..."
sleep $DELAY
docker ps
( docker logs midpoint_midpoint-server_1 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && exit 0
done

echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds
exit 1
10 changes: 10 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

. test/common.sh

trap 'exitcode=$? ; red "Exiting test.sh because of an error ($exitcode) occurred" ; exit $exitcode' ERR
echo "**************************************************************************************"
echo "*** Testing midPoint image ***"
echo "**************************************************************************************"
echo
midpoint/test.sh
18 changes: 18 additions & 0 deletions test/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

RED='\033[1;31m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
NC='\033[0m'

function red () {
echo -e ${RED}$*${NC}
}

function yellow () {
echo -e ${YELLOW}$*${NC}
}

function green () {
echo -e ${GREEN}$*${NC}
}

0 comments on commit 8a2e11c

Please sign in to comment.