Skip to content
Permalink
Browse files

adding of waiting and check functions for shibboleth idp

  • Loading branch information
skublik committed Sep 28, 2018
1 parent d19dfc4 commit baca108dd0c49160832a6cd9e7b6a4347f4be73a
Showing with 46 additions and 2 deletions.
  1. +7 −1 demo/complex/tests/main.bats
  2. +39 −1 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
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
@@ -8,7 +8,7 @@
function wait_for_midpoint_start () {
CONTAINER_NAME=$1
ATTEMPT=0
MAX_ATTEMPTS=20
MAX_ATTEMPTS=30
DELAY=10

until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do
@@ -26,6 +26,29 @@ function wait_for_midpoint_start () {
return 1
}

# Waits until Shibboleth IDP starts
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...
@@ -41,6 +64,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 baca108

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