You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-05 15:55:58 +03:00
[misc] test improvement
* adding SkySQL HA to test suite * test server build 10.6 * test maxscale 2.5.3
This commit is contained in:
14
.travis.yml
14
.travis.yml
@@ -23,17 +23,19 @@ before_install:
|
||||
- export SSLCERT=$PROJ_PATH/tmp
|
||||
matrix:
|
||||
allow_failures:
|
||||
# - env: DB=build
|
||||
# - env: SERVER_BRANCH=10.5
|
||||
# - env: SERVER_BRANCH=10.5 TEST_OPTION=--ps-protocol
|
||||
include:
|
||||
- env: DB=build
|
||||
- env: DB=build:10.6
|
||||
- env: SKYSQL=true
|
||||
- env: SKYSQL_HA=true MAXSCALE_TEST_DISABLE=true
|
||||
# disable for now - env: DB=mysql:8.0
|
||||
- env: DB=mariadb:10.1
|
||||
- env: DB=mariadb:10.2
|
||||
- env: DB=mariadb:10.3
|
||||
- env: DB=mariadb:10.4
|
||||
- env: DB=mariadb:10.5
|
||||
- env: DB=mariadb:10.5 MAXSCALE_VERSION=2.5.3 MAXSCALE_TEST_DISABLE=true
|
||||
- env: SERVER_BRANCH=10.2
|
||||
- env: SERVER_BRANCH=10.2 TEST_OPTION=--ps-protocol
|
||||
- env: SERVER_BRANCH=10.3
|
||||
@@ -44,8 +46,8 @@ matrix:
|
||||
- env: SERVER_BRANCH=10.5 TEST_OPTION=--ps-protocol
|
||||
|
||||
script:
|
||||
- if [ "$DB" = "build" ] ; then .travis/build/build.sh; fi
|
||||
- if [ "$DB" = "build" ] ; then docker build -t build:latest --label build .travis/build/; fi
|
||||
- if [ -z "$DB" ] && [ -z "$SKYSQL" ] ; then .travis/server-replace-submodule.sh; fi
|
||||
- if [ -n "$DB" ] || [ -n "$SKYSQL" ]; then .travis/script.sh; 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 [ -z "$DB" ] && [ -z "$SKYSQL" ] && [ -z "$SKYSQL_HA" ] ; then .travis/server-replace-submodule.sh; fi
|
||||
- if [ -n "$DB" ] || [ -n "$SKYSQL" ] || [ -n "$SKYSQL_HA" ]; then .travis/script.sh; fi
|
||||
|
||||
|
@@ -1,8 +1,22 @@
|
||||
FROM debian:jessie
|
||||
# vim:set ft=dockerfile:
|
||||
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
|
||||
|
||||
# https://bugs.debian.org/830696 (apt uses gpgv by default in newer releases, rather than gpg)
|
||||
RUN set -ex; \
|
||||
apt-get update; \
|
||||
if ! which gpg; then \
|
||||
apt-get install -y --no-install-recommends gnupg; \
|
||||
fi; \
|
||||
# Ubuntu includes "gnupg" (not "gnupg2", but still 2.x), but not dirmngr, and gnupg 2.x requires dirmngr
|
||||
# so, if we're not running gnupg 1.x, explicitly install dirmngr too
|
||||
if ! gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \
|
||||
apt-get install -y --no-install-recommends dirmngr; \
|
||||
fi; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# add gosu for easy step-down from root
|
||||
ENV GOSU_VERSION 1.10
|
||||
RUN set -ex; \
|
||||
@@ -21,8 +35,9 @@ RUN set -ex; \
|
||||
\
|
||||
# verify the signature
|
||||
export GNUPGHOME="$(mktemp -d)"; \
|
||||
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
||||
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
||||
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
|
||||
command -v gpgconf > /dev/null && gpgconf --kill all || :; \
|
||||
rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
|
||||
\
|
||||
chmod +x /usr/local/bin/gosu; \
|
||||
@@ -37,39 +52,44 @@ RUN mkdir /docker-entrypoint-initdb.d
|
||||
# install "apt-transport-https" for Percona's repo (switched to https-only)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
apt-transport-https ca-certificates \
|
||||
tzdata \
|
||||
pwgen \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN { \
|
||||
echo "mariadb-server-10.3" mysql-server/root_password password 'unused'; \
|
||||
echo "mariadb-server-10.3" 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 echo 'deb http://yum.mariadb.org/galera/repo/deb jessie 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 galera3 libnuma1 libaio1 zlib1g-dev libreadline5 libjemalloc1 libsnappy1 libcrack2
|
||||
RUN apt-get install -y curl libdbi-perl rsync socat libnuma1 libaio1 zlib1g-dev libreadline5 libjemalloc1 libsnappy1v5 libcrack2
|
||||
|
||||
#RUN apt-get install -y galera3
|
||||
|
||||
COPY *.deb /root/
|
||||
RUN chmod 777 /root/*
|
||||
|
||||
RUN dpkg -R --install /root/mysql-common*
|
||||
RUN dpkg -R --install /root/mariadb-common*
|
||||
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/* \
|
||||
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /run/mysqld \
|
||||
&& chown -R mysql:mysql /var/lib/mysql /run/mysqld \
|
||||
&& chmod 777 /run/mysqld \
|
||||
&& 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
|
||||
|
||||
|
@@ -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.3/
|
||||
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.3/build-$line/kvm-deb-jessie-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.3/build-$line/kvm-deb-jessie-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.3/build-$line/kvm-deb-jessie-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
|
||||
|
||||
|
@@ -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,152 +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"'" { print $2; exit }'
|
||||
"$@" --verbose --help --log-bin-index="$(mktemp -u)" 2>/dev/null \
|
||||
| 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' "$@")"
|
||||
mkdir -p "$DATADIR"
|
||||
chown -R mysql:mysql "$DATADIR"
|
||||
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 "$@"
|
||||
# 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
|
||||
# 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
|
||||
|
||||
mkdir -p "$DATADIR"
|
||||
|
||||
echo 'Initializing database'
|
||||
mysql_install_db --datadir="$DATADIR" --rpm
|
||||
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
|
||||
if docker_process_sql "${extraArgs[@]}" --database=mysql <<<'SELECT 1' &> /dev/null; then
|
||||
break
|
||||
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
|
||||
|
||||
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
|
||||
export MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
|
||||
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
|
||||
fi
|
||||
|
||||
rootCreate=
|
||||
# default root to listen for connections from anywhere
|
||||
file_env 'MYSQL_ROOT_HOST' '%'
|
||||
if [ ! -z "$MYSQL_ROOT_HOST" -a "$MYSQL_ROOT_HOST" != 'localhost' ]; then
|
||||
# no, we don't care if read finds a terminating character in this heredoc
|
||||
# https://unix.stackexchange.com/questions/265149/why-is-set-o-errexit-breaking-this-read-heredoc-expression/265151#265151
|
||||
read -r -d '' rootCreate <<-EOSQL || true
|
||||
CREATE USER 'root'@'${MYSQL_ROOT_HOST}' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
|
||||
GRANT ALL ON *.* TO 'root'@'${MYSQL_ROOT_HOST}' WITH GRANT OPTION ;
|
||||
EOSQL
|
||||
fi
|
||||
|
||||
"${mysql[@]}" <<-EOSQL
|
||||
-- What's done in this file shouldn't be replicated
|
||||
-- or products like mysql-fabric won't work
|
||||
SET @@SESSION.SQL_LOG_BIN=0;
|
||||
|
||||
DELETE FROM mysql.user WHERE user NOT IN ('mysql.sys', 'mysqlxsys', 'root') OR host NOT IN ('localhost') ;
|
||||
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ;
|
||||
GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ;
|
||||
${rootCreate}
|
||||
DROP DATABASE IF EXISTS test ;
|
||||
FLUSH PRIVILEGES ;
|
||||
EOSQL
|
||||
|
||||
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
|
||||
mysql+=( -p"${MYSQL_ROOT_PASSWORD}" )
|
||||
fi
|
||||
|
||||
file_env 'MYSQL_DATABASE'
|
||||
if [ "$MYSQL_DATABASE" ]; then
|
||||
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" | "${mysql[@]}"
|
||||
mysql+=( "$MYSQL_DATABASE" )
|
||||
fi
|
||||
|
||||
file_env 'MYSQL_USER'
|
||||
file_env 'MYSQL_PASSWORD'
|
||||
if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
|
||||
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"
|
||||
|
||||
if [ "$MYSQL_DATABASE" ]; then
|
||||
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | "${mysql[@]}"
|
||||
fi
|
||||
|
||||
echo 'FLUSH PRIVILEGES ;' | "${mysql[@]}"
|
||||
fi
|
||||
|
||||
echo
|
||||
for f in /docker-entrypoint-initdb.d/*; do
|
||||
case "$f" in
|
||||
*.sh) echo "$0: running $f"; . "$f" ;;
|
||||
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
|
||||
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
|
||||
*) echo "$0: ignoring $f" ;;
|
||||
esac
|
||||
echo
|
||||
done
|
||||
|
||||
if ! kill -s TERM "$pid" || ! wait "$pid"; then
|
||||
echo >&2 'MySQL init process failed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo 'MySQL init process done. Ready for start up.'
|
||||
echo
|
||||
sleep 1
|
||||
done
|
||||
if [ "$i" = 0 ]; then
|
||||
mysql_error "Unable to start server."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
exec "$@"
|
||||
# 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"
|
||||
|
||||
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
|
||||
declare -g DATADIR SOCKET
|
||||
DATADIR="$(mysql_get_config 'datadir' "$@")"
|
||||
SOCKET="$(mysql_get_config 'socket' "$@")"
|
||||
|
||||
# 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'
|
||||
|
||||
declare -g DATABASE_ALREADY_EXISTS
|
||||
if [ -d "$DATADIR/mysql" ]; then
|
||||
DATABASE_ALREADY_EXISTS='true'
|
||||
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 <my-file.sql
|
||||
docker_process_sql() {
|
||||
passfileArgs=()
|
||||
if [ '--dont-use-mysql-root-password' = "$1" ]; then
|
||||
passfileArgs+=( "$1" )
|
||||
shift
|
||||
fi
|
||||
# args sent in can override this db, since they will be later in the command
|
||||
if [ -n "$MYSQL_DATABASE" ]; then
|
||||
set -- --database="$MYSQL_DATABASE" "$@"
|
||||
fi
|
||||
|
||||
mysql --defaults-extra-file=<( _mysql_passfile "${passfileArgs[@]}") --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" "$@"
|
||||
}
|
||||
|
||||
# Initializes database with timezone info and root password, plus optional extra db/user
|
||||
docker_setup_db() {
|
||||
# Load timezone info into database
|
||||
if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then
|
||||
{
|
||||
# Aria in 10.4+ is slow due to "transactional" (crash safety)
|
||||
# https://jira.mariadb.org/browse/MDEV-23326
|
||||
# https://github.com/docker-library/mariadb/issues/262
|
||||
local tztables=( time_zone time_zone_leap_second time_zone_name time_zone_transition time_zone_transition_type )
|
||||
for table in "${tztables[@]}"; do
|
||||
echo "/*!100400 ALTER TABLE $table TRANSACTIONAL=0 */;"
|
||||
done
|
||||
|
||||
# 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/'
|
||||
|
||||
for table in "${tztables[@]}"; do
|
||||
echo "/*!100400 ALTER TABLE $table TRANSACTIONAL=1 */;"
|
||||
done
|
||||
} | docker_process_sql --dont-use-mysql-root-password --database=mysql
|
||||
# tell docker_process_sql to not use MYSQL_ROOT_PASSWORD since it is not set yet
|
||||
fi
|
||||
# Generate random root password
|
||||
if [ -n "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
|
||||
export MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
|
||||
mysql_note "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
|
||||
fi
|
||||
# Sets root password and creates root users for non-localhost hosts
|
||||
local rootCreate=
|
||||
# default root to listen for connections from anywhere
|
||||
if [ -n "$MYSQL_ROOT_HOST" ] && [ "$MYSQL_ROOT_HOST" != 'localhost' ]; then
|
||||
# no, we don't care if read finds a terminating character in this heredoc
|
||||
# https://unix.stackexchange.com/questions/265149/why-is-set-o-errexit-breaking-this-read-heredoc-expression/265151#265151
|
||||
read -r -d '' rootCreate <<-EOSQL || true
|
||||
CREATE USER 'root'@'${MYSQL_ROOT_HOST}' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
|
||||
GRANT ALL ON *.* TO 'root'@'${MYSQL_ROOT_HOST}' WITH GRANT OPTION ;
|
||||
EOSQL
|
||||
fi
|
||||
|
||||
# tell docker_process_sql to not use MYSQL_ROOT_PASSWORD since it is just now being set
|
||||
docker_process_sql --dont-use-mysql-root-password --database=mysql <<-EOSQL
|
||||
-- What's done in this file shouldn't be replicated
|
||||
-- or products like mysql-fabric won't work
|
||||
SET @@SESSION.SQL_LOG_BIN=0;
|
||||
|
||||
DELETE FROM mysql.user WHERE user NOT IN ('mysql.sys', 'mariadb.sys', 'mysqlxsys', 'root') OR host NOT IN ('localhost') ;
|
||||
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ;
|
||||
-- 10.1: https://github.com/MariaDB/server/blob/d925aec1c10cebf6c34825a7de50afe4e630aff4/scripts/mysql_secure_installation.sh#L347-L365
|
||||
-- 10.5: https://github.com/MariaDB/server/blob/00c3a28820c67c37ebbca72691f4897b57f2eed5/scripts/mysql_secure_installation.sh#L351-L369
|
||||
DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%' ;
|
||||
|
||||
GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ;
|
||||
FLUSH PRIVILEGES ;
|
||||
${rootCreate}
|
||||
DROP DATABASE IF EXISTS test ;
|
||||
EOSQL
|
||||
|
||||
# Creates a custom database and user if specified
|
||||
if [ -n "$MYSQL_DATABASE" ]; then
|
||||
mysql_note "Creating database ${MYSQL_DATABASE}"
|
||||
docker_process_sql --database=mysql <<<"CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;"
|
||||
fi
|
||||
|
||||
if [ -n "$MYSQL_USER" ] && [ -n "$MYSQL_PASSWORD" ]; then
|
||||
mysql_note "Creating user ${MYSQL_USER}"
|
||||
docker_process_sql --database=mysql <<<"CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;"
|
||||
|
||||
if [ -n "$MYSQL_DATABASE" ]; then
|
||||
mysql_note "Giving user ${MYSQL_USER} access to schema ${MYSQL_DATABASE}"
|
||||
docker_process_sql --database=mysql <<<"GRANT ALL ON \`${MYSQL_DATABASE//_/\\_}\`.* TO '$MYSQL_USER'@'%' ;"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_mysql_passfile() {
|
||||
# echo the password to the "file" the client uses
|
||||
# the client command will use process substitution to create a file on the fly
|
||||
# ie: --defaults-extra-file=<( _mysql_passfile )
|
||||
if [ '--dont-use-mysql-root-password' != "$1" ] && [ -n "$MYSQL_ROOT_PASSWORD" ]; then
|
||||
cat <<-EOF
|
||||
[client]
|
||||
password="${MYSQL_ROOT_PASSWORD}"
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
# check arguments for an option that would cause mysqld to stop
|
||||
# return true if there is one
|
||||
_mysql_want_help() {
|
||||
local arg
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
-'?'|--help|--print-defaults|-V|--version)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
_main() {
|
||||
# if command starts with an option, prepend mysqld
|
||||
if [ "${1:0:1}" = '-' ]; then
|
||||
set -- mysqld "$@"
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
exec "$@"
|
||||
}
|
||||
|
||||
# If we are sourced from elsewhere, don't perform any further actions
|
||||
if ! _is_sourced; then
|
||||
_main "$@"
|
||||
fi
|
@@ -9,5 +9,6 @@ services:
|
||||
- $SSLCERT:/etc/sslcert
|
||||
- $ENTRYPOINT:/docker-entrypoint-initdb.d
|
||||
environment:
|
||||
MYSQL_DATABASE: test
|
||||
MYSQL_DATABASE: testc
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
||||
MYSQL_INITDB_SKIP_TZINFO: 1
|
||||
|
36
.travis/maxscale-compose.yml
Normal file
36
.travis/maxscale-compose.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
version: '2.1'
|
||||
services:
|
||||
db:
|
||||
image: $DB
|
||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --ssl-ca=/etc/sslcert/ca.crt --ssl-cert=/etc/sslcert/server.crt --ssl-key=/etc/sslcert/server.key --bind-address=0.0.0.0
|
||||
ports:
|
||||
- 3305:3306
|
||||
volumes:
|
||||
- $SSLCERT:/etc/sslcert
|
||||
- $ENTRYPOINT:/docker-entrypoint-initdb.d
|
||||
environment:
|
||||
MYSQL_DATABASE: testc
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
||||
healthcheck:
|
||||
test: ["CMD", "mysql", "--protocol=tcp", "-ubob", "-h127.0.0.1"]
|
||||
timeout: 50s
|
||||
retries: 10
|
||||
interval: 5s
|
||||
|
||||
maxscale:
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
links:
|
||||
- "db:database"
|
||||
ports:
|
||||
- 4006:4006
|
||||
- 4008:4008
|
||||
- 4009:4009
|
||||
volumes:
|
||||
- $SSLCERT:/etc/sslcert
|
||||
build:
|
||||
context: .
|
||||
dockerfile: maxscale/Dockerfile
|
||||
args:
|
||||
MAXSCALE_VERSION: $MAXSCALE_VERSION
|
24
.travis/maxscale/Dockerfile
Normal file
24
.travis/maxscale/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
FROM centos:7
|
||||
|
||||
ARG MAXSCALE_VERSION
|
||||
ENV MAXSCALE_VERSION ${MAXSCALE_VERSION:-2.5.3}
|
||||
|
||||
COPY maxscale/mariadb.repo /etc/yum.repos.d/
|
||||
|
||||
RUN rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB \
|
||||
&& yum -y install https://downloads.mariadb.com/MaxScale/${MAXSCALE_VERSION}/centos/7/x86_64/maxscale-${MAXSCALE_VERSION}-2.rhel.7.x86_64.rpm \
|
||||
&& yum -y update
|
||||
|
||||
RUN yum -y install maxscale-${MAXSCALE_VERSION} MariaDB-client \
|
||||
&& yum clean all \
|
||||
&& rm -rf /tmp/*
|
||||
|
||||
COPY maxscale/docker-entrypoint.sh /
|
||||
COPY maxscale/maxscale.cnf /etc/
|
||||
RUN chmod 777 /etc/maxscale.cnf
|
||||
RUN chmod 777 /docker-entrypoint.sh
|
||||
|
||||
|
||||
EXPOSE 4006 4007 4008
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
35
.travis/maxscale/docker-entrypoint.sh
Normal file
35
.travis/maxscale/docker-entrypoint.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
echo 'creating configuration done'
|
||||
|
||||
sleep 15
|
||||
|
||||
#################################################################################################
|
||||
# wait for db availability for 60s
|
||||
#################################################################################################
|
||||
mysql=( mysql --protocol=tcp -ubob -hdb --port=3306 )
|
||||
for i in {60..0}; do
|
||||
if echo 'use test2' | "${mysql[@]}" &> /dev/null; then
|
||||
break
|
||||
fi
|
||||
echo 'DB init process in progress...'
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo 'use test2' | "${mysql[@]}"
|
||||
if [ "$i" = 0 ]; then
|
||||
echo 'DB init process failed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 'maxscale launching ...'
|
||||
|
||||
tail -n 500 /etc/maxscale.cnf
|
||||
|
||||
/usr/bin/maxscale --user=root --nodaemon
|
||||
|
||||
cd /var/log/maxscale
|
||||
ls -lrt
|
||||
tail -n 500 /var/log/maxscale/maxscale.log
|
7
.travis/maxscale/mariadb.repo
Normal file
7
.travis/maxscale/mariadb.repo
Normal file
@@ -0,0 +1,7 @@
|
||||
# MariaDB 10.2 CentOS repository list - created 2017-06-05 08:06 UTC
|
||||
# http://downloads.mariadb.org/mariadb/repositories/
|
||||
[mariadb]
|
||||
name = MariaDB
|
||||
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
|
||||
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
|
||||
gpgcheck=1
|
121
.travis/maxscale/maxscale.cnf
Normal file
121
.travis/maxscale/maxscale.cnf
Normal file
@@ -0,0 +1,121 @@
|
||||
# MaxScale documentation:
|
||||
# https://mariadb.com/kb/en/mariadb-maxscale-24/
|
||||
|
||||
# Global parameters
|
||||
#
|
||||
# Complete list of configuration options:
|
||||
# https://mariadb.com/kb/en/mariadb-maxscale-24-mariadb-maxscale-configuration-guide/
|
||||
|
||||
[maxscale]
|
||||
threads=auto
|
||||
|
||||
# Server definitions
|
||||
#
|
||||
# Set the address of the server to the network
|
||||
# address of a MariaDB server.
|
||||
#
|
||||
|
||||
[server2]
|
||||
type=server
|
||||
address=database
|
||||
port=3306
|
||||
protocol=MariaDBBackend
|
||||
ssl=true
|
||||
ssl_ca_cert=/etc/sslcert/server.crt
|
||||
ssl_cert=/etc/sslcert/client.crt
|
||||
ssl_key=/etc/sslcert/client.key
|
||||
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=db
|
||||
port=3306
|
||||
protocol=MariaDBBackend
|
||||
|
||||
|
||||
# Monitor for the servers
|
||||
#
|
||||
# This will keep MaxScale aware of the state of the servers.
|
||||
# MariaDB Monitor documentation:
|
||||
# https://mariadb.com/kb/en/mariadb-maxscale-24-mariadb-monitor/
|
||||
|
||||
[MariaDB-Monitor]
|
||||
type=monitor
|
||||
module=mariadbmon
|
||||
servers=server1
|
||||
user=boby
|
||||
password=hey
|
||||
monitor_interval=2000
|
||||
|
||||
[MariaDB-Monitor2]
|
||||
type=monitor
|
||||
module=mariadbmon
|
||||
servers=server2
|
||||
user=boby
|
||||
password=hey
|
||||
monitor_interval=2000
|
||||
|
||||
# Service definitions
|
||||
#
|
||||
# Service Definition for a read-only service and
|
||||
# a read/write splitting service.
|
||||
#
|
||||
|
||||
# ReadConnRoute documentation:
|
||||
# https://mariadb.com/kb/en/mariadb-maxscale-24-readconnroute/
|
||||
|
||||
[Read-Only-Service]
|
||||
type=service
|
||||
router=readconnroute
|
||||
servers=server1
|
||||
user=boby
|
||||
password=hey
|
||||
router_options=slave
|
||||
|
||||
# ReadWriteSplit documentation:
|
||||
# https://mariadb.com/kb/en/mariadb-maxscale-24-readwritesplit/
|
||||
|
||||
[Read-Write-Service]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=server1
|
||||
version_string=10.5.99-MariaDB-maxScale
|
||||
user=boby
|
||||
password=hey
|
||||
|
||||
[Read-Write-Service2]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
version_string=10.5.99-MariaDB-maxScale
|
||||
servers=server2
|
||||
user=boby
|
||||
password=hey
|
||||
|
||||
# Listener definitions for the services
|
||||
#
|
||||
# These listeners represent the ports the
|
||||
# services will listen on.
|
||||
#
|
||||
|
||||
[Read-Only-Listener]
|
||||
type=listener
|
||||
service=Read-Only-Service
|
||||
protocol=MariaDBClient
|
||||
port=4008
|
||||
|
||||
[Read-Write-Listener]
|
||||
type=listener
|
||||
service=Read-Write-Service
|
||||
protocol=MariaDBClient
|
||||
port=4006
|
||||
|
||||
|
||||
[Read-Write-Listener2]
|
||||
type=listener
|
||||
service=Read-Write-Service2
|
||||
protocol=MariaDBClient
|
||||
port=4009
|
||||
ssl=true
|
||||
ssl_ca_cert=/etc/sslcert/ca.crt
|
||||
ssl_cert=/etc/sslcert/server.crt
|
||||
ssl_key=/etc/sslcert/server.key
|
@@ -6,49 +6,91 @@ set -e
|
||||
###################################################################################################################
|
||||
# test different type of configuration
|
||||
###################################################################################################################
|
||||
mysql=( mysql --protocol=tcp -ubob -h127.0.0.1 --port=3305 )
|
||||
export MYSQL_TEST_TRAVIS=1
|
||||
|
||||
if [ -n "$SKYSQL" ] ; then
|
||||
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
|
||||
|
||||
if [ -z "$SKYSQL_TEST_HOST" ] ; then
|
||||
echo "No SkySQL configuration found !"
|
||||
exit 1
|
||||
export MYSQL_TEST_USER=$SKYSQL_USER
|
||||
export MYSQL_TEST_HOST=$SKYSQL_HOST
|
||||
export MYSQL_TEST_PASSWD=$SKYSQL_PASSWORD
|
||||
export MYSQL_TEST_PORT=$SKYSQL_PORT
|
||||
export MYSQL_TEST_DATABASE=testc
|
||||
export MYSQL_TEST_TLS=1
|
||||
|
||||
else
|
||||
|
||||
###################################################################################################################
|
||||
# test SKYSQL with replication
|
||||
###################################################################################################################
|
||||
if [ -z "$SKYSQL_HA" ] ; then
|
||||
echo "No SkySQL HA configuration found !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export MYSQL_TEST_USER=$SKYSQL_HA_USER
|
||||
export MYSQL_TEST_HOST=$SKYSQL_HA_HOST
|
||||
export MYSQL_TEST_PASSWD=$SKYSQL_HA_PASSWORD
|
||||
export MYSQL_TEST_PORT=$SKYSQL_HA_PORT
|
||||
export MYSQL_TEST_DATABASE=testc
|
||||
export MYSQL_TEST_TLS=1
|
||||
fi
|
||||
|
||||
export MYSQL_TEST_USER=$SKYSQL_TEST_USER
|
||||
export MYSQL_TEST_HOST=$SKYSQL_TEST_HOST
|
||||
export MYSQL_TEST_PASSWD=$SKYSQL_TEST_PASSWORD
|
||||
export MYSQL_TEST_PORT=$SKYSQL_TEST_PORT
|
||||
export MYSQL_TEST_DATABASE=$SKYSQL_TEST_DATABASE
|
||||
export MYSQL_TEST_TLS=1
|
||||
else
|
||||
export COMPOSE_FILE=.travis/docker-compose.yml
|
||||
|
||||
export COMPOSE_FILE=.travis/docker-compose.yml
|
||||
export MYSQL_TEST_HOST=mariadb.example.com
|
||||
export MYSQL_TEST_DB=testc
|
||||
export MYSQL_TEST_USER=bob
|
||||
export MYSQL_TEST_PORT=3305
|
||||
|
||||
export MARIADB_PLUGIN_DIR=$PWD
|
||||
|
||||
if [ -n "$MAXSCALE_VERSION" ] ; then
|
||||
# maxscale ports:
|
||||
# - non ssl: 4006
|
||||
# - ssl: 4009
|
||||
export MYSQL_TEST_PORT=4006
|
||||
export MYSQL_TEST_SSL_PORT=4009
|
||||
export COMPOSE_FILE=.travis/maxscale-compose.yml
|
||||
docker-compose -f ${COMPOSE_FILE} build
|
||||
fi
|
||||
|
||||
mysql=( mysql --protocol=TCP -u${MYSQL_TEST_USER} -h${MYSQL_TEST_HOST} --port=${MYSQL_TEST_PORT} ${MYSQL_TEST_DB})
|
||||
|
||||
###################################################################################################################
|
||||
# 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
|
||||
|
||||
|
||||
###################################################################################################################
|
||||
# wait for docker initialisation
|
||||
###################################################################################################################
|
||||
|
||||
for i in {60..0}; do
|
||||
for i in {30..0}; do
|
||||
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
|
||||
break
|
||||
fi
|
||||
echo 'data server still not active'
|
||||
sleep 1
|
||||
sleep 2
|
||||
done
|
||||
|
||||
docker-compose -f ${COMPOSE_FILE} logs
|
||||
|
||||
if [ "$i" = 0 ]; then
|
||||
echo 'SELECT 1' | "${mysql[@]}"
|
||||
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 init process failed.'
|
||||
exit 1
|
||||
fi
|
||||
@@ -56,14 +98,6 @@ else
|
||||
#list ssl certificates
|
||||
ls -lrt ${SSLCERT}
|
||||
|
||||
|
||||
export MYSQL_TEST_HOST=mariadb.example.com
|
||||
export MYSQL_TEST_DB=ctest
|
||||
export MYSQL_TEST_USER=bob
|
||||
export MYSQL_TEST_PORT=3305
|
||||
export MYSQL_TEST_TRAVIS=1
|
||||
export MARIADB_PLUGIN_DIR=$PWD
|
||||
|
||||
fi
|
||||
|
||||
#build C connector
|
||||
|
@@ -1,6 +1,13 @@
|
||||
CREATE USER 'bob'@'localhost';
|
||||
GRANT ALL ON *.* TO 'bob'@'localhost' with grant option;
|
||||
|
||||
CREATE USER 'bob'@'%';
|
||||
GRANT ALL ON *.* TO 'bob'@'%' with grant option;
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
CREATE USER 'boby'@'%' identified by 'hey';
|
||||
GRANT ALL ON *.* TO 'boby'@'%' identified by 'hey' with grant option;
|
||||
|
||||
CREATE DATABASE ctest;
|
||||
CREATE USER 'boby'@'localhost' identified by 'hey';
|
||||
GRANT ALL ON *.* TO 'boby'@'localhost' identified by 'hey' with grant option;
|
||||
|
||||
CREATE DATABASE test2;
|
@@ -38,6 +38,7 @@ static int test_conc75(MYSQL *my)
|
||||
my_bool reconnect= 1;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
@@ -147,6 +148,7 @@ static int test_conc70(MYSQL *my)
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
@@ -210,7 +212,7 @@ static int test_conc68(MYSQL *my)
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
SKIP_SKYSQL;
|
||||
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
@@ -399,7 +401,7 @@ static int test_bad_union(MYSQL *mysql)
|
||||
rc= mysql_stmt_prepare(stmt, SL(query));
|
||||
FAIL_UNLESS(rc && mysql_errno(mysql) == 1222, "Error expected");
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
free(stmt);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -420,9 +422,26 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "drop table if exists t2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "drop table if exists t3");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "drop table if exists t4");
|
||||
check_mysql_rc(rc, mysql);
|
||||
/* table without auto_increment column */
|
||||
rc= mysql_query(mysql, "create table t1 (f1 int, f2 varchar(255), key(f1))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "create table t3 (f1 int not null primary key auto_increment, f2 varchar(255)) engine=MyISAM");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "create table t4 (f1 int not null primary key "
|
||||
"auto_increment, f2 varchar(200), unique (f2)) engine=MyISAM");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "START TRANSACTION");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "insert into t1 values (1,'a')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
@@ -440,17 +459,12 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
Test for bug #34889: mysql_client_test::test_mysql_insert_id test fails
|
||||
sporadically
|
||||
*/
|
||||
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'b')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "insert into t1 select 5,'c'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
rc= mysql_query(mysql, "drop table t2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "insert into t1 select null,'d'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
@@ -470,9 +484,7 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
FAIL_UNLESS(res == 400, "");
|
||||
|
||||
/* table with auto_increment column */
|
||||
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255)) engine=MyISAM");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "insert into t2 values (1,'a')");
|
||||
rc= mysql_query(mysql, "insert into t3 values (1,'a')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 1, "");
|
||||
@@ -482,11 +494,11 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'b')");
|
||||
rc= mysql_query(mysql, "insert into t3 values (null,'b')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 2, "");
|
||||
rc= mysql_query(mysql, "insert into t2 select 5,'c'");
|
||||
rc= mysql_query(mysql, "insert into t3 select 5,'c'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
/*
|
||||
@@ -495,16 +507,16 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
0. We try to be consistent with INSERT VALUES.
|
||||
*/
|
||||
FAIL_UNLESS(res == 5, "");
|
||||
rc= mysql_query(mysql, "insert into t2 select null,'d'");
|
||||
rc= mysql_query(mysql, "insert into t3 select null,'d'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 6, "");
|
||||
/* with more than one row */
|
||||
rc= mysql_query(mysql, "insert into t2 values (10,'a'),(11,'b')");
|
||||
rc= mysql_query(mysql, "insert into t3 values (10,'a'),(11,'b')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 11, "");
|
||||
rc= mysql_query(mysql, "insert into t2 select 12,'a' union select 13,'b'");
|
||||
rc= mysql_query(mysql, "insert into t3 select 12,'a' union select 13,'b'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
/*
|
||||
@@ -513,34 +525,34 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
return 0. We try to be consistent with INSERT VALUES.
|
||||
*/
|
||||
FAIL_UNLESS(res == 13, "");
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'a'),(null,'b')");
|
||||
rc= mysql_query(mysql, "insert into t3 values (null,'a'),(null,'b')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 14, "");
|
||||
rc= mysql_query(mysql, "insert into t2 select null,'a' union select null,'b'");
|
||||
rc= mysql_query(mysql, "insert into t3 select null,'a' union select null,'b'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 16, "");
|
||||
rc= mysql_query(mysql, "insert into t2 select 12,'a' union select 13,'b'");
|
||||
rc= mysql_query(mysql, "insert into t3 select 12,'a' union select 13,'b'");
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
rc= mysql_query(mysql, "insert ignore into t2 select 12,'a' union select 13,'b'");
|
||||
rc= mysql_query(mysql, "insert ignore into t3 select 12,'a' union select 13,'b'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
rc= mysql_query(mysql, "insert into t2 values (12,'a'),(13,'b')");
|
||||
rc= mysql_query(mysql, "insert into t3 values (12,'a'),(13,'b')");
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
rc= mysql_query(mysql, "insert ignore into t2 values (12,'a'),(13,'b')");
|
||||
rc= mysql_query(mysql, "insert ignore into t3 values (12,'a'),(13,'b')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
/* mixing autogenerated and explicit values */
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'e'),(12,'a'),(13,'b')");
|
||||
rc= mysql_query(mysql, "insert into t3 values (null,'e'),(12,'a'),(13,'b')");
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'e'),(12,'a'),(13,'b'),(25,'g')");
|
||||
rc= mysql_query(mysql, "insert into t3 values (null,'e'),(12,'a'),(13,'b'),(25,'g')");
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,last_insert_id(300))");
|
||||
rc= mysql_query(mysql, "insert into t3 values (null,last_insert_id(300))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
/*
|
||||
@@ -550,20 +562,15 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
diag("res: %lld", res);
|
||||
FAIL_UNLESS(res == 20, "");
|
||||
/* If first autogenerated number fails and 2nd works: */
|
||||
rc= mysql_query(mysql, "drop table t2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key "
|
||||
"auto_increment, f2 varchar(200), unique (f2)) engine=MyISAM");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'e')");
|
||||
rc= mysql_query(mysql, "insert into t4 values (null,'e')");
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 1, "");
|
||||
rc= mysql_query(mysql, "insert ignore into t2 values (null,'e'),(null,'a'),(null,'e')");
|
||||
rc= mysql_query(mysql, "insert ignore into t4 values (null,'e'),(null,'a'),(null,'e')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 2, "");
|
||||
/* If autogenerated fails and explicit works: */
|
||||
rc= mysql_query(mysql, "insert ignore into t2 values (null,'e'),(12,'c'),(null,'d')");
|
||||
rc= mysql_query(mysql, "insert ignore into t4 values (null,'e'),(12,'c'),(null,'d')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
/*
|
||||
@@ -572,24 +579,24 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
*/
|
||||
FAIL_UNLESS(res == 13, "");
|
||||
/* UPDATE may update mysql_insert_id() if it uses LAST_INSERT_ID(#) */
|
||||
rc= mysql_query(mysql, "update t2 set f1=14 where f1=12");
|
||||
rc= mysql_query(mysql, "update t4 set f1=14 where f1=12");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
rc= mysql_query(mysql, "update t2 set f1=0 where f1=14");
|
||||
rc= mysql_query(mysql, "update t4 set f1=0 where f1=14");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
rc= mysql_query(mysql, "update t2 set f2=last_insert_id(372) where f1=0");
|
||||
rc= mysql_query(mysql, "update t4 set f2=last_insert_id(372) where f1=0");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 372, "");
|
||||
/* check that LAST_INSERT_ID() does not update mysql_insert_id(): */
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'g')");
|
||||
rc= mysql_query(mysql, "insert into t4 values (null,'g')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 15, "");
|
||||
rc= mysql_query(mysql, "update t2 set f2=(@li:=last_insert_id()) where f1=15");
|
||||
rc= mysql_query(mysql, "update t4 set f2=(@li:=last_insert_id()) where f1=15");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 0, "");
|
||||
@@ -598,13 +605,13 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
mysql_insert_id() returns the id of the row, instead of not being
|
||||
affected.
|
||||
*/
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,@li) on duplicate key "
|
||||
rc= mysql_query(mysql, "insert into t4 values (null,@li) on duplicate key "
|
||||
"update f2=concat('we updated ',f2)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_insert_id(mysql);
|
||||
FAIL_UNLESS(res == 15, "");
|
||||
|
||||
rc= mysql_query(mysql, "drop table t1,t2");
|
||||
rc= mysql_query(mysql, "drop table t1,t2,t3,t4");
|
||||
check_mysql_rc(rc, mysql);
|
||||
return OK;
|
||||
}
|
||||
|
@@ -513,6 +513,7 @@ static int bug30472_retrieve_charset_info(MYSQL *con,
|
||||
|
||||
static int test_bug30472(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
int rc;
|
||||
|
||||
char character_set_name_1[MY_CS_NAME_SIZE];
|
||||
|
@@ -35,6 +35,7 @@ static int test_conc66(MYSQL *my)
|
||||
char query[1024];
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
@@ -91,6 +92,7 @@ static int test_bug20023(MYSQL *mysql)
|
||||
int rc;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
@@ -527,6 +529,8 @@ static int test_opt_reconnect(MYSQL *mysql)
|
||||
|
||||
static int test_compress(MYSQL *mysql)
|
||||
{
|
||||
// maxscale doesn't support compression
|
||||
SKIP_MAXSCALE;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
int rc;
|
||||
@@ -560,6 +564,7 @@ static int test_compress(MYSQL *mysql)
|
||||
|
||||
static int test_reconnect(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
my_bool my_true= TRUE;
|
||||
MYSQL *mysql1;
|
||||
int rc;
|
||||
@@ -582,7 +587,6 @@ static int test_reconnect(MYSQL *mysql)
|
||||
socketname, 0)))
|
||||
{
|
||||
diag("connection failed");
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -606,6 +610,7 @@ static int test_reconnect(MYSQL *mysql)
|
||||
|
||||
int test_conc21(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
int rc;
|
||||
MYSQL_RES *res= NULL;
|
||||
MYSQL_ROW row;
|
||||
@@ -679,6 +684,7 @@ int test_connection_timeout2(MYSQL *unused __attribute__((unused)))
|
||||
MYSQL *mysql;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
|
||||
@@ -744,6 +750,8 @@ int test_connection_timeout3(MYSQL *unused __attribute__((unused)))
|
||||
/* test should run with valgrind */
|
||||
static int test_conc118(MYSQL *mysql)
|
||||
{
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
int rc;
|
||||
my_bool reconnect= 1;
|
||||
|
||||
@@ -1135,6 +1143,8 @@ static int test_reset(MYSQL *mysql)
|
||||
|
||||
static int test_auth256(MYSQL *my)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
@@ -1427,6 +1437,9 @@ static int test_expired_pw(MYSQL *my)
|
||||
|
||||
static int test_conc315(MYSQL *mysql)
|
||||
{
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
int rc;
|
||||
const char *csname;
|
||||
|
||||
@@ -1562,6 +1575,8 @@ static int test_conc327(MYSQL *unused __attribute__((unused)))
|
||||
|
||||
static int test_conc332(MYSQL *unused __attribute__((unused)))
|
||||
{
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
int rc;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
int server_status1, server_status2;
|
||||
@@ -1676,6 +1691,7 @@ static int test_conc366(MYSQL *mysql)
|
||||
MYSQL *my;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
if (!is_mariadb)
|
||||
{
|
||||
@@ -1755,6 +1771,8 @@ static int test_conc392(MYSQL *mysql)
|
||||
|
||||
static int test_conc443(MYSQL *my __attribute__((unused)))
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
my_bool x= 1;
|
||||
unsigned long thread_id= 0;
|
||||
char query[128];
|
||||
@@ -1801,6 +1819,9 @@ static int test_conc443(MYSQL *my __attribute__((unused)))
|
||||
|
||||
static int test_default_auth(MYSQL *my __attribute__((unused)))
|
||||
{
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
MYSQL *mysql;
|
||||
|
||||
if (!is_mariadb)
|
||||
|
@@ -157,15 +157,11 @@ static int test_server_errors(MYSQL *mysql)
|
||||
static int test_bug16143(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt;
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
FAIL_IF(!stmt, mysql_error(mysql));
|
||||
|
||||
/* Check mysql_stmt_sqlstate return "no error" */
|
||||
FAIL_UNLESS(strcmp(mysql_stmt_sqlstate(stmt), "00000") == 0, "Expected SQLstate 000000");
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
free(stmt);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -180,13 +176,17 @@ static int test_cuted_rows(MYSQL *mysql)
|
||||
return SKIP;
|
||||
|
||||
mysql_query(mysql, "DROP TABLE if exists t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
mysql_query(mysql, "DROP TABLE if exists t2");
|
||||
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1(c1 tinyint)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "CREATE TABLE t2(c1 int not null)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "START TRANSACTION");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 values(10), (NULL), (NULL)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@@ -39,6 +39,7 @@ static int test_bug28075(MYSQL *mysql)
|
||||
int rc;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
rc= mysql_dump_debug_info(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -172,6 +173,7 @@ static int bug31418_impl()
|
||||
|
||||
static int test_bug31418(MYSQL *unused __attribute__((unused)))
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
int i;
|
||||
|
||||
if (!is_mariadb)
|
||||
@@ -806,12 +808,15 @@ static int test_bug49694(MYSQL *mysql)
|
||||
|
||||
static int test_conc49(MYSQL *mysql)
|
||||
{
|
||||
|
||||
SKIP_LOAD_INFILE_DISABLE;
|
||||
SKIP_SKYSQL;
|
||||
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
int i;
|
||||
FILE *fp;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
fp= fopen("./sample.csv", "w");
|
||||
for (i=1; i < 4; i++)
|
||||
fprintf(fp, "\"%d\", \"%d\", \"%d\"\r\n", i, i, i);
|
||||
@@ -983,6 +988,7 @@ static int test_conc_114(MYSQL *mysql)
|
||||
/* run with valgrind */
|
||||
static int test_conc117(MYSQL *unused __attribute__((unused)))
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
my_bool reconnect= 1;
|
||||
MYSQL *my= mysql_init(NULL);
|
||||
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
|
||||
@@ -1000,6 +1006,7 @@ static int test_conc117(MYSQL *unused __attribute__((unused)))
|
||||
|
||||
static int test_read_timeout(MYSQL *unused __attribute__((unused)))
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
int timeout= 5, rc;
|
||||
MYSQL *my= mysql_init(NULL);
|
||||
mysql_options(my, MYSQL_OPT_READ_TIMEOUT, &timeout);
|
||||
@@ -1206,12 +1213,12 @@ static int test_server_status(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
unsigned int server_status;
|
||||
MYSQL_STMT *stmt;
|
||||
// MYSQL_STMT *stmt;
|
||||
|
||||
if (mysql_get_server_version(mysql) < 100200)
|
||||
return SKIP;
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
// stmt= mysql_stmt_init(mysql);
|
||||
|
||||
rc= mysql_autocommit(mysql, 1);
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_STATUS, &server_status);
|
||||
@@ -1252,7 +1259,7 @@ static int test_server_status(MYSQL *mysql)
|
||||
rc= mysql_select_db(mysql, schema);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
// mysql_stmt_close(stmt);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -1478,7 +1485,7 @@ struct my_tests_st my_tests[] = {
|
||||
{"test_conc117", test_conc117, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc_114", test_conc_114, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_connect_attrs", test_connect_attrs, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc49", test_conc49, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc49", test_conc49, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_bug28075", test_bug28075, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_bug28505", test_bug28505, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_debug_example", test_debug_example, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
|
@@ -73,6 +73,21 @@ if (IS_SKYSQL(hostname)) \
|
||||
#define SKIP_NOTLS
|
||||
#endif
|
||||
|
||||
#define IS_MAXSCALE() (getenv("MAXSCALE_TEST_DISABLE")!=NULL)
|
||||
#define SKIP_MAXSCALE \
|
||||
if (IS_MAXSCALE()) \
|
||||
{ \
|
||||
diag("test disabled with maxscale"); \
|
||||
return SKIP; \
|
||||
}
|
||||
|
||||
#define SKIP_LOAD_INFILE_DISABLE \
|
||||
if (!((mysql->server_capabilities & CLIENT_LOCAL_FILES) && \
|
||||
(mysql->options.client_flag & CLIENT_LOCAL_FILES))) { \
|
||||
diag("Load local infile not supported"); \
|
||||
return SKIP; \
|
||||
}
|
||||
|
||||
#define MAX_KEY MAX_INDEXES
|
||||
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4 /* strlen("4096") */
|
||||
|
||||
@@ -183,6 +198,7 @@ static const char *schema = 0;
|
||||
static char *hostname = 0;
|
||||
static char *password = 0;
|
||||
static unsigned int port = 0;
|
||||
static unsigned int ssl_port = 0;
|
||||
static char *socketname = 0;
|
||||
static char *username = 0;
|
||||
static int force_tls= 0;
|
||||
@@ -423,6 +439,7 @@ void get_options(int argc, char **argv)
|
||||
break;
|
||||
case 'P':
|
||||
port= atoi(optarg);
|
||||
ssl_port=port;
|
||||
break;
|
||||
case 'S':
|
||||
socketname= optarg;
|
||||
@@ -518,7 +535,7 @@ MYSQL *test_connect(struct my_tests_st *test)
|
||||
static int reset_connection(MYSQL *mysql) {
|
||||
int rc;
|
||||
|
||||
if (is_mariadb)
|
||||
if (is_mariadb && !IS_MAXSCALE())
|
||||
rc= mysql_change_user(mysql, username, password, schema);
|
||||
else
|
||||
rc= mysql_reset_connection(mysql);
|
||||
@@ -565,6 +582,15 @@ void get_envvars() {
|
||||
port= atoi(envvar);
|
||||
diag("port: %d", port);
|
||||
}
|
||||
if (!ssl_port)
|
||||
{
|
||||
if ((envvar= getenv("MYSQL_TEST_SSL_PORT")))
|
||||
ssl_port= atoi(envvar);
|
||||
else
|
||||
ssl_port = port;
|
||||
diag("ssl_port: %d", ssl_port);
|
||||
}
|
||||
|
||||
if (!force_tls && (envvar= getenv("MYSQL_TEST_TLS")))
|
||||
force_tls= atoi(envvar);
|
||||
if (!socketname)
|
||||
|
@@ -49,6 +49,7 @@ static int test_conc97(MYSQL *mysql)
|
||||
|
||||
static int test_conc83(MYSQL *unused __attribute__((unused)))
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
@@ -99,7 +100,7 @@ static int test_conc60(MYSQL *mysql)
|
||||
rc= mysql_stmt_prepare(stmt, SL(query));
|
||||
if (rc && mysql_stmt_errno(stmt) == 1146) {
|
||||
diag("Internal test - customer data not available");
|
||||
mysql_stmt_close(stmt);
|
||||
free(stmt);
|
||||
return SKIP;
|
||||
}
|
||||
check_stmt_rc(rc, stmt);
|
||||
@@ -458,6 +459,12 @@ static int test_prepare_syntax(MYSQL *mysql)
|
||||
"id int, name varchar(50), extra int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "START TRANSACTION");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
strcpy(query, "INSERT INTO test_prepare_syntax VALUES(?");
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
FAIL_IF(!stmt, mysql_error(mysql));
|
||||
@@ -473,7 +480,7 @@ static int test_prepare_syntax(MYSQL *mysql)
|
||||
rc= mysql_commit(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
free(stmt);
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_syntax");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -1196,8 +1203,8 @@ static int test_long_data(MYSQL *mysql)
|
||||
FAIL_IF(!stmt, mysql_error(mysql));
|
||||
rc= mysql_stmt_prepare(stmt, SL(query));
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
rc= mysql_stmt_close(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
// rc= mysql_stmt_close(stmt);
|
||||
// check_stmt_rc(rc, stmt);
|
||||
|
||||
strcpy(query, "INSERT INTO test_long_data(col1, col2, col3) VALUES(?, ?, ?)");
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
@@ -2537,6 +2544,12 @@ static int test_pure_coverage(MYSQL *mysql)
|
||||
rc= mysql_query(mysql, "CREATE TABLE test_pure(c1 int, c2 varchar(20))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "START TRANSACTION");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
FAIL_IF(!stmt, mysql_error(mysql));
|
||||
rc= mysql_stmt_prepare(stmt, SL("insert into test_pure(c67788) values(10)"));
|
||||
@@ -3805,6 +3818,12 @@ static int test_null(MYSQL *mysql)
|
||||
rc= mysql_query(mysql, "CREATE TABLE test_null(col1 int, col2 varchar(50))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "START TRANSACTION");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
/* insert by prepare, wrong column name */
|
||||
strcpy(query, "INSERT INTO test_null(col3, col2) VALUES(?, ?)");
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
|
@@ -519,6 +519,7 @@ static int test_bug11183(MYSQL *mysql)
|
||||
|
||||
static int test_bug12744(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
MYSQL_STMT *stmt = NULL;
|
||||
int rc;
|
||||
|
||||
@@ -817,7 +818,7 @@ static int test_bug16144(MYSQL *mysql)
|
||||
mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &flag);
|
||||
FAIL_UNLESS(flag == flag_orig, "flag != flag_orig");
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
free(stmt);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -2065,6 +2066,7 @@ static int test_bug3117(MYSQL *mysql)
|
||||
|
||||
static int test_bug36004(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
int rc, warning_count= 0;
|
||||
MYSQL_STMT *stmt;
|
||||
|
||||
@@ -2715,8 +2717,8 @@ static int test_bug5194(MYSQL *mysql)
|
||||
|
||||
free(param_str);
|
||||
free(query);
|
||||
rc= mysql_stmt_close(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
// rc= mysql_stmt_close(stmt);
|
||||
// check_stmt_rc(rc, stmt);
|
||||
free(my_bind);
|
||||
stmt_text= "drop table t1";
|
||||
rc= mysql_real_query(mysql, SL(stmt_text));
|
||||
@@ -2726,6 +2728,7 @@ static int test_bug5194(MYSQL *mysql)
|
||||
|
||||
static int test_bug5315(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
MYSQL_STMT *stmt;
|
||||
const char *stmt_text;
|
||||
int rc;
|
||||
@@ -3036,8 +3039,7 @@ static int test_bug7990(MYSQL *mysql)
|
||||
MYSQL is not documented and is subject to change in 5.0
|
||||
*/
|
||||
FAIL_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql), "Error expected");
|
||||
mysql_stmt_close(stmt);
|
||||
FAIL_UNLESS(!mysql_errno(mysql), "errno != 0");
|
||||
free(stmt);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -3781,6 +3783,7 @@ static int test_stiny_bug(MYSQL *mysql)
|
||||
|
||||
static int test_bug53311(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MAXSCALE;
|
||||
int rc;
|
||||
MYSQL_STMT *stmt;
|
||||
int i;
|
||||
@@ -4547,7 +4550,7 @@ static int test_conc217(MYSQL *mysql)
|
||||
FAIL_IF(rc==0, "Expected error\n");
|
||||
rc= mysql_query(mysql, "drop table if exists t_count");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_stmt_close(stmt);
|
||||
free(stmt);
|
||||
check_mysql_rc(rc, mysql);
|
||||
return OK;
|
||||
}
|
||||
@@ -5206,7 +5209,7 @@ static int test_returning(MYSQL *mysql)
|
||||
int rc;
|
||||
|
||||
diag("MDEV-23768 not fixed yet");
|
||||
mysql_stmt_close(stmt);
|
||||
free(stmt);
|
||||
return SKIP;
|
||||
|
||||
rc= mysql_query(mysql, "CREATE TEMPORARY TABLE t1 (a int not null auto_increment primary key, b json)");
|
||||
|
@@ -927,6 +927,9 @@ static int test_bug9992(MYSQL *mysql)
|
||||
|
||||
static int test_multi_statements(MYSQL *mysql)
|
||||
{
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
MYSQL *mysql_local;
|
||||
MYSQL_RES *result;
|
||||
int rc;
|
||||
|
@@ -140,7 +140,7 @@ static int test_ssl(MYSQL *mysql)
|
||||
create_ssl_user("ssluser", 0);
|
||||
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
mariadb_get_infov(my, MARIADB_CONNECTION_TLS_VERSION_ID, &iversion);
|
||||
diag("iversion: %d", iversion);
|
||||
@@ -221,7 +221,7 @@ static int test_ssl_cipher(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(my,0, 0, sslca, 0, 0);
|
||||
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
rc= mysql_query(my, "SHOW session status like 'Ssl_version'");
|
||||
check_mysql_rc(rc, my);
|
||||
@@ -254,7 +254,7 @@ static int test_conc95(MYSQL *unused __attribute__((unused)))
|
||||
NULL);
|
||||
|
||||
if (!mysql_real_connect(mysql, hostname, "ssluser1", sslpw, schema,
|
||||
port, socketname, 0))
|
||||
ssl_port, socketname, 0))
|
||||
{
|
||||
diag("could not establish x509 connection. Error: %s", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
@@ -283,7 +283,7 @@ static int test_multi_ssl_connections(MYSQL *unused __attribute__((unused)))
|
||||
my= mysql_init(NULL);
|
||||
FAIL_IF(!my,"mysql_init() failed");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
rc= mysql_query(my, "SHOW STATUS LIKE 'Ssl_accepts'");
|
||||
check_mysql_rc(rc, my);
|
||||
@@ -301,7 +301,7 @@ static int test_multi_ssl_connections(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql[i], 0, 0, sslca, 0, 0);
|
||||
|
||||
mysql_real_connect(mysql[i], hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
if (mysql_errno(mysql[i]))
|
||||
{
|
||||
diag("loop: %d error: %d %s", i, mysql_errno(mysql[i]), mysql_error(mysql[i]));
|
||||
@@ -345,7 +345,7 @@ DWORD WINAPI ssl_thread(void *dummy)
|
||||
mysql_ssl_set(mysql, 0, 0, sslca, 0, 0);
|
||||
|
||||
if(!mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0))
|
||||
ssl_port, socketname, 0))
|
||||
{
|
||||
diag(">Error: %s", mysql_error(mysql));
|
||||
goto end;
|
||||
@@ -435,7 +435,7 @@ static int test_phpbug51647(MYSQL *unused __attribute__((unused)))
|
||||
sslca, 0, 0);
|
||||
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
diag("%s", mysql_get_ssl_cipher(mysql));
|
||||
mysql_close(mysql);
|
||||
|
||||
@@ -459,7 +459,7 @@ static int test_password_protected(MYSQL *unused __attribute__((unused)))
|
||||
mysql_options(mysql, MARIADB_OPT_TLS_PASSPHRASE, "qwerty");
|
||||
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
diag("%s", mysql_get_ssl_cipher(mysql));
|
||||
mysql_close(mysql);
|
||||
|
||||
@@ -480,7 +480,7 @@ static int test_conc50(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, NULL, NULL, "./non_exisiting_cert.pem", NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
diag("Error: %d %s", mysql_errno(mysql), mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql) != 2026, "Expected errno 2026");
|
||||
mysql_close(mysql);
|
||||
@@ -509,7 +509,7 @@ static int test_conc50_1(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, NULL, NULL, sslca, NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
if (mysql_errno(mysql))
|
||||
diag("Error: %d %s", mysql_errno(mysql), mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql), "No error expected");
|
||||
@@ -532,7 +532,7 @@ static int test_conc50_2(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, NULL, NULL, "./non_exisiting_cert.pem", NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
FAIL_IF(mysql_errno(mysql) != 2026, "Expected errno 2026");
|
||||
mysql_close(mysql);
|
||||
|
||||
@@ -555,7 +555,7 @@ static int test_conc127(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, NULL, NULL, "./non_exisiting.pem", NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql) == 0, "Error expected (invalid certificate)");
|
||||
mysql_close(mysql);
|
||||
@@ -576,7 +576,7 @@ static int test_conc50_3(MYSQL *unused __attribute__((unused)))
|
||||
FAIL_IF(!mysql, "Can't allocate memory");
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
FAIL_IF(!mysql_errno(mysql), "Error expected, SSL connection required!");
|
||||
mysql_close(mysql);
|
||||
|
||||
@@ -586,7 +586,7 @@ static int test_conc50_3(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, NULL, NULL, sslca, NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
diag("Error: %s<", mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql), "No error expected");
|
||||
mysql_close(mysql);
|
||||
@@ -607,7 +607,7 @@ static int test_conc50_4(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, NULL, sslca, NULL, NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
FAIL_IF(!mysql_errno(mysql) , "Error expected");
|
||||
mysql_close(mysql);
|
||||
|
||||
@@ -634,7 +634,7 @@ static int verify_ssl_server_cert(MYSQL *unused __attribute__((unused)))
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
|
||||
FAIL_IF(!mysql_errno(mysql), "Expected error");
|
||||
diag("Error (expected): %s", mysql_error(mysql));
|
||||
@@ -656,7 +656,7 @@ static int test_bug62743(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, "dummykey", NULL, NULL, NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql) != 2026, "Expected errno 2026");
|
||||
mysql_close(mysql);
|
||||
@@ -667,7 +667,7 @@ static int test_bug62743(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, sslkey, NULL, NULL, NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
diag("Error with key: %s", mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql) != 2026, "Expected errno 2026");
|
||||
mysql_close(mysql);
|
||||
@@ -679,7 +679,7 @@ static int test_bug62743(MYSQL *unused __attribute__((unused)))
|
||||
sslcert, NULL, NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
FAIL_IF(mysql_errno(mysql) != 0, "Expected no error");
|
||||
mysql_close(mysql);
|
||||
|
||||
@@ -689,7 +689,7 @@ static int test_bug62743(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(mysql, sslkey, "blablubb", NULL, NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
diag("Error with cert: %s", mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql) == 0, "Expected error");
|
||||
mysql_close(mysql);
|
||||
@@ -716,7 +716,7 @@ DWORD WINAPI thread_conc102(void)
|
||||
mysql_ssl_set(mysql,0, 0, sslca, 0, 0);
|
||||
|
||||
if(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0))
|
||||
ssl_port, socketname, 0))
|
||||
{
|
||||
diag(">Error: %s", mysql_error(mysql));
|
||||
goto end;
|
||||
@@ -813,12 +813,12 @@ static int test_ssl_fp(MYSQL *unused __attribute__((unused)))
|
||||
mysql_options(my, MARIADB_OPT_SSL_FP, bad_cert_finger_print);
|
||||
|
||||
FAIL_IF(mysql_real_connect(my, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
mysql_options(my, MARIADB_OPT_SSL_FP, ssl_cert_finger_print);
|
||||
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
FAIL_IF(check_cipher(my) != 0, "Invalid cipher");
|
||||
|
||||
@@ -854,7 +854,7 @@ static int test_ssl_fp_list(MYSQL *unused __attribute__((unused)))
|
||||
mysql_options(my, MARIADB_OPT_SSL_FP_LIST, CERT_PATH "/server-cert.sha1");
|
||||
|
||||
if(!mysql_real_connect(my, hostname, username, password, schema,
|
||||
port, socketname, 0))
|
||||
ssl_port, socketname, 0))
|
||||
{
|
||||
diag("Error: %s", mysql_error(my));
|
||||
mysql_close(my);
|
||||
@@ -880,7 +880,7 @@ static int test_ssl_version(MYSQL *unused __attribute__((unused)))
|
||||
|
||||
mysql_ssl_set(my,0, 0, sslca, 0, 0);
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
diag("cipher: %s", mysql_get_ssl_cipher(my));
|
||||
mariadb_get_infov(my, MARIADB_CONNECTION_TLS_VERSION_ID, &iversion);
|
||||
@@ -911,7 +911,7 @@ static int test_schannel_cipher(MYSQL *unused __attribute__((unused)))
|
||||
mysql_ssl_set(my,0, 0, sslca, 0, 0);
|
||||
mysql_options(my, MARIADB_OPT_TLS_CIPHER_STRENGTH, &cipher_strength);
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
diag("cipher: %s", mysql_get_ssl_cipher(my));
|
||||
|
||||
@@ -969,7 +969,7 @@ static int test_cipher_mapping(MYSQL *unused __attribute__((unused)))
|
||||
|
||||
mysql->options.use_ssl= 1;
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
if (!(cipher= mysql_get_ssl_cipher(mysql)) ||
|
||||
strcmp(ciphers[i], cipher) != 0)
|
||||
{
|
||||
@@ -1038,14 +1038,14 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES128-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser1", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
FAIL_IF(!mysql_get_ssl_cipher(my), "No TLS connection");
|
||||
mysql_close(my);
|
||||
|
||||
my= mysql_init(NULL);
|
||||
mysql_options(my, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser1", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
FAIL_IF(!mysql_get_ssl_cipher(my), "No TLS connection");
|
||||
mysql_close(my);
|
||||
|
||||
@@ -1059,7 +1059,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
my= mysql_init(NULL);
|
||||
mysql_options(my, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
port, socketname, 0);
|
||||
ssl_port, socketname, 0);
|
||||
if (!mysql_error(my) &&
|
||||
strcmp(mysql_get_ssl_cipher(my), "AES256-SHA"))
|
||||
{
|
||||
@@ -1075,7 +1075,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
FAIL_IF(strcmp("AES256-SHA", mysql_get_ssl_cipher(my)) != 0, "expected cipher AES256-SHA");
|
||||
mysql_close(my);
|
||||
}
|
||||
@@ -1085,7 +1085,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES128-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
ssl_port, socketname, 0), "Error expected");
|
||||
mysql_close(my);
|
||||
|
||||
|
||||
@@ -1100,7 +1100,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
ssl_port, socketname, 0), "Error expected");
|
||||
mysql_close(my);
|
||||
|
||||
/* ssluser3 connect with cipher and certs */
|
||||
@@ -1111,7 +1111,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
NULL,
|
||||
"AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
mysql_close(my);
|
||||
|
||||
@@ -1124,7 +1124,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
ssl_port, socketname, 0), "Error expected");
|
||||
mysql_close(my);
|
||||
|
||||
/* ssluser4 connect with cipher and certs */
|
||||
@@ -1135,7 +1135,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
NULL,
|
||||
"AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
mysql_close(my);
|
||||
}
|
||||
diag("drop users");
|
||||
@@ -1163,7 +1163,7 @@ static int test_ssl_timeout(MYSQL *unused __attribute__((unused)))
|
||||
mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, &read_timeout);
|
||||
mysql->options.use_ssl= 1;
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
diag("cipher: %s\n", mysql_get_ssl_cipher(mysql));
|
||||
rc= mysql_query(mysql, "SELECT SLEEP(600)");
|
||||
if (!rc)
|
||||
@@ -1200,7 +1200,7 @@ static int test_conc286(MYSQL *unused __attribute__((unused)))
|
||||
mysql_options(my, MARIADB_OPT_SSL_FP, ssl_cert_finger_print);
|
||||
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
ssl_port, socketname, 0), mysql_error(my));
|
||||
|
||||
FAIL_IF(check_cipher(my) != 0, "Invalid cipher");
|
||||
|
||||
@@ -1276,7 +1276,7 @@ static int test_mdev14101(MYSQL *my __attribute__((unused)))
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
mysql_options(mysql, MARIADB_OPT_TLS_VERSION, combinations[i].opt_tls_version);
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_TLS_VERSION, &tls_version);
|
||||
diag("options: %s", combinations[i].opt_tls_version);
|
||||
diag("protocol: %s expected: %s", tls_version, combinations[i].expected);
|
||||
@@ -1296,7 +1296,7 @@ static int test_conc386(MYSQL *mysql)
|
||||
NULL,
|
||||
NULL);
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
FAIL_IF(check_cipher(mysql) != 0, "Invalid cipher");
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
@@ -1316,7 +1316,7 @@ static int test_ssl_verify(MYSQL *my __attribute__((unused)))
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &enforce);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);
|
||||
FAIL_IF(mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
ssl_port, socketname, 0), "Error expected");
|
||||
diag("error expected: %s\n", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
|
||||
@@ -1338,13 +1338,13 @@ static int test_ssl_verify(MYSQL *my __attribute__((unused)))
|
||||
mysql_ssl_set(mysql,0, 0, sslca, 0, 0);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &enforce);
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
ssl_port, socketname, 0), mysql_error(mysql));
|
||||
|
||||
diag("cipher: %s", mysql_get_ssl_cipher(mysql));
|
||||
mysql_close(mysql);
|
||||
|
Reference in New Issue
Block a user