Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add DB schema version check
Also disabled auto-restart of midPoint (causes problems
if midPoint cannot be started).
mederly committed Sep 29, 2018
1 parent 5e531e0 commit 71a5607
Showing 4 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.sh
@@ -30,7 +30,7 @@ echo ""
echo "(for simple demo)"
echo ""
echo "$ cd" $(normalize_path `pwd`/../demo/simple)
echo "$ docker-compose up --build"
echo "$ docker-compose up"
echo ""
echo "(for complex demo)"
echo ""
2 changes: 1 addition & 1 deletion container_files/supervisor/supervisord.conf
@@ -16,10 +16,10 @@ command=/bin/bash -c "/usr/local/bin/start-midpoint.sh"
stdout_logfile=/dev/fd/2
stdout_logfile_maxbytes=0
redirect_stderr=true
autorestart=false

[program:crond]
command=/usr/sbin/crond -n -i -m off
stdout_logfile=/tmp/logcrond
stdout_logfile_maxbytes=0
redirect_stderr=true
autorestart=false
13 changes: 13 additions & 0 deletions demo/simple/tests/main.bats
@@ -50,6 +50,19 @@ load ../../../library
search_and_check_object users test300
}

@test "350 Test DB schema version check" {
echo "Removing version information from m_global_metadata"
docker exec simple_midpoint-data_1 mysql -p123321 registry -e "delete from m_global_metadata"

echo "Bringing the containers down"
docker-compose down

echo "Re-creating the containers"
docker-compose up -d

wait_for_log_message simple_midpoint-server_1 "com.evolveum.midpoint.util.exception.SystemException: Existing database schema version could not be determined"
}

@test "999 Clean up" {
docker-compose down -v
}
30 changes: 21 additions & 9 deletions library.bash
@@ -4,34 +4,46 @@
# Contains common functions usable for midPoint system tests
#

# Waits until midPoint starts
function wait_for_midpoint_start () {
# do not use from outside (ugly signature)
function generic_wait_for_log () {
CONTAINER_NAME=$1
DATABASE_CONTAINER_NAME=$2
MESSAGE="$2"
WAITING_FOR="$3"
FAILURE="$4"
ADDITIONAL_CONTAINER_NAME=$5
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) ..."
echo "Waiting $DELAY seconds for $WAITING_FOR (attempt $ATTEMPT) ..."
sleep $DELAY
docker ps
( docker logs $CONTAINER_NAME 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && return 0
( docker logs $CONTAINER_NAME 2>&1 | grep "$MESSAGE" ) && return 0
done

echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME
echo "$FAILURE" in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME
echo "========== Container log =========="
docker logs $CONTAINER_NAME 2>&1
echo "========== End of the container log =========="
if [ -n "$DATABASE_CONTAINER_NAME" ]; then
echo "========== Container log ($DATABASE_CONTAINER_NAME) =========="
docker logs $DATABASE_CONTAINER_NAME 2>&1
if [ -n "ADDITIONAL_CONTAINER_NAME" ]; then
echo "========== Container log ($ADDITIONAL_CONTAINER_NAME) =========="
docker logs $ADDITIONAL_CONTAINER_NAME 2>&1
echo "========== End of the container log ($DATABASE_CONTAINER_NAME) =========="
fi
return 1
}

function wait_for_log_message () {
generic_wait_for_log $1 "$2" "log message" "log message has not appeared"
}

# Waits until midPoint starts
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
}

# Checks the health of midPoint server
function check_health () {
echo Checking health...

0 comments on commit 71a5607

Please sign in to comment.