Skip to content
Permalink
Browse files

Merge branch 'bats' of https://github.internet2.edu/docker/midPoint_c…

…ontainer into bats

# Conflicts:
#	library.bash
  • Loading branch information
mederly committed Sep 29, 2018
2 parents 71a5607 + 7931731 commit 0e78e7f27fc417695a66d38f919ad7dd5eb46280
Showing with 46 additions and 1 deletion.
  1. +7 −1 demo/complex/tests/main.bats
  2. +39 −0 library.bash
@@ -20,15 +20,21 @@ load ../../../library
@test "020 Wait until components are started" {
touch $BATS_TMPDIR/not-started
wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1
wait_for_shibboleth_idp_start complex_idp_1
rm $BATS_TMPDIR/not-started
# TODO wait for shibboleth, grouper-ui, (also something other?)
}

@test "050 Check midPoint health" {
@test "040 Check midPoint health" {
if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi
check_health
}

@test "050 Check Shibboleth IDP health" {
if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi
check_health_shibboleth_idp
}

@test "060 Check Grouper health" {
if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi
skip TODO
@@ -35,6 +35,7 @@ function generic_wait_for_log () {
return 1
}


function wait_for_log_message () {
generic_wait_for_log $1 "$2" "log message" "log message has not appeared"
}
@@ -44,6 +45,29 @@ function wait_for_midpoint_start () {
generic_wait_for_log $1 "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" "midPoint to start" "midPoint did not start" $2
}

# Waits until Shibboleth IDP starts ... TODO refactor using generic waiting function
function wait_for_shibboleth_idp_start () {
CONTAINER_NAME=$1
ATTEMPT=0
MAX_ATTEMPTS=20
DELAY=10

until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do
ATTEMPT=$((ATTEMPT+1))
echo "Waiting $DELAY seconds for Shibboleth IDP to start (attempt $ATTEMPT) ..."
sleep $DELAY
docker ps
( docker logs $CONTAINER_NAME 2>&1 | grep "INFO:oejs.Server:main: Started" ) && return 0
done

echo Shibboleth IDP did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME
echo "========== Container log =========="
docker logs $CONTAINER_NAME 2>&1
echo "========== End of the container log =========="
return 1
}


# Checks the health of midPoint server
function check_health () {
echo Checking health...
@@ -59,6 +83,21 @@ function check_health () {
fi
}

# Checks the health of Shibboleth IDP server
function check_health_shibboleth_idp () {
echo Checking health of shibboleth idp...
status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:4443/idp/)"
if [ $status -ne 200 ]; then
echo Error: Http code of response is $status
docker ps
return 1
else
echo OK
return 0
fi
}


# Retrieves XML object and checks if the name matches
function get_and_check_object () {
TYPE=$1

0 comments on commit 0e78e7f

Please sign in to comment.
You can’t perform that action at this time.