diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 89b08f4..129bfa9 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -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 diff --git a/library.bash b/library.bash index 9ed8046..5d093a3 100644 --- a/library.bash +++ b/library.bash @@ -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