diff --git a/.travis.yml b/.travis.yml index 423797b3..45f89a81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,18 +4,8 @@ services: docker addons: hosts: - mariadb.example.com -# homebrew: -# packages: -# - openssl -# - libiodbc -# - mariadb before_install: - #- chmod +x .travis/script.sh - #- chmod +x .travis/osx.sh - #- chmod +x .travis/gen-ssl.sh - #- chmod +x .travis/build/build.sh - #- chmod +x .travis/build/docker-entrypoint.sh - chmod 777 .travis/build/ - export PROJ_PATH=`pwd` - export ENTRYPOINT=$PROJ_PATH/.travis/sql @@ -26,7 +16,7 @@ before_install: matrix: allow_failures: - os: linux - env: DB=mariadb:10.2 PACKET=8M MAXSCALE_VERSION=2.1.8 + env: DB=mariadb:10.5 PACKET=8M MAXSCALE_VERSION=2.5.3 - os: linux env: DB=build - os: linux @@ -39,11 +29,11 @@ matrix: env: DB=mariadb:10.5 - os: linux env: DB=mariadb:10.1 + - env: SKYSQL=true + - env: SKYSQL_HA=true MAXSCALE_TEST_DISABLE=true include: - os: linux - env: DB=build - - os: linux - env: DB=mariadb:10.1 + env: DB=build:10.6 - os: linux env: DB=mariadb:10.2 - os: linux @@ -56,18 +46,20 @@ matrix: - os: linux compiler: clang env: DB=mariadb:10.5 + - env: SKYSQL=true + - env: SKYSQL_HA=true MAXSCALE_TEST_DISABLE=true - os: osx compiler: gcc env: DB=mariadb:10.5 addons: - mariadb: '10.5' + mariadb: '10.4' before_script: - brew update - brew install openssl - brew install libiodbc - brew install mariadb - os: linux - env: DB=mariadb:10.2 PACKET=8M MAXSCALE_VERSION=2.1.8 + env: DB=mariadb:10.5 PACKET=8M MAXSCALE_VERSION=2.5.3 - os: linux env: DB=mysql:5.5 - os: linux @@ -76,7 +68,7 @@ matrix: env: DB=mysql:5.7 script: - - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$DB" = "build" ] ; then .travis/build/build.sh; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$DB" = "build" ] ; then docker build -t build:latest --label build .travis/build/; fi + - if [[ "$DB" == build* ]] ; then .travis/build/build.sh; fi + - if [[ "$DB" == build* ]] ; then docker build -t build:10.6 --label build .travis/build/; fi - if [ "$TRAVIS_OS_NAME" = "linux" ] ; then .travis/script.sh; fi - if [ "$TRAVIS_OS_NAME" = "osx" ]; then .travis/osx.sh; fi diff --git a/.travis/build/Dockerfile b/.travis/build/Dockerfile index f152504b..73042544 100644 --- a/.travis/build/Dockerfile +++ b/.travis/build/Dockerfile @@ -1,5 +1,5 @@ # vim:set ft=dockerfile: -FROM ubuntu:bionic +FROM ubuntu:xenial # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r mysql && useradd -r -g mysql mysql @@ -57,18 +57,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* RUN { \ - echo "mariadb-server-10.5" mysql-server/root_password password 'unused'; \ - echo "mariadb-server-10.5" mysql-server/root_password_again password 'unused'; \ + echo "mariadb-server-10.6" mysql-server/root_password password 'unused'; \ + echo "mariadb-server-10.6" mysql-server/root_password_again password 'unused'; \ } | debconf-set-selections RUN apt-get update -y RUN apt-get install -y software-properties-common wget -RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db -RUN apt-key adv --recv-keys --keyserver ha.pool.sks-keyservers.net F1656F24C74CD1D8 -RUN echo 'deb http://yum.mariadb.org/galera/repo/deb bionic main' > /etc/apt/sources.list.d/galera-test-repo.list -RUN apt-get update -y +#RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db +#RUN apt-key adv --recv-keys --keyserver ha.pool.sks-keyservers.net F1656F24C74CD1D8 +#RUN echo 'deb http://yum.mariadb.org/galera/repo/deb xenial main' > /etc/apt/sources.list.d/galera-test-repo.list +#RUN apt-get update -y + +RUN apt-get install -y curl libdbi-perl rsync socat libnuma1 libaio1 zlib1g-dev libreadline5 libjemalloc1 libsnappy1v5 libcrack2 -RUN apt-get install -y curl libdbi-perl rsync socat galera3 libnuma1 libaio1 zlib1g-dev libreadline5 libjemalloc1 libsnappy1v5 libcrack2 +#RUN apt-get install -y galera3 COPY *.deb /root/ RUN chmod 777 /root/* @@ -77,16 +79,17 @@ RUN dpkg --install /root/mysql-common* RUN dpkg --install /root/mariadb-common* RUN dpkg -R --unpack /root/ RUN apt-get install -f -y - +RUN ls -lrt /etc/mysql +RUN ls -lrt /etc/mysql/mariadb.conf.d RUN rm -rf /var/lib/apt/lists/* \ - && sed -ri 's/^user\s/#&/' /etc/mysql/my.cnf /etc/mysql/conf.d/* \ + && sed -ri 's/^user\s/#&/' /etc/mysql/my.cnf /etc/mysql/mariadb.conf.d/*.cnf \ && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \ && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \ && chmod 777 /var/run/mysqld \ && find /etc/mysql/ -name '*.cnf' -print0 \ | xargs -0 grep -lZE '^(bind-address|log)' \ | xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' \ - && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf + && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/mariadb.conf.d/docker.cnf VOLUME /var/lib/mysql diff --git a/.travis/build/build.sh b/.travis/build/build.sh index f4d4c85d..cd62d279 100755 --- a/.travis/build/build.sh +++ b/.travis/build/build.sh @@ -4,22 +4,22 @@ echo "************************************************************************** echo "* searching for last complete build" echo "**************************************************************************" -wget -q -o /dev/null index.html http://hasky.askmonty.org/archive/10.5/ +wget -q -o /dev/null index.html http://hasky.askmonty.org/archive/10.6/ grep -o ">build-[0-9]*" index.html | grep -o "[0-9]*" | tac | while read -r line ; do - curl -s --head http://hasky.askmonty.org/archive/10.5/build-$line/kvm-deb-bionic-amd64/md5sums.txt | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null + curl -s --head http://hasky.askmonty.org/archive/10.6/build-$line/kvm-deb-xenial-amd64/md5sums.txt | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null if [ $? = "0" ]; then echo "**************************************************************************" echo "* Processing $line" echo "**************************************************************************" - wget -q -o /dev/null -O $line.html http://hasky.askmonty.org/archive/10.5/build-$line/kvm-deb-bionic-amd64/debs/binary/ + wget -q -o /dev/null -O $line.html http://hasky.askmonty.org/archive/10.6/build-$line/kvm-deb-xenial-amd64/debs/binary/ grep -o ">[^\"]*\.deb" $line.html | grep -o "[^>]*\.deb" | while read -r file ; do if [[ "$file" =~ ^mariadb-plugin.* ]] ; then echo "skipped file: $file" else - echo "download file: $file" - wget -q -o /dev/null -O .travis/build/$file http://hasky.askmonty.org/archive/10.5/build-$line/kvm-deb-bionic-amd64/debs/binary/$file + echo "download file: http://hasky.askmonty.org/archive/10.6/build-$line/kvm-deb-xenial-amd64/debs/binary/$file" + wget -q -o /dev/null -O .travis/build/$file http://hasky.askmonty.org/archive/10.6/build-$line/kvm-deb-xenial-amd64/debs/binary/$file fi done diff --git a/.travis/build/docker-entrypoint.sh b/.travis/build/docker-entrypoint.sh index 721cc7d9..588f4788 100755 --- a/.travis/build/docker-entrypoint.sh +++ b/.travis/build/docker-entrypoint.sh @@ -2,21 +2,21 @@ set -eo pipefail shopt -s nullglob -# if command starts with an option, prepend mysqld -if [ "${1:0:1}" = '-' ]; then - set -- mysqld "$@" -fi - -# skip setup if they want an option that stops mysqld -wantHelp= -for arg; do - case "$arg" in - -'?'|--help|--print-defaults|-V|--version) - wantHelp=1 - break - ;; - esac -done +# logging functions +mysql_log() { + local type="$1"; shift + printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "$type" "$*" +} +mysql_note() { + mysql_log Note "$@" +} +mysql_warn() { + mysql_log Warn "$@" >&2 +} +mysql_error() { + mysql_log ERROR "$@" >&2 + exit 1 +} # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' @@ -27,8 +27,7 @@ file_env() { local fileVar="${var}_FILE" local def="${2:-}" if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then - echo >&2 "error: both $var and $fileVar are set (but are exclusive)" - exit 1 + mysql_error "Both $var and $fileVar are set (but are exclusive)" fi local val="$def" if [ "${!var:-}" ]; then @@ -40,157 +39,317 @@ file_env() { unset "$fileVar" } -_check_config() { - toRun=( "$@" --verbose --help --log-bin-index="$(mktemp -u)" ) +# check to see if this file is being run or sourced from another script +_is_sourced() { + # https://unix.stackexchange.com/a/215279 + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] +} + +# usage: docker_process_init_files [file [file [...]]] +# ie: docker_process_init_files /always-initdb.d/* +# process initializer files, based on file extensions +docker_process_init_files() { + # mysql here for backwards compatibility "${mysql[@]}" + mysql=( docker_process_sql ) + + echo + local f + for f; do + case "$f" in + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + mysql_note "$0: running $f" + "$f" + else + mysql_note "$0: sourcing $f" + . "$f" + fi + ;; + *.sql) mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;; + *.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;; + *.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;; + *) mysql_warn "$0: ignoring $f" ;; + esac + echo + done +} + +mysql_check_config() { + local toRun=( "$@" --verbose --help --log-bin-index="$(mktemp -u)" ) errors if ! errors="$("${toRun[@]}" 2>&1 >/dev/null)"; then - cat >&2 <<-EOM - ERROR: mysqld failed while attempting to check config - command was: "${toRun[*]}" - $errors - EOM - exit 1 + mysql_error $'mysqld failed while attempting to check config\n\tcommand was: '"${toRun[*]}"$'\n\t'"$errors" fi } # Fetch value from server config # We use mysqld --verbose --help instead of my_print_defaults because the # latter only show values present in config files, and not server defaults -_get_config() { +mysql_get_config() { local conf="$1"; shift "$@" --verbose --help --log-bin-index="$(mktemp -u)" 2>/dev/null \ - | awk '$1 == "'"$conf"'" && /^[^ \t]/ { sub(/^[^ \t]+[ \t]+/, ""); print; exit }' + | awk -v conf="$conf" '$1 == conf && /^[^ \t]/ { sub(/^[^ \t]+[ \t]+/, ""); print; exit }' # match "datadir /some/path with/spaces in/it here" but not "--xyz=abc\n datadir (xyz)" } -# allow the container to be started with `--user` -if [ "$1" = 'mysqld' -a -z "$wantHelp" -a "$(id -u)" = '0' ]; then - _check_config "$@" - DATADIR="$(_get_config 'datadir' "$@")" +# Do a temporary startup of the MySQL server, for init purposes +docker_temp_server_start() { + "$@" --skip-networking --socket="${SOCKET}" & + mysql_note "Waiting for server startup" + local i + for i in {30..0}; do + # only use the root password if the database has already been initializaed + # so that it won't try to fill in a password file when it hasn't been set yet + extraArgs=() + if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + extraArgs+=( '--dont-use-mysql-root-password' ) + fi + if docker_process_sql "${extraArgs[@]}" --database=mysql <<<'SELECT 1' &> /dev/null; then + break + fi + sleep 1 + done + if [ "$i" = 0 ]; then + mysql_error "Unable to start server." + fi +} + +# Stop the server. When using a local socket file mysqladmin will block until +# the shutdown is complete. +docker_temp_server_stop() { + if ! mysqladmin --defaults-extra-file=<( _mysql_passfile ) shutdown -uroot --socket="${SOCKET}"; then + mysql_error "Unable to shut down server." + fi +} + +# Verify that the minimally required password settings are set for new databases. +docker_verify_minimum_env() { + if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then + mysql_error $'Database is uninitialized and password option is not specified\n\tYou need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD' + fi +} + +# creates folders for the database +# also ensures permission for user mysql of run as root +docker_create_db_directories() { + local user; user="$(id -u)" + + # TODO other directories that are used by default? like /var/lib/mysql-files + # see https://github.com/docker-library/mysql/issues/562 mkdir -p "$DATADIR" - find "$DATADIR" \! -user mysql -exec chown mysql '{}' + - exec gosu mysql "$BASH_SOURCE" "$@" -fi -if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then - # still need to check config, container may have started with --user - _check_config "$@" + if [ "$user" = "0" ]; then + # this will cause less disk access than `chown -R` + find "$DATADIR" \! -user mysql -exec chown mysql '{}' + + fi +} + +# initializes the database directory +docker_init_database_dir() { + mysql_note "Initializing database files" + installArgs=( --datadir="$DATADIR" --rpm --auth-root-authentication-method=normal ) + if { mysql_install_db --help || :; } | grep -q -- '--skip-test-db'; then + # 10.3+ + installArgs+=( --skip-test-db ) + fi + # "Other options are passed to mysqld." (so we pass all "mysqld" arguments directly here) + mysql_install_db "${installArgs[@]}" "${@:2}" + mysql_note "Database files initialized" +} + +# Loads various settings that are used elsewhere in the script +# This should be called after mysql_check_config, but before any other functions +docker_setup_env() { # Get config - DATADIR="$(_get_config 'datadir' "$@")" - - if [ ! -d "$DATADIR/mysql" ]; then - file_env 'MYSQL_ROOT_PASSWORD' - if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then - echo >&2 'error: database is uninitialized and password option is not specified ' - echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD' - exit 1 - fi + declare -g DATADIR SOCKET + DATADIR="$(mysql_get_config 'datadir' "$@")" + SOCKET="$(mysql_get_config 'socket' "$@")" - mkdir -p "$DATADIR" + # Initialize values that might be stored in a file + file_env 'MYSQL_ROOT_HOST' '%' + file_env 'MYSQL_DATABASE' + file_env 'MYSQL_USER' + file_env 'MYSQL_PASSWORD' + file_env 'MYSQL_ROOT_PASSWORD' - echo 'Initializing database' - installArgs=( --datadir="$DATADIR" --rpm ) - if { mysql_install_db --help || :; } | grep -q -- '--auth-root-authentication-method'; then - # beginning in 10.4.3, install_db uses "socket" which only allows system user root to connect, switch back to "normal" to allow mysql root without a password - # see https://github.com/MariaDB/server/commit/b9f3f06857ac6f9105dc65caae19782f09b47fb3 - # (this flag doesn't exist in 10.0 and below) - installArgs+=( --auth-root-authentication-method=normal ) - fi - # "Other options are passed to mysqld." (so we pass all "mysqld" arguments directly here) - mysql_install_db "${installArgs[@]}" "${@:2}" - echo 'Database initialized' - - SOCKET="$(_get_config 'socket' "$@")" - "$@" --skip-networking --socket="${SOCKET}" & - pid="$!" - - mysql=( mysql --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" ) - - for i in {30..0}; do - if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then - break - fi - echo 'MySQL init process in progress...' - sleep 1 - done - if [ "$i" = 0 ]; then - echo >&2 'MySQL init process failed.' - exit 1 - fi + declare -g DATABASE_ALREADY_EXISTS + if [ -d "$DATADIR/mysql" ]; then + DATABASE_ALREADY_EXISTS='true' + fi +} - if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then - # sed is for https://bugs.mysql.com/bug.php?id=20545 - mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql - fi +# Execute sql script, passed via stdin +# usage: docker_process_sql [--dont-use-mysql-root-password] [mysql-cli-args] +# ie: docker_process_sql --database=mydb <<<'INSERT ...' +# ie: docker_process_sql --dont-use-mysql-root-password --database=mydb &2 'MySQL init process failed.' - exit 1 + # skip setup if they aren't running mysqld or want an option that stops mysqld + if [ "$1" = 'mysqld' ] && ! _mysql_want_help "$@"; then + mysql_note "Entrypoint script for MySQL Server ${MARIADB_VERSION} started." + + mysql_check_config "$@" + # Load various environment variables + docker_setup_env "$@" + docker_create_db_directories + + # If container is started as root user, restart as dedicated mysql user + if [ "$(id -u)" = "0" ]; then + mysql_note "Switching to dedicated user 'mysql'" + exec gosu mysql "$BASH_SOURCE" "$@" fi - echo - echo 'MySQL init process done. Ready for start up.' - echo + # there's no database, so it needs to be initialized + if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + docker_verify_minimum_env + + # check dir permissions to reduce likelihood of half-initialized database + ls /docker-entrypoint-initdb.d/ > /dev/null + + docker_init_database_dir "$@" + + mysql_note "Starting temporary server" + docker_temp_server_start "$@" + mysql_note "Temporary server started." + + docker_setup_db + docker_process_init_files /docker-entrypoint-initdb.d/* + + mysql_note "Stopping temporary server" + docker_temp_server_stop + mysql_note "Temporary server stopped" + + echo + mysql_note "MySQL init process done. Ready for start up." + echo + fi fi -fi + exec "$@" +} -exec "$@" \ No newline at end of file +# If we are sourced from elsewhere, don't perform any further actions +if ! _is_sourced; then + _main "$@" +fi \ No newline at end of file diff --git a/.travis/pam/pam.sh b/.travis/pam/pam.sh new file mode 100755 index 00000000..4a879a0e --- /dev/null +++ b/.travis/pam/pam.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +tee /etc/pam.d/mariadb << EOF +auth required pam_unix.so audit +auth required pam_unix.so audit +account required pam_unix.so audit +EOF + +useradd testPam +chpasswd << EOF +testPam:myPwd +EOF + +usermod -a -G shadow mysql + +echo "pam configuration done" \ No newline at end of file diff --git a/.travis/script.sh b/.travis/script.sh index 78b68516..14d0211c 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -6,66 +6,144 @@ set -e ################################################################################################################### # test different type of configuration ################################################################################################################### -mysql=( mysql --protocol=tcp -ubob -h127.0.0.1 --port=3305 ) -export COMPOSE_FILE=.travis/docker-compose.yml +export TEST_SOCKET= +export ENTRYPOINT=$PROJ_PATH/.travis/sql +export ENTRYPOINT_PAM=$PROJ_PATH/.travis/pam + +set +x + +if [ -n "$SKYSQL" ] || [ -n "$SKYSQL_HA" ]; then + if [ -n "$SKYSQL" ]; then + ################################################################################################################### + # test SKYSQL + ################################################################################################################### + if [ -z "$SKYSQL_HOST" ] ; then + echo "No SkySQL configuration found !" + exit 0 + fi + + export TEST_UID=$SKYSQL_USER + export TEST_SERVER=$SKYSQL_HOST + export TEST_PASSWORD=$SKYSQL_PASSWORD + export TEST_PORT=$SKYSQL_PORT + export TEST_SCHEMA=testo + export TEST_USETLS=true + + else + + ################################################################################################################### + # test SKYSQL with replication + ################################################################################################################### + if [ -z "$SKYSQL_HA" ] ; then + echo "No SkySQL HA configuration found !" + exit 0 + fi + + export TEST_UID=$SKYSQL_HA_USER + export TEST_SERVER=$SKYSQL_HA_HOST + export TEST_PASSWORD=$SKYSQL_HA_PASSWORD + export TEST_PORT=$SKYSQL_HA_PORT + export TEST_SCHEMA=testo + export TEST_USETLS=true + fi -if [ -n "$MAXSCALE_VERSION" ] -then - mysql=( mysql --protocol=tcp -ubob -h127.0.0.1 --port=4007 ) - export COMPOSE_FILE=.travis/maxscale-compose.yml - export TEST_PORT=4007 else + export COMPOSE_FILE=.travis/docker-compose.yml + + export TEST_DRIVER=maodbc_test + export TEST_DSN=maodbc_test + export TEST_SCHEMA=odbc_test + export TEST_UID=bob + export TEST_SERVER=mariadb.example.com + export TEST_PASSWORD= export TEST_PORT=3305 -fi + if [ -n "$MAXSCALE_VERSION" ] ; then + # maxscale ports: + # - non ssl: 4006 + # - ssl: 4009 + export TEST_PORT=4006 + export TEST_SSL_PORT=4009 + export COMPOSE_FILE=.travis/maxscale-compose.yml + docker-compose -f ${COMPOSE_FILE} build + fi -################################################################################################################### -# launch docker server and maxscale -################################################################################################################### -export INNODB_LOG_FILE_SIZE=$(echo ${PACKET}| cut -d'M' -f 1)0M -docker-compose -f ${COMPOSE_FILE} build -docker-compose -f ${COMPOSE_FILE} up -d + mysql=( mysql --protocol=tcp -ubob -h127.0.0.1 --port=3305 ) + ################################################################################################################### + # launch docker server and maxscale + ################################################################################################################### + docker-compose -f ${COMPOSE_FILE} up -d -################################################################################################################### -# wait for docker initialisation -################################################################################################################### -for i in {60..0}; do + ################################################################################################################### + # wait for docker initialisation + ################################################################################################################### + for i in {30..0}; do if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then break fi echo 'data server still not active' - sleep 1 -done + sleep 2 + done -docker-compose -f ${COMPOSE_FILE} logs + if [ "$i" = 0 ]; then + if echo 'SELECT 1' | "${mysql[@]}" ; then + break + fi -if [ "$i" = 0 ]; then -# echo 'SELECT 1' | "${mysql[@]}" - set +e - echo 'SELECT 1' | "${mysql[@]}" --ssl-ca=$SSLCERT/server.crt --ssl-key=$SSLCERT/client.key --ssl-cert=$SSLCERT/client.crt + docker-compose -f ${COMPOSE_FILE} logs + if [ -n "$MAXSCALE_VERSION" ] ; then + docker-compose -f ${COMPOSE_FILE} exec maxscale tail -n 500 /var/log/maxscale/maxscale.log + fi echo >&2 'data server init process failed.' - set -e -# exit 1 -fi - -#list ssl certificates -ls -lrt ${SSLCERT} + exit 1 + fi + + if [[ "$DB" != mysql* ]] ; then + ################################################################################################################### + # execute pam + ################################################################################################################### + docker-compose -f ${COMPOSE_FILE} exec -u root db bash /pam/pam.sh + sleep 1 + docker-compose -f ${COMPOSE_FILE} restart db + sleep 5 + + ################################################################################################################### + # wait for restart + ################################################################################################################### + + for i in {30..0}; do + if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then + break + fi + echo 'data server restart still not active' + sleep 2 + done + + if [ "$i" = 0 ]; then + if echo 'SELECT 1' | "${mysql[@]}" ; then + break + fi + + docker-compose -f ${COMPOSE_FILE} logs + if [ -n "$MAXSCALE_VERSION" ] ; then + docker-compose -f ${COMPOSE_FILE} exec maxscale tail -n 500 /var/log/maxscale/maxscale.log + fi + echo >&2 'data server restart process failed.' + exit 1 + fi + fi + #list ssl certificates + ls -lrt ${SSLCERT} +fi DEBIAN_FRONTEND=noninteractive sudo apt-get update DEBIAN_FRONTEND=noninteractive sudo apt-get install --allow-unauthenticated -y --force-yes -m unixodbc-dev odbcinst1debian2 libodbc1 #build odbc connector -export TEST_DRIVER=maodbc_test -export TEST_DSN=maodbc_test -export TEST_SERVER=mariadb.example.com -export TEST_SOCKET= -export TEST_SCHEMA=odbc_test -export TEST_UID=bob -export TEST_PASSWORD= cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_OPENSSL=ON -DWITH_SSL=OPENSSL # In Travis we are interested in tests with latest C/C version, while for release we must use only latest release tag @@ -82,5 +160,5 @@ export ODBCINI="$PWD/odbc.ini" export ODBCSYSINI=$PWD -ctest -V +ctest -VV diff --git a/appveyor.yml b/appveyor.yml index 8762e5dd..f422207e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,15 +1,15 @@ environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - DB: 10.4.12 + DB: 10.4.14 CMAKE_PARAM_G: 'Visual Studio 14 2015 Win64' - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - DB: 10.4.12 + DB: 10.4.14 CMAKE_PARAM_G: 'Visual Studio 15 2017 Win64' - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - DB: 10.5.0 + DB: 10.5.5 CMAKE_PARAM_G: 'Visual Studio 15 2017 Win64' # scripts that are called at very beginning, before repo cloning diff --git a/test/types.c b/test/types.c index 780e7f93..b843873c 100644 --- a/test/types.c +++ b/test/types.c @@ -1039,7 +1039,13 @@ int sqlnum_test_to_str(SQLHANDLE Stmt, SQLCHAR* numdata, SQLCHAR prec, /* TODO until sqlnum errors are supported */ if (!strcmp("01S07", exptrunc)) - exprc = SQL_SUCCESS_WITH_INFO; + { + /* iOdbc seemingly doesn't think, that SQLExecute or SQLExecDirect may return SQL_SUCCESS_WITH_INFO, and returns SQL_SUCCESS instead */ + if (!iOdbc()) + { + exprc = SQL_SUCCESS_WITH_INFO; + } + } else if (!strcmp("22003", exptrunc)) exprc = SQL_ERROR;