mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-04-18 21:24:07 +03:00
testing various correction
travis: use connector-test-machine test script that permit to run the following tests : * MariaDB all supported version * Maxscale * MySQL * SkySQL If CONNECTOR_TEST_SECRET_KEY is not provided (PR) only MariaDB and MySQL community will be test Pull request testing correction appveyor correction using archive if not latest server release
This commit is contained in:
parent
802ce584a2
commit
94e85cdd4b
103
.travis.yml
103
.travis.yml
@ -1,51 +1,74 @@
|
||||
sudo: true
|
||||
os: linux
|
||||
dist: focal
|
||||
language: c
|
||||
cache:
|
||||
apt: true
|
||||
ccache: true
|
||||
services: docker
|
||||
|
||||
addons:
|
||||
hosts:
|
||||
- mariadb.example.com
|
||||
|
||||
before_script:
|
||||
# Disable services enabled by default
|
||||
- sudo /etc/init.d/mysql stop
|
||||
cache:
|
||||
apt: true
|
||||
ccache: true
|
||||
directories:
|
||||
- $HOME/docker
|
||||
|
||||
before_install:
|
||||
- chmod -R +x .travis/*
|
||||
- chmod 777 .travis/build/
|
||||
- export PROJ_PATH=`pwd`
|
||||
- export ENTRYPOINT=$PROJ_PATH/.travis/sql
|
||||
- mkdir tmp
|
||||
- .travis/gen-ssl.sh mariadb.example.com tmp
|
||||
- export SSLCERT=$PROJ_PATH/tmp
|
||||
matrix:
|
||||
- git clone https://github.com/mariadb-corporation/connector-test-machine.git
|
||||
# Load cached docker images
|
||||
- if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi
|
||||
|
||||
install:
|
||||
- |-
|
||||
if [ -z "$server_branch" ] ; then
|
||||
case $TRAVIS_OS_NAME in
|
||||
windows)
|
||||
connector-test-machine/launch.bat -t "$srv" -v "$v" -d testc
|
||||
;;
|
||||
linux)
|
||||
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testc -l "$local" -n "$native"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
env: local=0
|
||||
|
||||
jobs:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: srv=build v=10.6
|
||||
- env: srv=mariadb v=10.5
|
||||
os: windows
|
||||
language: shell
|
||||
include:
|
||||
- env: SKYSQL=true
|
||||
- env: SKYSQL_HA=true MAXSCALE_TEST_DISABLE=true
|
||||
# disable for now - env: DB=mysql:8.0
|
||||
# eoled - 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: DB=mariadb:10.6
|
||||
- env: SERVER_BRANCH=10.2
|
||||
- env: SERVER_BRANCH=10.2 TEST_OPTION=--ps-protocol
|
||||
- env: SERVER_BRANCH=10.3
|
||||
- env: SERVER_BRANCH=10.3 TEST_OPTION=--ps-protocol
|
||||
- env: SERVER_BRANCH=10.4
|
||||
- env: SERVER_BRANCH=10.4 TEST_OPTION=--ps-protocol
|
||||
- env: SERVER_BRANCH=10.5
|
||||
- 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: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
|
||||
- env: srv=mariadb v=10.5
|
||||
os: windows
|
||||
language: shell
|
||||
- env: srv=mariadb v=10.2 local=1
|
||||
dist: bionic
|
||||
- env: srv=mariadb v=10.3 local=1
|
||||
- env: srv=mariadb v=10.4 local=1
|
||||
- env: srv=mariadb v=10.5 local=1
|
||||
- env: srv=mariadb v=10.6 local=1
|
||||
- if: env(CONNECTOR_TEST_SECRET_KEY)
|
||||
env: srv=mariadb-es v=10.5
|
||||
- if: env(CONNECTOR_TEST_SECRET_KEY)
|
||||
env: srv=maxscale
|
||||
- if: env(CONNECTOR_TEST_SECRET_KEY)
|
||||
env: srv=build v=10.6
|
||||
- env: srv=mysql v=5.7 native=1
|
||||
- env: srv=mysql v=8.0 native=1
|
||||
- if: env(CONNECTOR_TEST_SECRET_KEY)
|
||||
env: srv=skysql
|
||||
- if: env(CONNECTOR_TEST_SECRET_KEY)
|
||||
env: srv=skysql-ha
|
||||
- env: server_branch=10.2
|
||||
- env: server_branch=10.2 TEST_OPTION=--ps-protocol
|
||||
- env: server_branch=10.3
|
||||
- env: server_branch=10.3 TEST_OPTION=--ps-protocol
|
||||
- env: server_branch=10.4
|
||||
- env: server_branch=10.4 TEST_OPTION=--ps-protocol
|
||||
- env: server_branch=10.5
|
||||
- env: server_branch=10.5 TEST_OPTION=--ps-protocol
|
||||
|
||||
script: ./travis.sh
|
||||
|
@ -1,102 +0,0 @@
|
||||
# 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; \
|
||||
\
|
||||
fetchDeps=' \
|
||||
ca-certificates \
|
||||
wget \
|
||||
'; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends $fetchDeps; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
|
||||
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
|
||||
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
|
||||
\
|
||||
# verify the signature
|
||||
export GNUPGHOME="$(mktemp -d)"; \
|
||||
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; \
|
||||
# verify that the binary works
|
||||
gosu nobody true; \
|
||||
\
|
||||
apt-get purge -y --auto-remove $fetchDeps
|
||||
|
||||
RUN mkdir /docker-entrypoint-initdb.d
|
||||
|
||||
# install "pwgen" for randomizing passwords
|
||||
# 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.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 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 galera3
|
||||
|
||||
COPY *.deb /root/
|
||||
RUN chmod 777 /root/*
|
||||
|
||||
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/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/mariadb.conf.d/docker.cnf
|
||||
|
||||
VOLUME /var/lib/mysql
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
||||
EXPOSE 3306
|
||||
CMD ["mysqld"]
|
||||
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "**************************************************************************"
|
||||
echo "* searching for last complete build"
|
||||
echo "**************************************************************************"
|
||||
|
||||
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.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.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: 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
|
||||
|
||||
exit
|
||||
else
|
||||
echo "skip build $line"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
@ -1,355 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
shopt -s nullglob
|
||||
|
||||
# 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'
|
||||
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
|
||||
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
|
||||
file_env() {
|
||||
local var="$1"
|
||||
local fileVar="${var}_FILE"
|
||||
local def="${2:-}"
|
||||
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||
mysql_error "Both $var and $fileVar are set (but are exclusive)"
|
||||
fi
|
||||
local val="$def"
|
||||
if [ "${!var:-}" ]; then
|
||||
val="${!var}"
|
||||
elif [ "${!fileVar:-}" ]; then
|
||||
val="$(< "${!fileVar}")"
|
||||
fi
|
||||
export "$var"="$val"
|
||||
unset "$fileVar"
|
||||
}
|
||||
|
||||
# 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
|
||||
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
|
||||
mysql_get_config() {
|
||||
local conf="$1"; shift
|
||||
"$@" --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)"
|
||||
}
|
||||
|
||||
# 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"
|
||||
|
||||
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
|
@ -1,14 +0,0 @@
|
||||
version: '2'
|
||||
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
|
||||
MYSQL_INITDB_SKIP_TZINFO: 1
|
@ -1,128 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
log () {
|
||||
echo "$@" 1>&2
|
||||
}
|
||||
|
||||
print_error () {
|
||||
echo "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
print_usage () {
|
||||
print_error "Usage: gen-ssl-cert-key <fqdn> <output-dir>"
|
||||
}
|
||||
|
||||
gen_cert_subject () {
|
||||
local fqdn="$1"
|
||||
[[ "${fqdn}" != "" ]] || print_error "FQDN cannot be blank"
|
||||
echo "/C=XX/ST=X/O=X/localityName=X/CN=${fqdn}/organizationalUnitName=X/emailAddress=X/"
|
||||
}
|
||||
|
||||
main () {
|
||||
local fqdn="$1"
|
||||
local sslDir="$2"
|
||||
[[ "${fqdn}" != "" ]] || print_usage
|
||||
[[ -d "${sslDir}" ]] || print_error "Directory does not exist: ${sslDir}"
|
||||
|
||||
local caCertFile="${sslDir}/ca.crt"
|
||||
local caKeyFile="${sslDir}/ca.key"
|
||||
local certFile="${sslDir}/server.crt"
|
||||
local keyFile="${sslDir}/server.key"
|
||||
local csrFile="${sslDir}/csrFile.key"
|
||||
local clientCertFile="${sslDir}/client.crt"
|
||||
local clientKeyFile="${sslDir}/client.key"
|
||||
local clientKeystoreFile="${sslDir}/client-keystore.p12"
|
||||
local pcks12FullKeystoreFile="${sslDir}/fullclient-keystore.p12"
|
||||
local clientReqFile="${sslDir}/clientReqFile.key"
|
||||
|
||||
log "Generating CA key"
|
||||
openssl genrsa -out "${caKeyFile}" 2048
|
||||
|
||||
log "Generating CA certificate"
|
||||
openssl req \
|
||||
-sha1 \
|
||||
-new \
|
||||
-x509 \
|
||||
-nodes \
|
||||
-days 3650 \
|
||||
-subj "$(gen_cert_subject ca.example.com)" \
|
||||
-key "${caKeyFile}" \
|
||||
-out "${caCertFile}"
|
||||
|
||||
log "Generating private key"
|
||||
openssl genrsa -out "${keyFile}" 2048
|
||||
|
||||
log "Generating certificate signing request"
|
||||
openssl req \
|
||||
-new \
|
||||
-batch \
|
||||
-sha1 \
|
||||
-subj "$(gen_cert_subject "$fqdn")" \
|
||||
-set_serial 01 \
|
||||
-key "${keyFile}" \
|
||||
-out "${csrFile}" \
|
||||
-nodes
|
||||
|
||||
log "Generating X509 certificate"
|
||||
openssl x509 \
|
||||
-req \
|
||||
-sha1 \
|
||||
-set_serial 01 \
|
||||
-CA "${caCertFile}" \
|
||||
-CAkey "${caKeyFile}" \
|
||||
-days 3650 \
|
||||
-in "${csrFile}" \
|
||||
-signkey "${keyFile}" \
|
||||
-out "${certFile}"
|
||||
|
||||
log "Generating client certificate"
|
||||
openssl req \
|
||||
-batch \
|
||||
-newkey rsa:2048 \
|
||||
-days 3600 \
|
||||
-subj "$(gen_cert_subject "$fqdn")" \
|
||||
-nodes \
|
||||
-keyout "${clientKeyFile}" \
|
||||
-out "${clientReqFile}"
|
||||
|
||||
openssl x509 \
|
||||
-req \
|
||||
-in "${clientReqFile}" \
|
||||
-days 3600 \
|
||||
-CA "${caCertFile}" \
|
||||
-CAkey "${caKeyFile}" \
|
||||
-set_serial 01 \
|
||||
-out "${clientCertFile}"
|
||||
|
||||
# Now generate a keystore with the client cert & key
|
||||
log "Generating client keystore"
|
||||
openssl pkcs12 \
|
||||
-export \
|
||||
-in "${clientCertFile}" \
|
||||
-inkey "${clientKeyFile}" \
|
||||
-out "${clientKeystoreFile}" \
|
||||
-name "mysqlAlias" \
|
||||
-passout pass:kspass
|
||||
|
||||
# Now generate a full keystore with the client cert & key + trust certificates
|
||||
log "Generating full client keystore"
|
||||
openssl pkcs12 \
|
||||
-export \
|
||||
-in "${clientCertFile}" \
|
||||
-inkey "${clientKeyFile}" \
|
||||
-out "${pcks12FullKeystoreFile}" \
|
||||
-name "mysqlAlias" \
|
||||
-passout pass:kspass
|
||||
|
||||
# Clean up CSR file:
|
||||
rm "$csrFile"
|
||||
rm "$clientReqFile"
|
||||
|
||||
log "Generated key file and certificate in: ${sslDir}"
|
||||
ls -l "${sslDir}"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
@ -1,36 +0,0 @@
|
||||
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
|
@ -1,24 +0,0 @@
|
||||
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"]
|
@ -1,35 +0,0 @@
|
||||
#!/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
|
@ -1,7 +0,0 @@
|
||||
# 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
|
@ -1,121 +0,0 @@
|
||||
# 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
|
@ -1,118 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
###################################################################################################################
|
||||
# test different type of configuration
|
||||
###################################################################################################################
|
||||
export MYSQL_TEST_TRAVIS=1
|
||||
|
||||
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 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
|
||||
|
||||
else
|
||||
|
||||
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
|
||||
###################################################################################################################
|
||||
docker-compose -f ${COMPOSE_FILE} up -d
|
||||
|
||||
###################################################################################################################
|
||||
# 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 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 init process failed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#list ssl certificates
|
||||
ls -lrt ${SSLCERT}
|
||||
|
||||
fi
|
||||
|
||||
#build C connector
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=OPENSSL -DCERT_PATH=${SSLCERT}
|
||||
make
|
||||
|
||||
## list ciphers
|
||||
openssl ciphers -v
|
||||
|
||||
###################################################################################################################
|
||||
# run test suite
|
||||
###################################################################################################################
|
||||
echo "Running tests"
|
||||
|
||||
cd unittest/libmariadb
|
||||
|
||||
ctest -V
|
||||
|
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# get latest server
|
||||
git clone -b ${SERVER_BRANCH} https://github.com/mariadb/server ../workdir-server
|
||||
|
||||
cd ../workdir-server
|
||||
# don't pull in submodules. We want the latest C/C as libmariadb
|
||||
# build latest server with latest C/C as libmariadb
|
||||
# skip to build some storage engines to speed up the build
|
||||
cmake -DPLUGIN_MROONGA=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_SPIDER=NO -DPLUGIN_TOKUDB=NO
|
||||
cd libmariadb
|
||||
git checkout ${TRAVIS_COMMIT}
|
||||
cd ..
|
||||
git add libmariadb
|
||||
make -j9
|
||||
|
||||
cd mysql-test/
|
||||
./mysql-test-run.pl --suite=main ${TEST_OPTION} --parallel=auto --skip-test=session_tracker_last_gtid
|
@ -1,13 +0,0 @@
|
||||
CREATE USER 'bob'@'localhost';
|
||||
GRANT ALL ON *.* TO 'bob'@'localhost' with grant option;
|
||||
|
||||
CREATE USER 'bob'@'%';
|
||||
GRANT ALL ON *.* TO 'bob'@'%' with grant option;
|
||||
|
||||
CREATE USER 'boby'@'%' identified by 'hey';
|
||||
GRANT ALL ON *.* TO 'boby'@'%' identified by 'hey' with grant option;
|
||||
|
||||
CREATE USER 'boby'@'localhost' identified by 'hey';
|
||||
GRANT ALL ON *.* TO 'boby'@'localhost' identified by 'hey' with grant option;
|
||||
|
||||
CREATE DATABASE test2;
|
16
appveyor-download.bat
Normal file
16
appveyor-download.bat
Normal file
@ -0,0 +1,16 @@
|
||||
@echo off
|
||||
set archive=http://ftp.hosteurope.de/mirror/archive.mariadb.org//mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
|
||||
set last=http://mirror.i3d.net/pub/mariadb//mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
|
||||
|
||||
curl -fLsS -o server.msi %archive%
|
||||
|
||||
if %ERRORLEVEL% == 0 goto end
|
||||
|
||||
curl -fLsS -o server.msi %last%
|
||||
if %ERRORLEVEL% == 0 goto end
|
||||
|
||||
echo Failure Reason Given is %errorlevel%
|
||||
exit /b %errorlevel%
|
||||
|
||||
:end
|
||||
echo "File found".
|
15
appveyor.yml
15
appveyor.yml
@ -4,16 +4,16 @@ branches:
|
||||
- 3.1
|
||||
environment:
|
||||
matrix:
|
||||
- DB: '10.2.37'
|
||||
- DB: '10.2.38'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
- DB: '10.3.28'
|
||||
- DB: '10.3.29'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
- DB: '10.4.18'
|
||||
- DB: '10.4.19'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
- DB: '10.5.9'
|
||||
- DB: '10.5.10'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
|
||||
@ -21,15 +21,14 @@ environment:
|
||||
configuration: RelWithDebInfo
|
||||
clone_folder: c:\projects\mariadb-connector-c
|
||||
before_build:
|
||||
- cmd: appveyor-download.bat
|
||||
- cmd: msiexec /i server.msi INSTALLDIR=c:\projects\server SERVICENAME=mariadb ALLOWREMOTEROOTACCESS=true /qn
|
||||
- cmd: "\"c:\\projects\\server\\bin\\mysql.exe\" -e \"create database testc\" --user=root"
|
||||
- cmd: set MYSQL_TEST_USER=root
|
||||
- cmd: set MYSQL_TEST_HOST=127.0.0.1
|
||||
- cmd: set MYSQL_TEST_PASSWD=
|
||||
- cmd: set MYSQL_TEST_PORT=3306
|
||||
- cmd: set MYSQL_TEST_DB=testc
|
||||
- cmd: set archive=http://mariadb.mirrors.ovh.net/MariaDB/mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
|
||||
- cmd: curl -fsS -o server.msi %archive%
|
||||
- cmd: msiexec /i server.msi INSTALLDIR=c:\projects\server SERVICENAME=mariadb ALLOWREMOTEROOTACCESS=true /qn
|
||||
- cmd: "\"c:\\projects\\server\\bin\\mysql.exe\" -e \"create database testc\" --user=root"
|
||||
- cmd: cmake -G "%CMAKE_PARAM%" -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
build:
|
||||
project: mariadb-connector-c.sln
|
||||
|
@ -1,233 +0,0 @@
|
||||
resources:
|
||||
containers:
|
||||
|
||||
- container: ubuntu-1804
|
||||
image: ubuntu:18.04
|
||||
options: "--name ubuntu-1804 --add-host=mariadb.example.com:127.0.0.1 -v /usr/bin/docker:/tmp/docker:ro"
|
||||
|
||||
jobs:
|
||||
|
||||
- job: SSLFiles
|
||||
displayName: 'Creating SSL Files'
|
||||
pool:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
container: $[ variables['containerImage'] ]
|
||||
steps:
|
||||
- script: |
|
||||
java --version
|
||||
mkdir tmp
|
||||
chmod 777 .travis/gen-ssl.sh
|
||||
.travis/gen-ssl.sh mariadb.example.com tmp
|
||||
cp -R tmp $BUILD_ARTIFACTSTAGINGDIRECTORY
|
||||
displayName: 'create SSL certificates'
|
||||
|
||||
- task: PublishPipelineArtifact@0
|
||||
inputs:
|
||||
targetPath: '$(Build.ArtifactStagingDirectory)'
|
||||
artifactName: ssl_certs
|
||||
|
||||
- job: windowsTest
|
||||
displayName: 'test windows'
|
||||
pool:
|
||||
vmImage: 'windows-2019'
|
||||
dependsOn:
|
||||
- SSLFiles
|
||||
steps:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download SSL files'
|
||||
inputs:
|
||||
artifactName: ssl_certs
|
||||
targetPath: $(System.DefaultWorkingDirectory)
|
||||
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download 10.4 server'
|
||||
inputs:
|
||||
source: 'specific'
|
||||
project: '550599d3-6165-4abd-8c86-e3f7e53a1847'
|
||||
artifact: 'Windows'
|
||||
pipeline: 3
|
||||
runVersion: 'latestFromBranch'
|
||||
runBranch: 'refs/heads/10.4-enterprise'
|
||||
downloadPath: $(System.DefaultWorkingDirectory)
|
||||
|
||||
- script: |
|
||||
for /f %%a in ('dir /B $(System.DefaultWorkingDirectory)\win_build\mariadb-enterprise-10.*-winx64.msi') do set servername=$(System.DefaultWorkingDirectory)\win_build\%%a
|
||||
echo %servername%
|
||||
msiexec /i %servername% INSTALLDIR=c:\projects\server SERVICENAME=mariadb ALLOWREMOTEROOTACCESS=true /qn
|
||||
c:\projects\server\bin\mysql.exe -e "create database testc" --user=root
|
||||
c:\projects\server\bin\mysql.exe -e "GRANT ALL on *.* to 'someUser'@'%' identified by 'Passw@rd2' with grant option;" --user=root
|
||||
displayName: 'install server'
|
||||
|
||||
- script: |
|
||||
echo 127.0.0.1 mariadb.example.com >> %WINDIR%\System32\Drivers\Etc\Hosts
|
||||
displayName: 'set hostname'
|
||||
|
||||
- script: |
|
||||
cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
cmake --build . --config RelWithDebInfo
|
||||
displayName: 'build connector'
|
||||
|
||||
- script: |
|
||||
cd $(System.DefaultWorkingDirectory)\unittest\libmariadb
|
||||
set MARIADB_PLUGIN_DIR=$(System.DefaultWorkingDirectory)\plugins\lib\RelWithDebInfo
|
||||
ctest -V
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo Success
|
||||
) else (
|
||||
echo exit code is %errorlevel%
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
displayName: 'run tests'
|
||||
env:
|
||||
MYSQL_TEST_HOST: "mariadb.example.com"
|
||||
MYSQL_TEST_USER: 'someUser'
|
||||
MYSQL_TEST_PASSWD: 'Passw@rd2'
|
||||
MYSQL_TEST_DB: 'testc'
|
||||
MYSQL_TEST_PORT: 3306
|
||||
TEST_SSL_CA_FILE: "$(System.DefaultWorkingDirectory)/tmp/server.crt"
|
||||
TEST_SSL_CLIENT_KEY_FILE: "$(System.DefaultWorkingDirectory)/tmp/client.key"
|
||||
TEST_SSL_CLIENT_CERT_FILE: "$(System.DefaultWorkingDirectory)/tmp/client.crt"
|
||||
TEST_SSL_CLIENT_KEYSTORE_FILE: "$(System.DefaultWorkingDirectory)/tmp/client-keystore.p12"
|
||||
|
||||
- job: RunInContainer
|
||||
pool:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
displayName: 'test ubuntu bionic'
|
||||
dependsOn:
|
||||
- SSLFiles
|
||||
strategy:
|
||||
matrix:
|
||||
ubuntu-1804:
|
||||
containerImage: ubuntu-1804
|
||||
containerName: bionic
|
||||
|
||||
container: $[variables['containerImage']]
|
||||
|
||||
steps:
|
||||
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
artifactName: ssl_certs
|
||||
targetPath: $(System.DefaultWorkingDirectory)
|
||||
|
||||
- script: /tmp/docker exec -t -u 0 $(containerImage) sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
|
||||
displayName: Set up sudo
|
||||
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download 10.4 enterprise server artifact files'
|
||||
inputs:
|
||||
source: 'specific'
|
||||
project: '550599d3-6165-4abd-8c86-e3f7e53a1847'
|
||||
artifact: '$(containerImage)'
|
||||
pipeline: 3
|
||||
runVersion: 'latestFromBranch'
|
||||
runBranch: 'refs/heads/10.4-enterprise'
|
||||
downloadPath: $(System.DefaultWorkingDirectory)
|
||||
|
||||
- task: DownloadPipelineArtifact@2
|
||||
displayName: 'Download galera server artifact files'
|
||||
inputs:
|
||||
source: 'specific'
|
||||
project: '550599d3-6165-4abd-8c86-e3f7e53a1847'
|
||||
artifact: $(containerImage)
|
||||
runVersion: 'latestFromBranch'
|
||||
pipeline: 2
|
||||
runBranch: 'refs/heads/es-mariadb-4.x'
|
||||
downloadPath: $(System.DefaultWorkingDirectory)
|
||||
|
||||
|
||||
- script: |
|
||||
tar xf mariadb-enterprise*
|
||||
|
||||
sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime
|
||||
|
||||
sudo apt-get update && sudo apt-get install -y --no-install-recommends apt-transport-https ca-certificates tzdata pwgen
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
sudo debconf-set-selections <<< "mariadb-server-10.4 mysql-server/root_password password P4ssw@rd"
|
||||
sudo debconf-set-selections <<< "mariadb-server-10.4 mysql-server/root_password_again password P4ssw@rd"
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install --allow-unauthenticated -f -y libssl-dev libaio1 libaio-dev libxml2 libcurl4 curl libc-dev linux-libc-dev libc-dev-bin libdbi-perl rsync socat libnuma1 zlib1g-dev libreadline5 libjemalloc1 libsnappy1v5 libcrack2 gawk lsof psmisc perl libreadline5
|
||||
|
||||
cd mariadb-enterprise*/
|
||||
sudo groupadd mysql
|
||||
sudo useradd -g mysql mysql
|
||||
|
||||
export PROJ_PATH=`pwd`
|
||||
echo $PROJ_PATH
|
||||
|
||||
cat <<EOT >> my.cnf
|
||||
[mysqld]
|
||||
port=3306
|
||||
max_allowed_packet=16M
|
||||
datadir=$PROJ_PATH/data
|
||||
socket=/tmp/mysql.sock
|
||||
user=mysql
|
||||
ssl-ca=$(System.DefaultWorkingDirectory)/tmp/ca.crt
|
||||
ssl-cert=$(System.DefaultWorkingDirectory)/tmp/server.crt
|
||||
ssl-key=$(System.DefaultWorkingDirectory)/tmp/server.key
|
||||
EOT
|
||||
|
||||
sudo chown mysql $PROJ_PATH/my.cnf
|
||||
sudo tail -n 5000 $PROJ_PATH/my.cnf
|
||||
|
||||
sudo chmod 777 $PROJ_PATH
|
||||
sudo ln -s $PROJ_PATH /usr/local/mysql
|
||||
|
||||
sudo ./scripts/mysql_install_db --defaults-file=$PROJ_PATH/my.cnf --user=mysql
|
||||
sudo chown -R root .
|
||||
sudo chown -R mysql data
|
||||
|
||||
export PATH=$PATH:$PROJ_PATH/bin/
|
||||
|
||||
env:
|
||||
WORKING_DIR: $(System.DefaultWorkingDirectory)
|
||||
displayName: 'install server'
|
||||
|
||||
- script: |
|
||||
sudo apt-get install -f -y make cmake
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=OPENSSL -DCERT_PATH=$(System.DefaultWorkingDirectory)/tmp
|
||||
make
|
||||
displayName: 'Build'
|
||||
|
||||
- script: |
|
||||
cd mariadb-enterprise*/
|
||||
sudo ./bin/mysqld --defaults-file=./my.cnf &
|
||||
|
||||
for i in {30..0}; do
|
||||
if sudo ./bin/mysql -e "SELECT 1" &> /dev/null; then
|
||||
echo 'MySQL connected...'
|
||||
break
|
||||
fi
|
||||
echo 'MySQL init process in progress...'
|
||||
sleep 1
|
||||
done
|
||||
if [ "$i" = 0 ]; then
|
||||
echo >&2 'MySQL init process failed.'
|
||||
sudo ./bin/mysql -e "SELECT 1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo ./bin/mysql -e "CREATE USER 'someUser'@'%' identified by 'Passw@rd2';"
|
||||
sudo ./bin/mysql -e "GRANT ALL on *.* to 'someUser'@'%' identified by 'Passw@rd2' with grant option;"
|
||||
sudo ./bin/mysql -e "CREATE DATABASE testc;"
|
||||
|
||||
echo "Running tests"
|
||||
cd ../unittest/libmariadb
|
||||
ctest -V
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
cd $(System.DefaultWorkingDirectory)/mariadb-enterprise*/
|
||||
sudo ./bin/mysqladmin shutdown
|
||||
env:
|
||||
MYSQL_TEST_HOST: mariadb.example.com
|
||||
MYSQL_TEST_DB: testc
|
||||
MYSQL_TEST_USER: 'someUser'
|
||||
MYSQL_TEST_PORT: 3306
|
||||
MYSQL_TEST_TRAVIS: 1
|
||||
MYSQL_TEST_PASSWD: 'Passw@rd2'
|
||||
TEST_SSL_CA_FILE: "$(System.DefaultWorkingDirectory)/tmp/server.crt"
|
||||
TEST_SSL_CLIENT_KEY_FILE: "$(System.DefaultWorkingDirectory)/tmp/client.key"
|
||||
TEST_SSL_CLIENT_CERT_FILE: "$(System.DefaultWorkingDirectory)/tmp/client.crt"
|
||||
TEST_SSL_CLIENT_KEYSTORE_FILE: "$(System.DefaultWorkingDirectory)/tmp/client-keystore.p12"
|
||||
displayName: 'run tests'
|
87
travis.sh
Executable file
87
travis.sh
Executable file
@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -n "$server_branch" ] ; then
|
||||
|
||||
###################################################################################################################
|
||||
# run server test suite
|
||||
###################################################################################################################
|
||||
echo "run server test suite"
|
||||
|
||||
# change travis localhost to use only 127.0.0.1
|
||||
sudo sed -i 's/127\.0\.1\.1 localhost/127.0.0.1 localhost/' /etc/hosts
|
||||
sudo tail /etc/hosts
|
||||
|
||||
# get latest server
|
||||
git clone -b ${server_branch} https://github.com/mariadb/server ../workdir-server
|
||||
|
||||
cd ../workdir-server
|
||||
# don't pull in submodules. We want the latest C/C as libmariadb
|
||||
# build latest server with latest C/C as libmariadb
|
||||
# skip to build some storage engines to speed up the build
|
||||
cmake -DPLUGIN_MROONGA=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_SPIDER=NO -DPLUGIN_TOKUDB=NO
|
||||
cd libmariadb
|
||||
if [ -z "$TRAVIS_PULL_REQUEST" ] ; then
|
||||
# fetching pull request
|
||||
git fetch origin pull/${TRAVIS_PULL_REQUEST}/head:PR_${TRAVIS_PULL_REQUEST}
|
||||
git checkout PR_${TRAVIS_PULL_REQUEST}
|
||||
else
|
||||
git checkout ${TRAVIS_COMMIT}
|
||||
fi
|
||||
|
||||
cd ..
|
||||
git add libmariadb
|
||||
make -j9
|
||||
|
||||
cd mysql-test/
|
||||
./mysql-test-run.pl --suite=main ${TEST_OPTION} --parallel=auto --skip-test=session_tracker_last_gtid
|
||||
|
||||
else
|
||||
|
||||
###################################################################################################################
|
||||
# run connector test suite
|
||||
###################################################################################################################
|
||||
echo "run connector test suite"
|
||||
|
||||
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCERT_PATH=${SSLCERT}
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" = "windows" ] ; then
|
||||
echo "build from windows"
|
||||
set MYSQL_TEST_DB=testc
|
||||
set MYSQL_TEST_TLS=%TEST_REQUIRE_TLS%
|
||||
set MYSQL_TEST_USER=%TEST_DB_USER%
|
||||
set MYSQL_TEST_HOST=%TEST_DB_HOST%
|
||||
set MYSQL_TEST_PASSWD=%TEST_DB_PASSWORD%
|
||||
set MYSQL_TEST_PORT=%TEST_DB_PORT%
|
||||
set MYSQL_TEST_TLS=%TEST_REQUIRE_TLS%
|
||||
cmake --build . --config RelWithDebInfo
|
||||
else
|
||||
echo "build from linux"
|
||||
export MYSQL_TEST_USER=$TEST_DB_USER
|
||||
export MYSQL_TEST_HOST=$TEST_DB_HOST
|
||||
export MYSQL_TEST_PASSWD=$TEST_DB_PASSWORD
|
||||
export MYSQL_TEST_PORT=$TEST_DB_PORT
|
||||
export MYSQL_TEST_DB=testc
|
||||
export MYSQL_TEST_TLS=$TEST_REQUIRE_TLS
|
||||
export SSLCERT=$TEST_DB_SERVER_CERT
|
||||
export MARIADB_PLUGIN_DIR=$PWD
|
||||
|
||||
echo "MYSQL_TEST_PLUGINDIR=$MYSQL_TEST_PLUGINDIR"
|
||||
if [ -n "$MYSQL_TEST_SSL_PORT" ] ; then
|
||||
export MYSQL_TEST_SSL_PORT=$MYSQL_TEST_SSL_PORT
|
||||
fi
|
||||
export MYSQL_TEST_TLS=$TEST_REQUIRE_TLS
|
||||
export SSLCERT=$TEST_DB_SERVER_CERT
|
||||
if [ -n "$MYSQL_TEST_SSL_PORT" ] ; then
|
||||
export MYSQL_TEST_SSL_PORT=$MYSQL_TEST_SSL_PORT
|
||||
fi
|
||||
make
|
||||
fi
|
||||
|
||||
ls -lrt
|
||||
|
||||
openssl ciphers -v
|
||||
cd unittest/libmariadb
|
||||
ctest -V
|
||||
fi
|
@ -572,7 +572,11 @@ static int test_bug30472(MYSQL *mysql)
|
||||
FAIL_UNLESS(strncmp(character_set_name_2, "utf8", 4) == 0, "cs_name != utf8");
|
||||
FAIL_UNLESS(strncmp(character_set_client_2, "utf8", 4) == 0, "cs_client != utf8");
|
||||
FAIL_UNLESS(strncmp(character_set_results_2, "utf8", 4) == 0, "cs_result != ut8");
|
||||
FAIL_UNLESS(strcmp(collation_connnection_2, "utf8_general_ci") == 0, "collation != utf8_general_ci");
|
||||
if (mariadb_connection(mysql) && mysql_get_server_version(mysql) < 100600) {
|
||||
FAIL_UNLESS(strcmp(collation_connnection_2, "utf8_general_ci") == 0, "collation != utf8_general_ci");
|
||||
} else {
|
||||
FAIL_UNLESS(strcmp(collation_connnection_2, "utf8mb3_general_ci") == 0, "collation != utf8_general_ci");
|
||||
}
|
||||
|
||||
diag("%s %s", character_set_name_1, character_set_name_2);
|
||||
FAIL_UNLESS(strcmp(character_set_name_1, character_set_name_2) != 0, "cs_name1 = cs_name2");
|
||||
@ -622,11 +626,16 @@ static int test_bug30472(MYSQL *mysql)
|
||||
collation_connnection_4);
|
||||
|
||||
/* Check that we have UTF8 on the server and on the client. */
|
||||
|
||||
FAIL_UNLESS(strcmp(character_set_name_4, "utf8") == 0, "cs_name != utf8");
|
||||
FAIL_UNLESS(strcmp(character_set_client_4, "utf8") == 0, "cs_client != utf8");
|
||||
FAIL_UNLESS(strcmp(character_set_results_4, "utf8") == 0, "cs_result != utf8");
|
||||
FAIL_UNLESS(strcmp(collation_connnection_4, "utf8_general_ci") == 0, "collation_connection != utf8_general_ci");
|
||||
if (mariadb_connection(mysql) && mysql_get_server_version(mysql) < 100600) {
|
||||
FAIL_UNLESS(strcmp(character_set_client_4, "utf8") == 0, "cs_client != utf8");
|
||||
FAIL_UNLESS(strcmp(character_set_results_4, "utf8") == 0, "cs_result != utf8");
|
||||
FAIL_UNLESS(strcmp(collation_connnection_4, "utf8_general_ci") == 0, "collation_connection != utf8_general_ci");
|
||||
} else {
|
||||
FAIL_UNLESS(strcmp(character_set_client_4, "utf8mb3") == 0, "cs_client != utf8");
|
||||
FAIL_UNLESS(strcmp(character_set_results_4, "utf8mb3") == 0, "cs_result != utf8");
|
||||
FAIL_UNLESS(strcmp(collation_connnection_4, "utf8mb3_general_ci") == 0, "collation_connection != utf8_general_ci");
|
||||
}
|
||||
|
||||
/* That's it. Cleanup. */
|
||||
|
||||
@ -647,8 +656,12 @@ static int test_bug_54100(MYSQL *mysql)
|
||||
while ((row= mysql_fetch_row(result)))
|
||||
{
|
||||
/* ignore ucs2 */
|
||||
if (strcmp(row[0], "ucs2") && strcmp(row[0], "utf16le") && strcmp(row[0], "utf8mb4") &&
|
||||
strcmp(row[0], "utf16") && strcmp(row[0], "utf32")) {
|
||||
if (strcmp(row[0], "ucs2")
|
||||
&& strcmp(row[0], "utf16le")
|
||||
&& (strcmp(row[0], "utf8mb4") && mariadb_connection(mysql) && mysql_get_server_version(mysql) < 100600)
|
||||
&& (strcmp(row[0], "utf8") && mariadb_connection(mysql) && mysql_get_server_version(mysql) >= 100600)
|
||||
&& strcmp(row[0], "utf16")
|
||||
&& strcmp(row[0], "utf32")) {
|
||||
rc= mysql_set_character_set(mysql, row[0]);
|
||||
check_mysql_rc(rc, mysql);
|
||||
}
|
||||
@ -777,6 +790,7 @@ static int charset_auto(MYSQL *my __attribute__((unused)))
|
||||
/* check if all server character sets are supported */
|
||||
static int test_conc223(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MYSQL(mysql);
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -980,9 +980,14 @@ static int test_sess_track_db(MYSQL *mysql)
|
||||
do {
|
||||
printf("# SESSION_TRACK_VARIABLES: %*.*s\n", (int)len, (int)len, data);
|
||||
} while (!mysql_session_track_get_next(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len));
|
||||
diag("charset: %s", mysql->charset->csname);
|
||||
FAIL_IF(strncmp(mysql->charset->csname, "utf8", 4), "Expected charset 'utf8'");
|
||||
|
||||
diag("charset: %s", mysql->charset->csname);
|
||||
if (mariadb_connection(mysql) && mysql_get_server_version(mysql) >= 100600) {
|
||||
diag("skipping since utf8mb3 isn't handled in 3.1");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
FAIL_IF(strcmp(mysql->charset->csname, "utf8"), "Expected charset 'utf8'");
|
||||
rc= mysql_query(mysql, "SET NAMES latin1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
FAIL_IF(strcmp(mysql->charset->csname, "latin1"), "Expected charset 'latin1'");
|
||||
@ -1633,6 +1638,9 @@ static int test_conc351(MYSQL *unused __attribute__((unused)))
|
||||
diag("Server doesn't support session tracking (cap=%lu)", mysql->server_capabilities);
|
||||
return SKIP;
|
||||
}
|
||||
rc= mysql_query(mysql, "USE mysql");
|
||||
check_mysql_rc(rc, mysql);
|
||||
FAIL_IF(strcmp(mysql->db, "mysql"), "Expected new schema 'mysql'");
|
||||
|
||||
FAIL_IF(mysql_session_track_get_first(mysql, SESSION_TRACK_SCHEMA, &data, &len), "expected session track schema");
|
||||
|
||||
@ -1712,8 +1720,11 @@ static int test_conc366(MYSQL *mysql)
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
|
||||
sprintf(query, "CREATE OR REPLACE USER 'ede'@'%s' IDENTIFIED VIA ed25519 USING 'vubFBzIrapbfHct1/J72dnUryz5VS7lA6XHH8sIx4TI'", this_host);
|
||||
if (mysql_get_server_version(mysql) < 100400) {
|
||||
sprintf(query, "CREATE OR REPLACE USER 'ede'@'%s' IDENTIFIED VIA ed25519 USING '6aW9C7ENlasUfymtfMvMZZtnkCVlcb1ssxOLJ0kj/AA'", this_host);
|
||||
} else {
|
||||
sprintf(query, "CREATE OR REPLACE USER 'ede'@'%s' IDENTIFIED VIA ed25519 USING PASSWORD('MySup8%rPassw@ord')", this_host);
|
||||
}
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@ -1724,7 +1735,7 @@ static int test_conc366(MYSQL *mysql)
|
||||
my= mysql_init(NULL);
|
||||
if (plugindir)
|
||||
mysql_options(my, MYSQL_PLUGIN_DIR, plugindir);
|
||||
if (!my_test_connect(my, hostname, "ede", "foo", schema, port, socketname, 0))
|
||||
if (!my_test_connect(my, hostname, "ede", "MySup8%rPassw@ord", schema, port, socketname, 0))
|
||||
{
|
||||
diag("Error: %s", mysql_error(my));
|
||||
return FAIL;
|
||||
@ -1743,6 +1754,7 @@ static int test_conc366(MYSQL *mysql)
|
||||
|
||||
static int test_conc392(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MYSQL(mysql);
|
||||
int rc;
|
||||
const char *data;
|
||||
size_t len;
|
||||
|
@ -283,6 +283,7 @@ static int test_cursors_with_union(MYSQL *mysql)
|
||||
|
||||
static int test_cursors_with_procedure(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MYSQL(mysql);
|
||||
const char *queries[]=
|
||||
{
|
||||
"SELECT * FROM t1 procedure analyse()"
|
||||
@ -1493,19 +1494,16 @@ static int test_bug38486(MYSQL *mysql)
|
||||
int rc;
|
||||
unsigned long type= CURSOR_TYPE_READ_ONLY;
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*)&type);
|
||||
check_stmt_rc(rc, stmt);
|
||||
stmt_text= "CREATE TABLE t1 (a INT)";
|
||||
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
|
||||
check_stmt_rc(rc, stmt);
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
mysql_stmt_close(stmt);
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t10");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "CREATE TABLE t10 (a INT)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*)&type);
|
||||
check_stmt_rc(rc, stmt);
|
||||
stmt_text= "INSERT INTO t1 VALUES (1)";
|
||||
stmt_text= "INSERT INTO t10 VALUES (1)";
|
||||
rc= mysql_stmt_prepare(stmt, SL(stmt_text));
|
||||
check_stmt_rc(rc, stmt);
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
|
@ -28,6 +28,9 @@ static int execute_direct(MYSQL *mysql)
|
||||
rc= mariadb_stmt_execute_direct(stmt, "CREATE TABLE t1 (a int)", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
memset(&bind, 0, sizeof(MYSQL_BIND));
|
||||
|
||||
bind.buffer= &i;
|
||||
@ -43,6 +46,9 @@ static int execute_direct(MYSQL *mysql)
|
||||
rc= mariadb_stmt_execute_direct(stmt, "INSERT INTO t1 VALUES (?)", -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_query(mysql, "START TRANSACTION");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
for (i=1; i < 1000; i++)
|
||||
{
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
@ -58,6 +64,8 @@ static int execute_direct(MYSQL *mysql)
|
||||
FAIL_IF(mysql_num_rows(res) != 1000, "Expected 1000 rows");
|
||||
|
||||
mysql_free_result(res);
|
||||
rc= mysql_query(mysql, "COMMIT");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@ -475,6 +475,9 @@ static int test_wl4166_2(MYSQL *mysql)
|
||||
"alter table t1 change column c_int c_int varchar(11)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
@ -509,6 +512,9 @@ static int test_wl4166_2(MYSQL *mysql)
|
||||
rc= mysql_query(mysql, "alter table t1 add column d_int int");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
|
||||
@ -769,11 +775,26 @@ static int test_wl4284_1(MYSQL *mysql)
|
||||
static int test_bug49694(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
int i;
|
||||
FILE *fp;
|
||||
|
||||
diag("Load local infile server : %ld", (mysql->server_capabilities & CLIENT_LOCAL_FILES));
|
||||
diag("Load local infile client : %ld", (mysql->client_flag & CLIENT_LOCAL_FILES));
|
||||
|
||||
SKIP_LOAD_INFILE_DISABLE;
|
||||
SKIP_SKYSQL;
|
||||
|
||||
rc= mysql_query(mysql, "select @@LOCAL_INFILE");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_store_result(mysql);
|
||||
row= mysql_fetch_row(res);
|
||||
if (atol(row[0]) == 0) {
|
||||
diag("Load local infile disable");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS enclist");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@ -803,6 +824,7 @@ static int test_bug49694(MYSQL *mysql)
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE enclist");
|
||||
check_mysql_rc(rc, mysql);
|
||||
mysql_free_result(res);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -810,12 +832,23 @@ static int test_conc49(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
int i;
|
||||
FILE *fp;
|
||||
|
||||
SKIP_LOAD_INFILE_DISABLE;
|
||||
SKIP_SKYSQL;
|
||||
|
||||
rc= mysql_query(mysql, "select @@LOCAL_INFILE");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_store_result(mysql);
|
||||
row= mysql_fetch_row(res);
|
||||
if (atol(row[0]) == 0) {
|
||||
diag("Load local infile disable");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
fp= fopen("./sample.csv", "w");
|
||||
for (i=1; i < 4; i++)
|
||||
fprintf(fp, "\"%d\", \"%d\", \"%d\"\r\n", i, i, i);
|
||||
@ -848,6 +881,9 @@ static int test_ldi_path(MYSQL *mysql)
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "FLUSH TABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
#ifdef _WIN32
|
||||
rc= mysql_query(mysql, "LOAD DATA LOCAL INFILE 'X:/non_existing_path/data.csv' INTO TABLE t1 "
|
||||
"FIELDS TERMINATED BY '.' LINES TERMINATED BY '\r\n'");
|
||||
@ -1028,6 +1064,8 @@ static int test_remote1(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
SKIP_SKYSQL;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
remote_plugin= (void *)mysql_client_find_plugin(mysql, "remote_io", MARIADB_CLIENT_REMOTEIO_PLUGIN);
|
||||
if (!remote_plugin)
|
||||
@ -1037,6 +1075,18 @@ static int test_remote1(MYSQL *mysql)
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
SKIP_LOAD_INFILE_DISABLE;
|
||||
|
||||
rc= mysql_query(mysql, "select @@LOCAL_INFILE");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_store_result(mysql);
|
||||
row= mysql_fetch_row(res);
|
||||
if (atol(row[0]) == 0) {
|
||||
diag("Load local infile disable");
|
||||
return SKIP;
|
||||
}
|
||||
mysql_free_result(res);
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
|
@ -73,7 +73,7 @@ if (IS_SKYSQL(hostname)) \
|
||||
#define SKIP_NOTLS
|
||||
#endif
|
||||
|
||||
#define IS_MAXSCALE() (getenv("MAXSCALE_TEST_DISABLE")!=NULL)
|
||||
#define IS_MAXSCALE() (getenv("srv")!=NULL && (strcmp(getenv("srv"), "maxscale") == 0 || strcmp(getenv("srv"), "skysql-ha") == 0))
|
||||
#define SKIP_MAXSCALE \
|
||||
if (IS_MAXSCALE()) \
|
||||
{ \
|
||||
@ -496,6 +496,8 @@ MYSQL *test_connect(struct my_tests_st *test)
|
||||
}
|
||||
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, &truncation_report);
|
||||
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
|
||||
if (plugindir)
|
||||
mysql_options(mysql, MYSQL_PLUGIN_DIR, plugindir);
|
||||
|
||||
/* option handling */
|
||||
if (test && test->options) {
|
||||
@ -554,7 +556,7 @@ static int reset_connection(MYSQL *mysql) {
|
||||
void get_envvars() {
|
||||
char *envvar;
|
||||
|
||||
if (getenv("MYSQL_TEST_TRAVIS"))
|
||||
if (getenv("TRAVIS_JOB_ID"))
|
||||
travis_test= 1;
|
||||
|
||||
if (!hostname && (envvar= getenv("MYSQL_TEST_HOST")))
|
||||
|
@ -674,6 +674,7 @@ static int test_bug1500(MYSQL *mysql)
|
||||
|
||||
static int test_bug15510(MYSQL *mysql)
|
||||
{
|
||||
SKIP_MYSQL(mysql);
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
const char *query= "select 1 from dual where 1/0";
|
||||
@ -2070,7 +2071,7 @@ static int test_bug36004(MYSQL *mysql)
|
||||
int rc, warning_count= 0;
|
||||
MYSQL_STMT *stmt;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
SKIP_MYSQL(mysql); // don't send expected warnings
|
||||
|
||||
if (mysql_get_server_version(mysql) < 60000) {
|
||||
diag("Test requires MySQL Server version 6.0 or above");
|
||||
|
@ -426,8 +426,7 @@ static int test_view_insert_fields(MYSQL *mysql)
|
||||
"F7F8 double NOT NULL default '0',"
|
||||
"F8F8 double NOT NULL default '0',"
|
||||
"F9D8 decimal(8,2) NOT NULL default '0.00',"
|
||||
"PRIMARY KEY (K1C4,K2C4,K3C4,K4N4)) "
|
||||
"CHARSET=latin1 COLLATE latin1_bin");
|
||||
"PRIMARY KEY (K1C4,K2C4,K3C4,K4N4))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql,
|
||||
"CREATE VIEW v1 AS select sql_no_cache "
|
||||
|
Loading…
x
Reference in New Issue
Block a user