diff --git a/Jenkinsfile b/Jenkinsfile index 801552a..f39c25c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,6 +36,7 @@ pipeline { try { sh './download-midpoint &> debug' sh 'bin/rebuild.sh &>> debug' + sh 'echo Build output ; cat debug' } catch (error) { def error_details = readFile('./debug') def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" @@ -50,6 +51,7 @@ pipeline { script { try { sh 'bin/test.sh &> debug' + sh '(cd demo/simple ; bats tests ) &>> debug' sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats new file mode 100755 index 0000000..eec4945 --- /dev/null +++ b/demo/simple/tests/main.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../../library + +@test "000 Initialize and start midPoint" { + run docker-compose down -v + docker-compose up -d + wait_for_midpoint_start simple_midpoint-server_1 +} + +@test "999 Clean up" { + docker-compose down -v +} diff --git a/library.bash b/library.bash new file mode 100644 index 0000000..1cfbdaf --- /dev/null +++ b/library.bash @@ -0,0 +1,18 @@ +#!/bin/bash + +function wait_for_midpoint_start () { + 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 $1 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && return 0 + done + + echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds + return 1 +}