Skip to content

Commit

Permalink
[CONJ-827] update maxscale test to recent version
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Sep 14, 2020
1 parent 8e2d523 commit 5bf84cc
Show file tree
Hide file tree
Showing 26 changed files with 247 additions and 160 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ cache:
directories:
- $HOME/.m2

env:
- SSLPORT=3305

matrix:
allow_failures:
- env: DB=build PACKET=8M
Expand All @@ -36,8 +39,6 @@ matrix:
jdk: openjdk11
- env: SKYSQL=true PACKET=8M
jdk: openjdk11
- env: DB=mysql:5.6 PACKET=8M
jdk: openjdk11
- env: DB=mysql:5.7 PACKET=8M
jdk: openjdk11
- env: DB=mysql:8.0 PACKET=8M ADDITIONAL_CONF=--default-authentication-plugin=mysql_native_password --caching_sha2_password_private_key_path=/etc/sslcert/server.key --caching_sha2_password_public_key_path=/etc/sslcert/public.key
Expand Down Expand Up @@ -78,7 +79,7 @@ matrix:
jdk: openjdk11
- env: DB=mariadb:10.5 PACKET=8M
jdk: openjdk12
- env: DB=mariadb:10.5 PACKET=8M MAXSCALE_VERSION=2.2.9
- env: DB=mariadb:10.5 PACKET=8M MAXSCALE_VERSION=2.5.3 MAXSCALE_TEST_DISABLE=true SSLPORT=4009
jdk: openjdk11

script:
Expand Down
34 changes: 22 additions & 12 deletions .travis/maxscale-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
version: '2.1'
services:
maxscale:
depends_on:
- db
ports:
- 4006:4006
- 4007:4007
- 4008:4008
build:
context: .
dockerfile: maxscale/Dockerfile
args:
MAXSCALE_VERSION: $MAXSCALE_VERSION
db:
image: $DB
command: --max-connections=500 --max-allowed-packet=$PACKET --innodb-log-file-size=$INNODB_LOG_FILE_SIZE --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
Expand All @@ -23,3 +11,25 @@ services:
environment:
MYSQL_DATABASE: testj
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
test: ["CMD", "mysql", "--protocol=tcp", "-ubob", "-h127.0.0.1", "-ubob"]
timeout: 20s
retries: 10

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
6 changes: 3 additions & 3 deletions .travis/maxscale/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM centos:7

ARG MAXSCALE_VERSION
ENV MAXSCALE_VERSION ${MAXSCALE_VERSION:-2.1.4}
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}-1.centos.7.x86_64.rpm \
&& 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 /
RUN chmod 777 /etc/maxscale.cnf
COPY maxscale/maxscale.cnf /etc/
RUN chmod 777 /etc/maxscale.cnf
RUN chmod 777 /docker-entrypoint.sh


Expand Down
118 changes: 57 additions & 61 deletions .travis/maxscale/maxscale.cnf
Original file line number Diff line number Diff line change
@@ -1,45 +1,59 @@
# MaxScale documentation on GitHub:
# https://github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Documentation-Contents.md
# MaxScale documentation:
# https://mariadb.com/kb/en/mariadb-maxscale-24/

# Global parameters
#
# Complete list of configuration options:
# https://github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Getting-Started/Configuration-Guide.md

# https://mariadb.com/kb/en/mariadb-maxscale-24-mariadb-maxscale-configuration-guide/

[maxscale]
threads=2
log_messages=1
log_trace=1
log_debug=1
threads=auto

# Server definitions
#
# Set the address of the server to the network
# address of a MySQL server.
# 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
authenticator_options=skip_authentication=true
router_options=master


# Monitor for the servers
#
# This will keep MaxScale aware of the state of the servers.
# MySQL Monitor documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Monitors/MySQL-Monitor.md
# MariaDB Monitor documentation:
# https://mariadb.com/kb/en/mariadb-maxscale-24-mariadb-monitor/

[MySQLMonitor]
[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=server1
user=boby
passwd=hey
monitor_interval=10000
password=hey
monitor_interval=2000

[MariaDB-Monitor2]
type=monitor
module=mariadbmon
servers=server2
user=boby
password=hey
monitor_interval=2000

# Service definitions
#
Expand All @@ -48,78 +62,60 @@ monitor_interval=10000
#

# ReadConnRoute documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Routers/ReadConnRoute.md
# https://mariadb.com/kb/en/mariadb-maxscale-24-readconnroute/

[Read-OnlyService]
enable_root_user=1
version_string=10.4.99-MariaDB-maxScale
[Read-Only-Service]
type=service
router=readconnroute
servers=server1
user=boby
passwd=hey
password=hey
router_options=slave
localhost_match_wildcard_host=1

[Read-WriteService]
enable_root_user=1
version_string=10.4.99-MariaDB-maxScale
# 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
passwd=hey
localhost_match_wildcard_host=1
password=hey

[WriteService]
[Read-Write-Service2]
type=service
router=readconnroute
servers=server1
router=readwritesplit
version_string=10.5.99-MariaDB-maxScale
servers=server2
user=boby
passwd=hey
router_options=master
localhost_match_wildcard_host=1
version_string=10.4.99-MariaDB-maxscale


# This service enables the use of the MaxAdmin interface
# MaxScale administration guide:
# https://github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Reference/MaxAdmin.mda

[MaxAdminService]
enable_root_user=1
version_string=10.4.99-MariaDB-maxScale
type=service
router=cli
password=hey

# Listener definitions for the services
#
# These listeners represent the ports the
# services will listen on.
#
[WriteListener]
type=listener
service=WriteService
protocol=MariaDBClient
port=4007
#socket=/var/lib/maxscale/writeconn.sock

[Read-OnlyListener]
[Read-Only-Listener]
type=listener
service=Read-OnlyService
service=Read-Only-Service
protocol=MariaDBClient
port=4008
#socket=/var/lib/maxscale/readconn.sock

[Read-WriteListener]
[Read-Write-Listener]
type=listener
service=Read-WriteService
service=Read-Write-Service
protocol=MariaDBClient
port=4006
#socket=/var/lib/maxscale/rwsplit.sock

[MaxAdminListener]

[Read-Write-Listener2]
type=listener
service=MaxAdminService
protocol=maxscaled
socket=/tmp/maxadmin.sock
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
19 changes: 10 additions & 9 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ else
-Dkeystore2Password="kspass" -DkeyPassword="kspasskey" \
-Dkeystore2PathP12="$SSLCERT/fullclient-keystore.p12" \
-DrunLongTest=true \
-DserverPublicKey="$SSLCERT/public.key" )
-DserverPublicKey="$SSLCERT/public.key"\
-DsslPort="$SSLPORT")

if [ -n "$AURORA" ] ; then
if [ -n "$AURORA_STRING_URL" ] ; then
Expand All @@ -82,9 +83,9 @@ else
###################################################################################################################
# launch Maxscale with one server
###################################################################################################################
mysql=( mysql --protocol=tcp -ubob -h127.0.0.1 --port=4007 )
mysql=( mysql --protocol=TCP -ubob -h127.0.0.1 --port=4006 test2)
export COMPOSE_FILE=.travis/maxscale-compose.yml
urlString='jdbc:mariadb://mariadb.example.com:4007/testj?user=bob&killFetchStmtOnClose=false&enablePacketDebug=true'
urlString='jdbc:mariadb://mariadb.example.com:4006/testj?user=bob&enablePacketDebug=true'
docker-compose -f ${COMPOSE_FILE} build
docker-compose -f ${COMPOSE_FILE} up -d
else
Expand All @@ -93,15 +94,15 @@ else
###################################################################################################################
# launch 3 galera servers
###################################################################################################################
mysql=( mysql --protocol=tcp -ubob -hmariadb.example.com --port=3106 )
mysql=( mysql --protocol=TCP -ubob -hmariadb.example.com --port=3106 test2)
export COMPOSE_FILE=.travis/galera-compose.yml

urlString='jdbc:mariadb://mariadb.example.com:3106/testj?user=bob&enablePacketDebug=true'
cmd+=( -DdefaultGaleraUrl="jdbc:mariadb:sequential://mariadb.example.com:3106,mariadb.example.com:3107,mariadb.example.com:3108/testj?user=bob&enablePacketDebug=true" -DdefaultSequentialUrl="jdbc:mariadb:sequential://mariadb.example.com:3106,mariadb.example.com:3107,mariadb.example.com:3108/testj?user=bob&enablePacketDebug=true" -DdefaultLoadbalanceUrl="jdbc:mariadb:loadbalance://mariadb.example.com:3106,mariadb.example.com:3107,mariadb.example.com:3108/testj?user=bob&enablePacketDebug=true" )
docker-compose -f ${COMPOSE_FILE} up -d
SLEEP 10
else
mysql=( mysql --protocol=tcp -ubob -hmariadb.example.com --port=3106 )
mysql=( mysql --protocol=tcp -ubob -hmariadb.example.com --port=3106 test2)

urlString='jdbc:mariadb://mariadb.example.com:3106/testj?user=bob&enablePacketDebug=true'
docker run \
Expand Down Expand Up @@ -135,7 +136,7 @@ else
###################################################################################################################
# launch docker server
###################################################################################################################
mysql=( mysql --protocol=tcp -ubob -h127.0.0.1 --port=3305 )
mysql=( mysql --protocol=TCP -ubob -hmariadb.example.com --port=3305 test2)
export COMPOSE_FILE=.travis/docker-compose.yml
docker-compose -f ${COMPOSE_FILE} up -d

Expand All @@ -147,12 +148,12 @@ else
# wait for docker initialisation
###################################################################################################################

for i in {60..0}; do
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
for i in {15..0}; do
if echo 'SELECT 1' | "${mysql[@]}" ; then
break
fi
echo 'data server still not active'
sleep 1
sleep 2
done


Expand Down
8 changes: 7 additions & 1 deletion .travis/sql/dbinit.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
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'@'%' with grant option;
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;

FLUSH PRIVILEGES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ private void postConnectionQueries() throws SQLException {
sendPipelineAdditionalData();
readPipelineAdditionalData(serverData);
} catch (SQLException sqle) {
if ("08".equals(sqle.getSQLState())) {
if (sqle.getSQLState() != null && sqle.getSQLState().startsWith("08")) {
throw sqle;
}
// in case pipeline is not supported
Expand Down Expand Up @@ -1031,6 +1031,18 @@ private void readPipelineAdditionalData(Map<String, String> serverData) throws S
try {
readRequestSessionVariables(serverData);
} catch (SQLException sqlException) {
if (resultingException != null) {
if (resultingException.getSQLState() != null
&& !resultingException.getSQLState().startsWith("08")
&& sqlException.getSQLState() != null
&& sqlException.getSQLState().startsWith("08")) {
throw new SQLException(
resultingException.getMessage(),
"08000",
resultingException.getErrorCode(),
resultingException);
}
}
if (resultingException == null) {
resultingException =
exceptionFactory.create("could not load system variables", "08000", sqlException);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
import static org.mariadb.jdbc.internal.com.Packet.*;
import static org.mariadb.jdbc.internal.util.SqlStates.*;

import java.io.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
Expand Down
Loading

0 comments on commit 5bf84cc

Please sign in to comment.