Skip to content
Permalink
Browse files

Add auto-upgrade support

  • Loading branch information
mederly committed Oct 1, 2018
1 parent 4c5e895 commit ceafa77a75096781e1e9191372f7f08ebe567754
@@ -68,6 +68,8 @@ ENV REPO_DATABASE midpoint
ENV REPO_JDBC_URL default
ENV REPO_PASSWORD_FILE /run/secrets/m_database_password.txt
ENV REPO_DATABASE_TYPE mariadb
ENV REPO_MISSING_SCHEMA_ACTION create
ENV REPO_UPGRADEABLE_SCHEMA_ACTION stop

# Logging parameters

@@ -1,27 +1,24 @@
#!/bin/bash

if [ "$AUTHENTICATION" = "shibboleth" ]; then
LOGOUT_URL_DIRECTIVE="-Dauth.logout.url=$LOGOUT_URL"
else
LOGOUT_URL_DIRECTIVE=
fi

java -Xmx$MEM -Xms2048m -Dfile.encoding=UTF8 \
-Dmidpoint.home=$MP_DIR/var \
-Dmidpoint.repository.database=$REPO_DATABASE_TYPE \
-Dmidpoint.repository.jdbcUsername=$REPO_USER \
-Dmidpoint.repository.jdbcPassword_FILE=$REPO_PASSWORD_FILE \
-Dmidpoint.repository.jdbcUrl="`$MP_DIR/repository-url`" \
-Dmidpoint.repository.hibernateHbm2ddl=none \
-Dmidpoint.repository.missingSchemaAction=create \
-Dmidpoint.repository.missingSchemaAction=$REPO_MISSING_SCHEMA_ACTION \
-Dmidpoint.repository.upgradeableSchemaAction=$REPO_UPGRADEABLE_SCHEMA_ACTION \
$(if [ -n "$REPO_SCHEMA_VERSION_IF_MISSING" ]; then echo "-Dmidpoint.repository.schemaVersionIfMissing=$REPO_SCHEMA_VERSION_IF_MISSING"; fi) \
$(if [ -n "$REPO_SCHEMA_VARIANT" ]; then echo "-Dmidpoint.repository.schemaVariant=$REPO_SCHEMA_VARIANT"; fi) \
-Dmidpoint.repository.initializationFailTimeout=60000 \
-Dmidpoint.keystore.keyStorePassword_FILE=$KEYSTORE_PASSWORD_FILE \
-Dmidpoint.logging.alt.enabled=true \
-Dmidpoint.logging.alt.filename=/tmp/logmidpoint \
-Dmidpoint.logging.alt.timezone=UTC \
-Dspring.profiles.active="`$MP_DIR/active-spring-profiles`" \
-Dauth.sso.header=$SSO_HEADER \
$LOGOUT_URL_DIRECTIVE \
$(if [ "$AUTHENTICATION" = "shibboleth" ]; then echo "-Dauth.logout.url=$LOGOUT_URL"; fi) \
-Dserver.tomcat.ajp.enabled=$AJP_ENABLED \
-Dserver.tomcat.ajp.port=$AJP_PORT \
-Dlogging.path=/tmp/logtomcat \
@@ -7,6 +7,8 @@ REPO_HOST=midpoint-data
REPO_PORT=default
REPO_DATABASE=registry
REPO_USER=registry_user
REPO_MISSING_SCHEMA_ACTION=create
REPO_UPGRADEABLE_SCHEMA_ACTION=stop
REPO_PASSWORD_FILE=/run/secrets/m_database_password.txt
KEYSTORE_PASSWORD_FILE=/run/secrets/m_keystore_password.txt
MEM=2048m
@@ -84,75 +84,6 @@ services:
source: ./configs-and-secrets/grouper/httpd/host-cert.pem
target: /etc/pki/tls/certs/cachain.pem


# grouper-ws:
# build: ./grouper-ws/
# command: bash -c "while ! curl -s grouper-data:3306 > /dev/null; do echo waiting for mysql on grouper-data to start; sleep 3; done; while ! curl -s ldap://directory:389 > /dev/null; do echo waiting for ldap on directory to start; sleep 3; done; exec ws"
# depends_on:
# - grouper-data
# - directory
# environment:
# - ENV=dev
# - GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/g_database_password.txt
# - SUBJECT_SOURCE_LDAP_PASSWORD=password
# - USERTOKEN=build-2
# networks:
# - back
# ports:
# - "8443:443"
# secrets:
# - g_database_password.txt
# - source: grouper.hibernate.properties
# target: grouper_grouper.hibernate.properties
# - source: grouper-loader.properties
# target: grouper_grouper-loader.properties
# - source: subject.properties
# target: grouper_subject.properties
# - source: sp-key.pem
# target: shib_sp-key.pem
# - source: host-key.pem
# volumes:
# - type: bind
# source: ./configs-and-secrets/grouper/grouper.properties
# target: /opt/grouper/conf/grouper.properties
# - type: bind
# source: ./configs-and-secrets/grouper/grouper.client.properties
# target: /opt/grouper/conf/grouper.client.properties
# - type: bind
# source: ./configs-and-secrets/httpd/host-cert.pem
# target: /etc/pki/tls/certs/host-cert.pem
# - type: bind
# source: ./configs-and-secrets/httpd/host-cert.pem
# target: /etc/pki/tls/certs/cachain.pem
#
# gsh:
# build: ./gsh/
# depends_on:
# - grouper-data
# - directory
# environment:
# - ENV=dev
# - GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/g_database_password.txt
# - SUBJECT_SOURCE_LDAP_PASSWORD=password
# - USERTOKEN=build-2
# networks:
# - back
# secrets:
# - g_database_password.txt
# - source: grouper.hibernate.properties
# target: grouper_grouper.hibernate.properties
# - source: grouper-loader.properties
# target: grouper_grouper-loader.properties
# - source: subject.properties
# target: grouper_subject.properties
# volumes:
# - type: bind
# source: ./configs-and-secrets/grouper/grouper.properties
# target: /opt/grouper/conf/grouper.properties
# - type: bind
# source: ./configs-and-secrets/grouper/grouper.client.properties
# target: /opt/grouper/conf/grouper.client.properties

grouper-data:
build: ./grouper-data/
networks:
@@ -215,6 +146,10 @@ services:
- REPO_DATABASE
- REPO_USER
- REPO_PASSWORD_FILE
- REPO_MISSING_SCHEMA_ACTION
- REPO_UPGRADEABLE_SCHEMA_ACTION
- REPO_SCHEMA_VERSION_IF_MISSING
- REPO_SCHEMA_VARIANT
- KEYSTORE_PASSWORD_FILE
- MEM
- SSO_HEADER
@@ -8,4 +8,5 @@ REPO_HOST=midpoint-data
REPO_PORT=default
REPO_DATABASE=registry
REPO_USER=registry_user
REPO_MISSING_SCHEMA_ACTION=create
MEM=2048m
@@ -27,6 +27,10 @@ services:
- REPO_PORT
- REPO_DATABASE
- REPO_USER
- REPO_MISSING_SCHEMA_ACTION
- REPO_UPGRADEABLE_SCHEMA_ACTION
- REPO_SCHEMA_VERSION_IF_MISSING
- REPO_SCHEMA_VARIANT
- MEM
- TIER_BEACON_OPT_OUT
networks:
@@ -63,6 +63,27 @@ load ../../../library
wait_for_log_message simple_midpoint-server_1 "Database schema is not compatible with the executing code; however, an upgrade path is available."
}

@test "360 Test DB schema upgrade" {
echo "Stopping midpoint-server container"
docker stop simple_midpoint-server_1

echo "Installing empty 3.8 repository"
docker exec simple_midpoint-data_1 mysql -p123321 -e "DROP DATABASE registry"
docker exec simple_midpoint-data_1 bash -c " curl https://raw.githubusercontent.com/Evolveum/midpoint/v3.8/config/sql/_all/mysql-3.8-all-utf8mb4.sql > /tmp/create-3.8-utf8mb4.sql"
docker exec simple_midpoint-data_1 mysql -p123321 -e "CREATE DATABASE IF NOT EXISTS registry;"
docker exec simple_midpoint-data_1 mysql -p123321 -e "GRANT ALL ON registry.* TO 'registry_user'@'%' IDENTIFIED BY 'WJzesbe3poNZ91qIbmR7' ;"
docker exec simple_midpoint-data_1 bash -c "mysql -p123321 registry < /tmp/create-3.8-utf8mb4.sql"

echo "Bringing the containers down"
docker-compose down

echo "Re-creating the containers"
env REPO_SCHEMA_VERSION_IF_MISSING=3.8 REPO_UPGRADEABLE_SCHEMA_ACTION=upgrade REPO_SCHEMA_VARIANT=utf8mb4 docker-compose up -d

wait_for_log_message simple_midpoint-server_1 "Schema was successfully upgraded from 3.8 to 3.9 using script 'mysql-upgrade-3.8-3.9-utf8mb4.sql'"
wait_for_midpoint_start simple_midpoint-server_1
}

@test "999 Clean up" {
docker-compose down -v
}

0 comments on commit ceafa77

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