This commit is contained in:
Carlos Salguero
2018-01-25 00:01:56 -03:00
parent d9ae64e443
commit f3132d3cee
24 changed files with 445 additions and 435 deletions

Binary file not shown.

View File

@@ -28,10 +28,12 @@ relay_log = mysql-relay-bin
report-host = 127.0.0.1 report-host = 127.0.0.1
report-port = PORT report-port = PORT
server-id = PORT server-id = PORT
#local_infile = ON
#default_authentication_plugin=mysql_native_password
# fkc test # fkc test
binlog_format = STATEMENT binlog_format = STATEMENT
performance_schema = ON #performance_schema = ON
#performance-schema-instrument='wait/lock/metadata/sql/mdl=ON' #performance-schema-instrument='wait/lock/metadata/sql/mdl=ON'
#performance-schema-instrument='transaction=ON' #performance-schema-instrument='transaction=ON'
secure-file-priv = secure-file-priv =

View File

@@ -2,8 +2,8 @@
start_ts=$(date +%s) start_ts=$(date +%s)
PIDFILE="/tmp/PORT/data/mysql_sandboxPORT.pid" PIDFILE="TMP_DIR/PORT/data/mysql_sandboxPORT.pid"
SOCKETFILE="/tmp/PORT/mysql_sandboxPORT.sock" SOCKETFILE="TMP_DIR/PORT/mysql_sandboxPORT.sock"
BASEDIR="PERCONA_TOOLKIT_SANDBOX" BASEDIR="PERCONA_TOOLKIT_SANDBOX"
sandbox_is_alive() { sandbox_is_alive() {
@@ -11,14 +11,14 @@ sandbox_is_alive() {
[ -f $PIDFILE -a -S $SOCKETFILE ] || return 1 [ -f $PIDFILE -a -S $SOCKETFILE ] || return 1
# And that PID file must have a PID. # And that PID file must have a PID.
local pid=$(cat /tmp/PORT/data/mysql_sandboxPORT.pid 2>/dev/null) local pid=$(cat TMP_DIR/PORT/data/mysql_sandboxPORT.pid 2>/dev/null)
[ "$pid" ] || return 1 [ "$pid" ] || return 1
# Second, MySQL is truly alive when it respond to a ping. # Second, MySQL is truly alive when it respond to a ping.
# It's not enough that the mysqld process is running because # It's not enough that the mysqld process is running because
# InnoDB can take time to create ibdata1, etc. So MySQL is # InnoDB can take time to create ibdata1, etc. So MySQL is
# only alive when it responds to queries. # only alive when it responds to queries.
$BASEDIR/bin/mysqladmin --defaults-file="/tmp/PORT/my.sandbox.cnf" ping >/dev/null 2>&1 $BASEDIR/bin/mysqladmin --defaults-file="TMP_DIR/PORT/my.sandbox.cnf" ping >/dev/null 2>&1
[ $? -eq 0 ] || return 1 [ $? -eq 0 ] || return 1
echo "return 0" echo "return 0"
@@ -42,7 +42,7 @@ if [ -f "$PIDFILE" -o -S "$SOCKETFILE" ]; then
fi fi
# Sandbox exists but is not running. Clear it and then start it. # Sandbox exists but is not running. Clear it and then start it.
/tmp/PORT/stop >/dev/null 2>&1 TMP_DIR/PORT/stop >/dev/null 2>&1
fi fi
echo -n "Starting MySQL test server on port PORT... " echo -n "Starting MySQL test server on port PORT... "
@@ -51,11 +51,11 @@ echo -n "Starting MySQL test server on port PORT... "
cwd=$PWD cwd=$PWD
cd $BASEDIR cd $BASEDIR
init_file="/tmp/PORT/mysql-init" init_file="TMP_DIR/PORT/mysql-init"
if [ -e $init_file ]; then if [ -e $init_file ]; then
$BASEDIR/MYSQLD --defaults-file=/tmp/PORT/my.sandbox.cnf -u root --init-file $init_file & $BASEDIR/MYSQLD --defaults-file=TMP_DIR/PORT/my.sandbox.cnf -u root --init-file $init_file &
else else
$BASEDIR/MYSQLD --defaults-file=/tmp/PORT/my.sandbox.cnf > /dev/null 2>&1 & $BASEDIR/MYSQLD --defaults-file=TMP_DIR/PORT/my.sandbox.cnf > /dev/null 2>&1 &
fi fi
cd $PWD cd $PWD

View File

@@ -2,8 +2,8 @@
start_ts=$(date +%s) start_ts=$(date +%s)
PIDFILE="/tmp/PORT/data/mysql_sandboxPORT.pid" PIDFILE="TMP_DIR/PORT/data/mysql_sandboxPORT.pid"
SOCKETFILE="/tmp/PORT/mysql_sandboxPORT.sock" SOCKETFILE="TMP_DIR/PORT/mysql_sandboxPORT.sock"
BASEDIR="PERCONA_TOOLKIT_SANDBOX" BASEDIR="PERCONA_TOOLKIT_SANDBOX"
sandbox_is_alive() { sandbox_is_alive() {
@@ -11,14 +11,14 @@ sandbox_is_alive() {
[ -f $PIDFILE -a -S $SOCKETFILE ] || return 1 [ -f $PIDFILE -a -S $SOCKETFILE ] || return 1
# And that PID file must have a PID. # And that PID file must have a PID.
local pid=$(cat /tmp/PORT/data/mysql_sandboxPORT.pid 2>/dev/null) local pid=$(cat TMP_DIR/PORT/data/mysql_sandboxPORT.pid 2>/dev/null)
[ "$pid" ] || return 1 [ "$pid" ] || return 1
# Second, MySQL is truly alive when it respond to a ping. # Second, MySQL is truly alive when it respond to a ping.
# It's not enough that the mysqld process is running because # It's not enough that the mysqld process is running because
# InnoDB can take time to create ibdata1, etc. So MySQL is # InnoDB can take time to create ibdata1, etc. So MySQL is
# only alive when it responds to queries. # only alive when it responds to queries.
$BASEDIR/bin/mysqladmin --defaults-file="/tmp/PORT/my.sandbox.cnf" ping >/dev/null 2>&1 $BASEDIR/bin/mysqladmin --defaults-file="TMP_DIR/PORT/my.sandbox.cnf" ping >/dev/null 2>&1
[ $? -eq 0 ] || return 1 [ $? -eq 0 ] || return 1
return 0 return 0
@@ -36,7 +36,7 @@ _seq() {
echo -n "Stopping MySQL test server on port PORT... " echo -n "Stopping MySQL test server on port PORT... "
if sandbox_is_alive; then if sandbox_is_alive; then
$BASEDIR/bin/mysqladmin --defaults-file=/tmp/PORT/my.sandbox.cnf shutdown $BASEDIR/bin/mysqladmin --defaults-file=TMP_DIR/PORT/my.sandbox.cnf shutdown
fi fi
for i in $(_seq 60); do for i in $(_seq 60); do

View File

@@ -2,6 +2,6 @@
BASEDIR="PERCONA_TOOLKIT_SANDBOX" BASEDIR="PERCONA_TOOLKIT_SANDBOX"
$BASEDIR/bin/mysql --defaults-file=/tmp/PORT/my.sandbox.cnf "$@" $BASEDIR/bin/mysql --defaults-file=TMP_DIR/PORT/my.sandbox.cnf "$@"
exit exit

View File

@@ -1,8 +1,9 @@
#!/bin/sh #!/bin/bash
TMP_DIR=${TMP_DIR:-/tmp}
# This script starts a Percona Toolkit sandbox sever. sandbox/test-env # This script starts a Percona Toolkit sandbox sever. sandbox/test-env
# uses it, and many tests use it to create special, temporary sandbox # uses it, and many tests use it to create special, temporary sandbox
# servers. The actual startup is done by /tmp/PORT/start, which this # servers. The actual startup is done by ${TMP_DIR}/PORT/start, which this
# script calls after doing a bunch of sanity checks. # script calls after doing a bunch of sanity checks.
# #
# Exit 0 if the sandbox server started ok, else 1 and debug_sandbox() # Exit 0 if the sandbox server started ok, else 1 and debug_sandbox()
@@ -18,12 +19,12 @@ debug_sandbox() {
set -x set -x
local port="$1" local port="$1"
ps x | grep mysql >&2 ps x | grep mysql >&2
if [ -d "/tmp/$port" ]; then if [ -d "${TMP_DIR}/$port" ]; then
ls -lh /tmp/$port/* >&2 ls -lh ${TMP_DIR}/$port/* >&2
cat /tmp/$port/data/mysqld.log >&2 cat ${TMP_DIR}/$port/data/mysqld.log >&2
tail -n 100 /tmp/$port/data/genlog >&2 tail -n 100 ${TMP_DIR}/$port/data/genlog >&2
else else
echo "/tmp/$port does not exist" >&2 echo "${TMP_DIR}/$port does not exist" >&2
fi fi
} }
@@ -36,25 +37,25 @@ mysql_upgrade_on() {
make_sandbox() { make_sandbox() {
# Make the sandbox dir and extract the base files. # Make the sandbox dir and extract the base files.
rm -rf /tmp/$port || die "Failed to rm /tmp/$port" rm -rf ${TMP_DIR}/$port || die "Failed to rm ${TMP_DIR}/$port"
mkdir /tmp/$port || die "Failed to mkdir /tmp/$port" mkdir ${TMP_DIR}/$port || die "Failed to mkdir ${TMP_DIR}/$port"
local generating_database=0 local generating_database=0
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/my.sandbox.cnf /tmp/$port cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/my.sandbox.cnf ${TMP_DIR}/$port
if [ -e $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz ]; then if [ -e $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz ]; then
tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz -C /tmp/$port tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz -C ${TMP_DIR}/$port
else else
generating_database=1 generating_database=1
fi fi
for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do
if [ -f $script ]; then if [ -f $script ]; then
cp $script /tmp/$port cp $script ${TMP_DIR}/$port
fi fi
done done
if [ "${type}" = "cluster" ]; then if [ "${type}" = "cluster" ]; then
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/pxc/$version/my.sandbox.cnf /tmp/$port cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/pxc/$version/my.sandbox.cnf ${TMP_DIR}/$port
local libgalera="$PERCONA_TOOLKIT_SANDBOX/lib/libgalera_smm.so" local libgalera="$PERCONA_TOOLKIT_SANDBOX/lib/libgalera_smm.so"
local cluster_name="${CLUSTER_NAME:-"pt_sandbox_cluster"}" local cluster_name="${CLUSTER_NAME:-"pt_sandbox_cluster"}"
@@ -67,84 +68,85 @@ make_sandbox() {
local this_listen_port=$(($port + 10)) local this_listen_port=$(($port + 10))
local this_cluster_address="gcomm://$ip:$this_listen_port" local this_cluster_address="gcomm://$ip:$this_listen_port"
sed -e "s!gcomm://\$!$this_cluster_address!g" -i.bak "/tmp/$master_port/my.sandbox.cnf" sed -e "s!gcomm://\$!$this_cluster_address!g" -i.bak "${TMP_DIR}/$master_port/my.sandbox.cnf"
fi fi
sed -e "s/ADDR/$ip/g" -i.bak "/tmp/$port/my.sandbox.cnf" sed -e "s/ADDR/$ip/g" -i.bak "${TMP_DIR}/$port/my.sandbox.cnf"
sed -e "s!CLUSTER_AD!$cluster_address!g" -i.bak "/tmp/$port/my.sandbox.cnf" sed -e "s!CLUSTER_AD!$cluster_address!g" -i.bak "${TMP_DIR}/$port/my.sandbox.cnf"
sed -e "s/CLUSTER_NAME/$cluster_name/g" -i.bak "/tmp/$port/my.sandbox.cnf" sed -e "s/CLUSTER_NAME/$cluster_name/g" -i.bak "${TMP_DIR}/$port/my.sandbox.cnf"
sed -e "s/RECEIVE_PRT/$receive_port/g" -i.bak "/tmp/$port/my.sandbox.cnf" sed -e "s/RECEIVE_PRT/$receive_port/g" -i.bak "${TMP_DIR}/$port/my.sandbox.cnf"
sed -e "s/LISTEN_PRT/$listen_port/g" -i.bak "/tmp/$port/my.sandbox.cnf" sed -e "s/LISTEN_PRT/$listen_port/g" -i.bak "${TMP_DIR}/$port/my.sandbox.cnf"
sed -e "s!LIBGALERA!$libgalera!g" -i.bak "/tmp/$port/my.sandbox.cnf" sed -e "s!LIBGALERA!$libgalera!g" -i.bak "${TMP_DIR}/$port/my.sandbox.cnf"
fi fi
for file in `grep -l PORT /tmp/$port/* 2>/dev/null`; do for file in `grep -l PORT ${TMP_DIR}/$port/* 2>/dev/null`; do
sed -e "s/PORT/$port/g" -i.bak $file sed -e "s/PORT/$port/g" -i.bak $file
sed -e "s!TMP_DIR!$TMP_DIR!g" -i.bak $file
# Use ! instead of / because the replacment has / (it's a directory) # Use ! instead of / because the replacment has / (it's a directory)
sed -e "s!PERCONA_TOOLKIT_SANDBOX!$PERCONA_TOOLKIT_SANDBOX!g" -i.bak $file sed -e "s!PERCONA_TOOLKIT_SANDBOX!$PERCONA_TOOLKIT_SANDBOX!g" -i.bak $file
sed -e "s!MYSQLD!$mysqld!g" -i.bak $file sed -e "s!MYSQLD!$mysqld!g" -i.bak $file
done done
rm /tmp/$port/*.bak >/dev/null 2>&1 rm ${TMP_DIR}/$port/*.bak >/dev/null 2>&1
if [ -n "$BINLOG_FORMAT" ]; then if [ -n "$BINLOG_FORMAT" ]; then
echo "binlog-format=$BINLOG_FORMAT" >> /tmp/$port/my.sandbox.cnf echo "binlog-format=$BINLOG_FORMAT" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$SLAVE_EXEC_MODE" ]; then if [ -n "$SLAVE_EXEC_MODE" ]; then
echo "slave_exec_mode=$SLAVE_EXEC_MODE" >> /tmp/$port/my.sandbox.cnf echo "slave_exec_mode=$SLAVE_EXEC_MODE" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$SQL_MODE" ]; then if [ -n "$SQL_MODE" ]; then
echo "sql-mode=$SQL_MODE" >> /tmp/$port/my.sandbox.cnf echo "sql-mode=$SQL_MODE" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$GENLOG" ]; then if [ -n "$GENLOG" ]; then
echo "log=genlog" >> /tmp/$port/my.sandbox.cnf echo "log=genlog" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$SKIP_INNODB" ]; then if [ -n "$SKIP_INNODB" ]; then
echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf echo "skip-innodb" >> ${TMP_DIR}/$port/my.sandbox.cnf
echo "default-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf echo "default-storage-engine=myisam" >> ${TMP_DIR}/$port/my.sandbox.cnf
if [ "$version" ">" "5.5" ]; then if [ "$version" ">" "5.5" ]; then
echo "default-tmp-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf echo "default-tmp-storage-engine=myisam" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
fi fi
if [ -n "$MODE_ANSI" ]; then if [ -n "$MODE_ANSI" ]; then
echo "sql_mode=ansi" >> /tmp/$port/my.sandbox.cnf echo "sql_mode=ansi" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then if [ -n "$MULTIPLE_BUFFER_POOLS" ]; then
echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> /tmp/$port/my.sandbox.cnf echo "innodb_buffer_pool_instances=$MULTIPLE_BUFFER_POOLS" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$LOCAL_INFILE" ]; then if [ -n "$LOCAL_INFILE" ]; then
echo "local-infile=$LOCAL_INFILE" >> /tmp/$port/my.sandbox.cnf echo "local-infile=$LOCAL_INFILE" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$QUERY_CACHE_SIZE" ]; then if [ -n "$QUERY_CACHE_SIZE" ]; then
echo "query_cache_type=1" >> /tmp/$port/my.sandbox.cnf echo "query_cache_type=1" >> ${TMP_DIR}/$port/my.sandbox.cnf
echo "query_cache_size=$QUERY_CACHE_SIZE" >> /tmp/$port/my.sandbox.cnf echo "query_cache_size=$QUERY_CACHE_SIZE" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$GTID" ]; then if [ -n "$GTID" ]; then
echo "gtid_mode=on" >> /tmp/$port/my.sandbox.cnf echo "gtid_mode=on" >> ${TMP_DIR}/$port/my.sandbox.cnf
echo "enforce_gtid_consistency" >> /tmp/$port/my.sandbox.cnf echo "enforce_gtid_consistency" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$REPLICATION_THREADS" ]; then if [ -n "$REPLICATION_THREADS" ]; then
echo "slave_parallel_workers=$REPLICATION_THREADS" >> /tmp/$port/my.sandbox.cnf echo "slave_parallel_workers=$REPLICATION_THREADS" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ -n "$EXTRA_DEFAULTS_FILE" ]; then if [ -n "$EXTRA_DEFAULTS_FILE" ]; then
cat "$EXTRA_DEFAULTS_FILE" >> /tmp/$port/my.sandbox.cnf cat "$EXTRA_DEFAULTS_FILE" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
if [ $generating_database -eq 0 ]; then if [ $generating_database -eq 0 ]; then
# If the sandbox is a slave, set it read_only. # If the sandbox is a slave, set it read_only.
if [ "$type" = "slave" ]; then if [ "$type" = "slave" ]; then
echo "read_only" >> /tmp/$port/my.sandbox.cnf echo "read_only" >> ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
fi fi
if [ $generating_database -eq 1 ]; then if [ $generating_database -eq 1 ]; then
echo "Creating default databases ..." echo "Creating default databases ..."
if [ "$version" > "5.6" ]; then if [ "$version" > "5.6" ]; then
rm -f /tmp/empty-defaults.txt rm -f ${TMP_DIR}/empty-defaults.txt
touch /tmp/empty-defaults.txt touch ${TMP_DIR}/empty-defaults.txt
rm -rf /tmp/$port/data rm -rf ${TMP_DIR}/$port/data
$PERCONA_TOOLKIT_SANDBOX/$mysqld --defaults-file=/tmp/${port}/my.sandbox.cnf --initialize $PERCONA_TOOLKIT_SANDBOX/$mysqld --defaults-file=${TMP_DIR}/${port}/my.sandbox.cnf --initialize
else else
# MySQL up to 5.6 needs mysql_install_db # MySQL up to 5.6 needs mysql_install_db
# Support for it is a TODO # Support for it is a TODO
@@ -152,7 +154,7 @@ make_sandbox() {
exit 1 exit 1
fi fi
init_file="/tmp/$port/mysql-init" init_file="${TMP_DIR}/$port/mysql-init"
rm -rf $init_file rm -rf $init_file
$PERCONA_TOOLKIT_BRANCH/util/version_cmp $minor_version 5.7.5 $PERCONA_TOOLKIT_BRANCH/util/version_cmp $minor_version 5.7.5
@@ -182,10 +184,10 @@ make_sandbox() {
fi fi
# Start the sandbox and check that it has InnoDB. # Start the sandbox and check that it has InnoDB.
/tmp/$port/start ${TMP_DIR}/$port/start
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ -z "$SKIP_INNODB" ]; then if [ -z "$SKIP_INNODB" ]; then
/tmp/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1 ${TMP_DIR}/$port/use -e 'SHOW /*!40100 ENGINE*/ INNODB STATUS' | grep 'INNODB MONITOR OUTPUT' >/dev/null 2>&1
# grep exits 0 if lines are found # grep exits 0 if lines are found
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Sandbox $type $port doesn't have InnoDB." >&2 echo "Sandbox $type $port doesn't have InnoDB." >&2
@@ -194,7 +196,7 @@ make_sandbox() {
fi fi
for sql in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/"*.sql; do for sql in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/"*.sql; do
[ -f "$sql" ] && /tmp/$port/use < $sql [ -f "$sql" ] && ${TMP_DIR}/$port/use < $sql
done done
fi fi
@@ -202,7 +204,7 @@ make_sandbox() {
if [ -n "$SYS_SCHEMA" ]; then if [ -n "$SYS_SCHEMA" ]; then
local sys_dir="$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/sys" local sys_dir="$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/sys"
cd "$sys_dir" cd "$sys_dir"
[ -f "$sys_dir/sys.sql" ] && /tmp/$port/use < "$sys_dir/sys.sql" [ -f "$sys_dir/sys.sql" ] && ${TMP_DIR}/$port/use < "$sys_dir/sys.sql"
fi fi
else else
echo "Sandbox $type $port failed to start." >&2 echo "Sandbox $type $port failed to start." >&2
@@ -211,17 +213,17 @@ make_sandbox() {
fi fi
/tmp/$port/use -e "CREATE DATABASE IF NOT EXISTS percona_test"; ${TMP_DIR}/$port/use -e "CREATE DATABASE IF NOT EXISTS percona_test";
/tmp/$port/use -e "CREATE TABLE IF NOT EXISTS percona_test.sentinel (id INT PRIMARY KEY, ping VARCHAR(64) NOT NULL DEFAULT '')"; ${TMP_DIR}/$port/use -e "CREATE TABLE IF NOT EXISTS percona_test.sentinel (id INT PRIMARY KEY, ping VARCHAR(64) NOT NULL DEFAULT '')";
if [ -n "${MYSQL_UPGRADE:-""}" ]; then if [ -n "${MYSQL_UPGRADE:-""}" ]; then
mysql_upgrade_on /tmp/$port/my.sandbox.cnf mysql_upgrade_on ${TMP_DIR}/$port/my.sandbox.cnf
fi fi
# If the sandbox is a slave, start the slave. # If the sandbox is a slave, start the slave.
if [ "$type" = "slave" ]; then if [ "$type" = "slave" ]; then
/tmp/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port" ${TMP_DIR}/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"
/tmp/$port/use -e "start slave" ${TMP_DIR}/$port/use -e "start slave"
fi fi
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/ps-admin" ]; then if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/ps-admin" ]; then
@@ -264,8 +266,8 @@ fi
# If creating a slave, the master must exist first. Not true for creating # If creating a slave, the master must exist first. Not true for creating
# a master-master though. # a master-master though.
if [ "$type" = "slave" ] && [ ! -d "/tmp/$master_port" ]; then if [ "$type" = "slave" ] && [ ! -d "${TMP_DIR}/$master_port" ]; then
die "Master sandbox does not exist: /tmp/$master_port" die "Master sandbox does not exist: ${TMP_DIR}/$master_port"
fi fi
# ########################################################################### # ###########################################################################
@@ -327,7 +329,7 @@ fi
# ########################################################################### # ###########################################################################
# Start and configure the sandbox server. # Start and configure the sandbox server.
# ########################################################################### # ###########################################################################
PIDFILE="/tmp/$port/data/mysql_sandbox$port.pid" PIDFILE="${TMP_DIR}/$port/data/mysql_sandbox$port.pid"
if [ -f $PIDFILE ]; then if [ -f $PIDFILE ]; then
echo "Sandbox $port already started (found pid file $PIDFILE)" echo "Sandbox $port already started (found pid file $PIDFILE)"
@@ -344,12 +346,12 @@ else
make_sandbox make_sandbox
# Slave mm2 -> mm1 # Slave mm2 -> mm1
/tmp/$mm2_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm1_port" ${TMP_DIR}/$mm2_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm1_port"
/tmp/$mm2_port/use -e "start slave" ${TMP_DIR}/$mm2_port/use -e "start slave"
# Slave mm1 -> mm2 # Slave mm1 -> mm2
/tmp/$mm1_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm2_port" ${TMP_DIR}/$mm1_port/use -e "change master to master_host='127.0.0.1', master_log_file='mysql-bin.000001', master_log_pos=0, master_user='msandbox', master_password='msandbox', master_port=$mm2_port"
/tmp/$mm1_port/use -e "start slave" ${TMP_DIR}/$mm1_port/use -e "start slave"
fi fi
fi fi

View File

@@ -1,4 +1,5 @@
#!/bin/sh #!/bin/bash
TMP_DIR=${TMP_DIR:-/tmp}
die() { die() {
echo $1 >&2 echo $1 >&2
@@ -12,20 +13,20 @@ fi
exit_status=0 exit_status=0
for port in "$@"; do for port in "$@"; do
if ! [ -d "/tmp/$port" ]; then if ! [ -d "${TMP_DIR}/$port" ]; then
echo "MySQL test server on port $port does not exist." echo "MySQL test server on port $port does not exist."
continue continue
fi fi
if [ -x "/tmp/$port/stop" ]; then if [ -x "${TMP_DIR}/$port/stop" ]; then
/tmp/$port/stop ${TMP_DIR}/$port/stop
exit_status=$((exit_status | $?)) exit_status=$((exit_status | $?))
else else
echo "/tmp/$port is missing files:" >&2 echo "${TMP_DIR}/$port is missing files:" >&2
ls -la /tmp/$port >&2 ls -la ${TMP_DIR}/$port >&2
fi fi
rm -rf /tmp/$port rm -rf ${TMP_DIR}/$port
exit_status=$((exit_status | $?)) exit_status=$((exit_status | $?))
done done

View File

@@ -1,262 +1,264 @@
#!/bin/sh #!/bin/bash
TMP_DIR=${TMP_DIR:-/tmp}
# This script controls the Percona Toolkit test environment. The basic # This script controls the Percona Toolkit test environment. The basic
# environment is a master on port 12345 in /tmp/12345 and a slave on port # environment is a master on port 12345 in ${TMP_DIR}/12345 and a slave on port
# 12346 in /tmp/12346. This script attempts to ensure that all environment # 12346 in ${TMP_DIR}/12346. This script attempts to ensure that all environment
# vars like PERCONA_TOOLKIT_BRANCH and PERCONA_TOOLKIT_SANDBOX are correct. # vars like PERCONA_TOOLKIT_BRANCH and PERCONA_TOOLKIT_SANDBOX are correct.
# Exist 0 on success/no errors, or 1 on any warnings or errors. # Exist 0 on success/no errors, or 1 on any warnings or errors.
err() { err() {
for msg; do for msg; do
echo "$msg" >&2 echo "$msg" >&2
done done
if [ "$DEBUG_SANDBOXES" ]; then if [ "$DEBUG_SANDBOXES" ]; then
echo echo
echo "MySQL processes:" >&2 echo "MySQL processes:" >&2
ps x | grep mysql >&2 ps x | grep mysql >&2
echo echo
for p in 12345 12346 12347; do for p in 12345 12346 12347; do
echo "Sandbox $p:" >&2 echo "Sandbox $p:" >&2
if [ -d "/tmp/$p" ]; then if [ -d "${TMP_DIR}/$p" ]; then
ls -lh /tmp/$p/* >&2 ls -lh ${TMP_DIR}/$p/* >&2
echo echo
cat /tmp/$p/data/mysqld.log >&2 cat ${TMP_DIR}/$p/data/mysqld.log >&2
echo echo
tail -n 100 /tmp/$p/data/genlog >&2 tail -n 100 ${TMP_DIR}/$p/data/genlog >&2
else else
echo "/tmp/$p does not exist" >&2 echo "${TMP_DIR}/$p does not exist" >&2
fi fi
done done
fi fi
} }
usage() { usage() {
err "Usage: test-env start|stop|restart|status|checkconfig|reset|kill" \ err "Usage: test-env start|stop|restart|status|checkconfig|reset|kill" \
"" \ "" \
" start Start test servers in /tmp/PORT" \ " start Start test servers in ${TMP_DIR}/PORT" \
" stop Stop test servers and remvoe all /tmp/PORT" \ " stop Stop test servers and remvoe all ${TMP_DIR}/PORT" \
" kill Kill test servers (use if stop fails)" \ " kill Kill test servers (use if stop fails)" \
" restart Stop and start test servers" \ " restart Stop and start test servers" \
" status Print status of test servers" \ " status Print status of test servers" \
" checkconfig Check test env and test servers" \ " checkconfig Check test env and test servers" \
" reset Reset test server binary logs" \ " reset Reset test server binary logs" \
" version Print MySQL version of running test servers" \ " version Print MySQL version of running test servers" \
"" ""
} }
mysql_basedir_ok() { mysql_basedir_ok() {
local basedir=$1 local basedir=$1
if [ ! -d "$basedir" ] || [ ! -d "$basedir/bin" ]; then if [ ! -d "$basedir" ] || [ ! -d "$basedir/bin" ]; then
return 0 return 0
fi fi
if [ ! -x "$basedir/bin/mysqld_safe" ]; then if [ ! -x "$basedir/bin/mysqld_safe" ]; then
return 0 return 0
fi fi
return 1 # basedir is ok return 1 # basedir is ok
} }
set_mysql_basedir() { set_mysql_basedir() {
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/mysqld" ]; then if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/mysqld" ]; then
mysqld="$PERCONA_TOOLKIT_SANDBOX/bin/mysqld" mysqld="$PERCONA_TOOLKIT_SANDBOX/bin/mysqld"
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" ]; then elif [ -x "$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" ]; then
mysqld="$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" mysqld="$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld"
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then
mysqld="$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" mysqld="$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld"
else else
err "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec." err "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec."
return 0 return 0
fi fi
mysql_basedir_ok $PERCONA_TOOLKIT_SANDBOX mysql_basedir_ok $PERCONA_TOOLKIT_SANDBOX
local basedir_ok=$? local basedir_ok=$?
if [ $basedir_ok -eq 1 ]; then if [ $basedir_ok -eq 1 ]; then
export PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX export PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX
fi fi
return $basedir_ok return $basedir_ok
} }
checkconfig() { checkconfig() {
local print_conf=$1 local print_conf=$1
local stat="" local stat=""
conf_err=0 conf_err=0
if [ -z "$PERCONA_TOOLKIT_BRANCH" ] || [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then if [ -z "$PERCONA_TOOLKIT_BRANCH" ] || [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
conf_err=1 conf_err=1
stat="INVALID" stat="INVALID"
else else
stat="ok" stat="ok"
fi fi
if [ $print_conf ]; then if [ $print_conf ]; then
echo "PERCONA_TOOLKIT_BRANCH=$PERCONA_TOOLKIT_BRANCH - $stat" echo "PERCONA_TOOLKIT_BRANCH=$PERCONA_TOOLKIT_BRANCH - $stat"
fi fi
set_mysql_basedir set_mysql_basedir
if [ $? -ne 1 ]; then if [ $? -ne 1 ]; then
conf_err=1 conf_err=1
stat="INVALID" stat="INVALID"
else else
stat="ok" stat="ok"
fi fi
if [ $print_conf ]; then if [ $print_conf ]; then
echo -n "PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX - $stat" echo -n "PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX - $stat"
if [ -n "$BASEDIR_AUTO_DETECTED" ]; then if [ -n "$BASEDIR_AUTO_DETECTED" ]; then
echo " (auto-detected)" echo " (auto-detected)"
else else
echo echo
fi fi
fi fi
return $conf_err return $conf_err
} }
sandbox_status() { sandbox_status() {
local type=$1 local type=$1
local port=$2 local port=$2
local master_port=$3 local master_port=$3
local status=0 # sandbox is ok, no problems local status=0 # sandbox is ok, no problems
echo "MySQL $type test server on port $port:" echo "MySQL $type test server on port $port:"
echo -n " PID file exists - " echo -n " PID file exists - "
if [ -f "/tmp/$port/data/mysql_sandbox$port.pid" ]; then if [ -f "${TMP_DIR}/$port/data/mysql_sandbox$port.pid" ]; then
echo "yes" echo "yes"
echo -n " PID file has a PID - " echo -n " PID file has a PID - "
local pid=`cat /tmp/$port/data/mysql_sandbox$port.pid 2>/dev/null` local pid=`cat ${TMP_DIR}/$port/data/mysql_sandbox$port.pid 2>/dev/null`
if [ -n "$pid" ]; then if [ -n "$pid" ]; then
echo "yes"
echo -n " process $pid is alive - "
kill -0 $pid >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "yes" echo "yes"
else echo -n " process $pid is alive - "
echo "NO" kill -0 $pid >/dev/null 2>&1
status=1 if [ $? -eq 0 ]; then
fi echo "yes"
else
echo "NO"
status=1
fi
else
echo "NO"
status=1
fi
echo -n " MySQL is alive - "
$PERCONA_TOOLKIT_SANDBOX/bin/mysqladmin --defaults-file="/tmp/$port/my.sandbox.cnf" ping >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "yes"
if [ "$MYSQL_VERSION" '>' "4.1" ]; then
echo -n " sakila db is loaded - "
/tmp/$port/use -e 'show databases like "sakila"' 2>/dev/null | grep sakila >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "yes"
else
echo "NO"
status=1
fi
fi
if [ "$type" = "slave" ]; then
echo -n " slave is running - "
# Slave status should show:
# Slave_IO_Running: Yes
# Slave_SQL_Running: Yes
local slave_running=`/tmp/$port/use -e 'show slave status\G' 2>/dev/null | grep Running | grep -c Yes`
if [ $slave_running -eq 2 ]; then
echo "yes"
else
echo "NO"
status=1
fi
if [ -n "$master_port" ]; then
echo -n " slave to master $master_port - "
local mp=`/tmp/$port/use -e 'show slave status\G' 2>/dev/null | grep Master_Port | awk '{print $2}'`
if [ "$mp" = "$master_port" ]; then
echo "yes"
else else
echo "NO" echo "NO"
status=1 status=1
fi fi
fi else
fi echo "NO"
else status=1
echo "NO" fi
status=1 else
fi echo "NO"
return $status status=1
fi
echo -n " MySQL is alive - "
$PERCONA_TOOLKIT_SANDBOX/bin/mysqladmin --defaults-file="${TMP_DIR}/$port/my.sandbox.cnf" ping >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "yes"
if [ "$MYSQL_VERSION" '>' "4.1" ]; then
echo -n " sakila db is loaded - "
${TMP_DIR}/$port/use -e 'show databases like "sakila"' 2>/dev/null | grep sakila >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "yes"
else
echo "NO"
status=1
fi
fi
if [ "$type" = "slave" ]; then
echo -n " slave is running - "
# Slave status should show:
# Slave_IO_Running: Yes
# Slave_SQL_Running: Yes
local slave_running=`${TMP_DIR}/$port/use -e 'show slave status\G' 2>/dev/null | grep Running | grep -c Yes`
if [ $slave_running -eq 2 ]; then
echo "yes"
else
echo "NO"
status=1
fi
if [ -n "$master_port" ]; then
echo -n " slave to master $master_port - "
local mp=`${TMP_DIR}/$port/use -e 'show slave status\G' 2>/dev/null | grep Master_Port | awk '{print $2}'`
if [ "$mp" = "$master_port" ]; then
echo "yes"
else
echo "NO"
status=1
fi
fi
fi
else
echo "NO"
status=1
fi
return $status
} }
sandbox_is_running() { sandbox_is_running() {
local p=$1 local p=$1
ps xw | grep mysqld | grep -v grep | grep /tmp/$p >/dev/null ps xw | grep mysqld | grep -v grep | grep ${TMP_DIR}/$p >/dev/null
} }
kill_sandbox() { kill_sandbox() {
local p=$1 local p=$1
# See if the sandbox server is running. # See if the sandbox server is running.
sandbox_is_running $p sandbox_is_running $p
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
# Try to kill it with mysqladmin shutdown. We try different # Try to kill it with mysqladmin shutdown. We try different
# user/pass because sometimes a test can bork acct privs. # user/pass because sometimes a test can bork acct privs.
mysqladmin -h127.1 -P$p -umsandbox -pmsandbox shutdown >/dev/null 2>&1 mysqladmin -h127.1 -P$p -umsandbox -pmsandbox shutdown >/dev/null 2>&1
mysqladmin -h127.1 -P$p -uroot -pmsandbox shutdown >/dev/null 2>&1 mysqladmin -h127.1 -P$p -uroot -pmsandbox shutdown >/dev/null 2>&1
mysqladmin -h127.1 -P$p -uroot shutdown >/dev/null 2>&1 mysqladmin -h127.1 -P$p -uroot shutdown >/dev/null 2>&1
sleep 2 sleep 2
# See if the sandbox server is still running. # See if the sandbox server is still running.
sandbox_is_running $p sandbox_is_running $p
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
# Kill both mysqld_safe and mysqld. # Kill both mysqld_safe and mysqld.
pid1=`ps xw | grep -v grep | grep mysqld_safe | grep /tmp/$p | awk '{print $1}'` pid1=`ps xw | grep -v grep | grep mysqld_safe | grep ${TMP_DIR}/$p | awk '{print $1}'`
pid2=`ps xw | grep -v grep | grep -v mysqld_safe | grep mysqld | grep /tmp/$p | awk '{print $1}'` pid2=`ps xw | grep -v grep | grep -v mysqld_safe | grep mysqld | grep ${TMP_DIR}/$p | awk '{print $1}'`
[ "$pid1" ] && kill -9 $pid1 # Die, damn you, die! [ "$pid1" ] && kill -9 $pid1 # Die, damn you, die!
[ "$pid2" ] && kill -9 $pid2 [ "$pid2" ] && kill -9 $pid2
sleep 2 sleep 2
# Third and finaly check if the sandbox server is running. # Third and finaly check if the sandbox server is running.
sandbox_is_running $p sandbox_is_running $p
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
err "Failed to kill MySQL test server on port $p (PID $pid1, $pid2)" err "Failed to kill MySQL test server on port $p (PID $pid1, $pid2)"
return 1 return 1
else else
echo "Killed MySQL test server on port $p (PID $pid1, $pid2)" echo "Killed MySQL test server on port $p (PID $pid1, $pid2)"
fi fi
else else
echo "Killed MySQL test server on port $p" echo "Killed MySQL test server on port $p"
fi fi
fi fi
if [ -d "/tmp/$p" ]; then if [ -d "${TMP_DIR}/$p" ]; then
rm -rf /tmp/$p rm -rf ${TMP_DIR}/$p
echo "Removed /tmp/$p" echo "Removed ${TMP_DIR}/$p"
fi fi
return 0 return 0
} }
MYSQL_VERSION="" MYSQL_VERSION=""
set_mysql_version() { set_mysql_version() {
if [ -d /tmp/12345 ] && [ -f /tmp/12345/use ]; then if [ -d ${TMP_DIR}/12345 ] && [ -f ${TMP_DIR}/12345/use ]; then
MYSQL_VERSION=$(/tmp/12345/use -ss -e "SELECT VERSION()" \ MYSQL_VERSION=$(${TMP_DIR}/12345/use -ss -e "SELECT VERSION()" \
| cut -d'.' -f1,2) | cut -d'.' -f1,2)
fi fi
} }
_seq() { _seq() {
local i="$1" local i="$1"
awk "BEGIN { for(i=1; i<=$i; i++) print i; }" awk "BEGIN { for(i=1; i<=$i; i++) print i; }"
} }
# ########################################################################### # ###########################################################################
# Sanity check the cmd line options. # Sanity check the cmd line options.
# ########################################################################### # ###########################################################################
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
usage usage
exit 1 exit 1
fi fi
opt=$1 opt=$1
@@ -272,158 +274,158 @@ if [ -e ${PERCONA_TOOLKIT_SANDBOX}/lib/mysql/libjemalloc.so ]; then
fi fi
if [ $opt = 'checkconfig' ]; then if [ $opt = 'checkconfig' ]; then
checkconfig 1 checkconfig 1
echo -n "Percona Toolkit test environment config is " echo -n "Percona Toolkit test environment config is "
if [ $conf_err -eq 0 ]; then if [ $conf_err -eq 0 ]; then
echo "ok!" echo "ok!"
exit 0 exit 0
else else
echo "invalid." echo "invalid."
exit 1 exit 1
fi fi
else else
checkconfig checkconfig
if [ $conf_err -eq 1 ]; then if [ $conf_err -eq 1 ]; then
err "The Percona Toolkit test environment config is invalid." \ err "The Percona Toolkit test environment config is invalid." \
"Run '$0 checkconfig' to see the current configuration." "Run '$0 checkconfig' to see the current configuration."
exit 1 exit 1
fi fi
fi fi
case $opt in case $opt in
start) start)
cd $PERCONA_TOOLKIT_BRANCH/sandbox cd $PERCONA_TOOLKIT_BRANCH/sandbox
./start-sandbox "${2:-"master"}" 12345 ./start-sandbox "${2:-"master"}" 12345
exit_status=$((exit_status | $?)) exit_status=$((exit_status | $?))
set_mysql_version set_mysql_version
if [ $exit_status -eq 0 ]; then if [ $exit_status -eq 0 ]; then
if [ "${2:-""}" = "channels" ] && [ "$MYSQL_VERSION" '>' "5.6" ]; then if [ "${2:-""}" = "channels" ] && [ "$MYSQL_VERSION" '>' "5.6" ]; then
./start-sandbox master 12346 ./start-sandbox master 12346
exit_status=$((exit_status | $?)) exit_status=$((exit_status | $?))
./start-sandbox master 12347 ./start-sandbox master 12347
exit_status=$((exit_status | $?)) exit_status=$((exit_status | $?))
/tmp/12345/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql ${TMP_DIR}/12345/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
exit_status=$? exit_status=$?
/tmp/12346/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql ${TMP_DIR}/12346/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
exit_status=$? exit_status=$?
/tmp/12347/use < $PERCONA_TOOLKIT_BRANCH/sandbox/slave_channels.sql ${TMP_DIR}/12347/use < $PERCONA_TOOLKIT_BRANCH/sandbox/slave_channels.sql
exit_status=$? exit_status=$?
else
./start-sandbox "${2:-"slave"}" 12346 12345
exit_status=$((exit_status | $?))
./start-sandbox "${2:-"slave"}" 12347 12346
exit_status=$((exit_status | $?))
fi
if [ "${2:-""}" = "cluster" ]; then
# Bit of magic here. 'start-sandbox cluster new_node old_node'
# changes old_node's my.sandbox.cnf's wsrep_cluster_address to
# point to new_node. This is especially useful because otherwise,
# calling stop/start like below on 12345 would create a new cluster.
/tmp/12345/stop >/dev/null
/tmp/12345/start >/dev/null
echo -n "Checking that the cluster size is correct... "
size=$(/tmp/12345/use -ss -e "SHOW STATUS LIKE 'wsrep_cluster_size'" | awk '{print $2}')
if [ ${size:-0} -ne 3 ]; then
echo "FAILED"
else else
echo "OK" ./start-sandbox "${2:-"slave"}" 12346 12345
fi exit_status=$((exit_status | $?))
fi ./start-sandbox "${2:-"slave"}" 12347 12346
exit_status=$((exit_status | $?))
if [ $? -eq 0 ]; then
SAKILA=${SAKILA:-1}
if [ $SAKILA -eq 1 ]; then
echo -n "Loading sakila database... "
./load-sakila-db 12345 "${2:-""}"
exit_status=$((exit_status | $?))
if [ $exit_status -ne 0 ]; then
echo "FAILED"
else
echo "OK"
fi
fi fi
# Create percona_test db and checksum all the tables. if [ "${2:-""}" = "cluster" ]; then
../util/checksum-test-dataset # Bit of magic here. 'start-sandbox cluster new_node old_node'
# changes old_node's my.sandbox.cnf's wsrep_cluster_address to
# LOAD DATA is disabled or broken on some boxes. # point to new_node. This is especially useful because otherwise,
# PerconaTest exports $can_load_data which is true # calling stop/start like below on 12345 would create a new cluster.
# if percona_test.load_data has a row with 1, ${TMP_DIR}/12345/stop >/dev/null
# signaling that LOAD DATA LOCAL INFILE worked. ${TMP_DIR}/12345/start >/dev/null
../util/check-load-data echo -n "Checking that the cluster size is correct... "
size=$(${TMP_DIR}/12345/use -ss -e "SHOW STATUS LIKE 'wsrep_cluster_size'" | awk '{print $2}')
ping=$(/tmp/12345/use -ss -e "SELECT MD5(RAND())") if [ ${size:-0} -ne 3 ]; then
/tmp/12345/use -e "SET AUTOCOMMIT=1; REPLACE INTO percona_test.sentinel (id, ping) VALUES (1, '$ping')"; echo "FAILED"
echo -n "Waiting for replication to finish..." else
for i in $(_seq 60); do echo "OK"
pong=$(/tmp/12347/use -ss -e "SELECT ping FROM percona_test.sentinel WHERE id=1 AND ping='$ping'" 2>/dev/null) fi
[ "$ping" = "$pong" ] && break
echo -n '.'
sleep 1
done
if [ "$ping" = "$pong" ]; then
echo " OK"
else
echo " FAILED"
exit_status=$((exit_status | 1))
fi fi
fi
fi if [ $? -eq 0 ]; then
if [ $exit_status -eq 0 ]; then SAKILA=${SAKILA:-1}
echo "Percona Toolkit test environment started with MySQL v$MYSQL_VERSION." if [ $SAKILA -eq 1 ]; then
else echo -n "Loading sakila database... "
DEBUG_SANDBOXES=1 ./load-sakila-db 12345 "${2:-""}"
err "There was an error starting the Percona Toolkit test environment." exit_status=$((exit_status | $?))
fi if [ $exit_status -ne 0 ]; then
;; echo "FAILED"
stop) else
cd $PERCONA_TOOLKIT_BRANCH/sandbox echo "OK"
./stop-sandbox 12349 12348 12347 12346 12345 fi
exit_status=$((exit_status | $?)) fi
./stop-sandbox 2903 2902 2901 2900
exit_status=$((exit_status | $?)) # Create percona_test db and checksum all the tables.
if [ $exit_status -eq 0 ]; then ../util/checksum-test-dataset
echo "Percona Toolkit test environment stopped."
else # LOAD DATA is disabled or broken on some boxes.
DEBUG_SANDBOXES=1 # PerconaTest exports $can_load_data which is true
err "Error stopping the Percona Toolkit test environment." # if percona_test.load_data has a row with 1,
fi # signaling that LOAD DATA LOCAL INFILE worked.
;; ../util/check-load-data
kill)
# This is a blunt approach for killing the entire test env ping=$(${TMP_DIR}/12345/use -ss -e "SELECT MD5(RAND())")
# when a polite stop fails. It uses kill -9 as a last resort. ${TMP_DIR}/12345/use -e "SET AUTOCOMMIT=1; REPLACE INTO percona_test.sentinel (id, ping) VALUES (1, '$ping')";
for port in 12349 12348 12347 12346 12345 2903 2902 2901 2900; do echo -n "Waiting for replication to finish..."
kill_sandbox $port for i in $(_seq 60); do
exit_status=$((exit_status | $?)) pong=$(${TMP_DIR}/12347/use -ss -e "SELECT ping FROM percona_test.sentinel WHERE id=1 AND ping='$ping'" 2>/dev/null)
done [ "$ping" = "$pong" ] && break
;; echo -n '.'
restart) sleep 1
shift; done
$0 stop "$@" if [ "$ping" = "$pong" ]; then
$0 start "$@" echo " OK"
;; else
status) echo " FAILED"
sandbox_status 'master' '12345' exit_status=$((exit_status | 1))
master_status=$? fi
sandbox_status 'slave' '12346' '12345' fi
slave_status=$? fi
echo -n "Percona Test test environment is " if [ $exit_status -eq 0 ]; then
if [ $master_status -eq 0 ] && [ $slave_status -eq 0 ]; then echo "Percona Toolkit test environment started with MySQL v$MYSQL_VERSION."
echo "ok!" else
else DEBUG_SANDBOXES=1
echo "invalid." err "There was an error starting the Percona Toolkit test environment."
exit_status=1 fi
fi ;;
;; stop)
version) cd $PERCONA_TOOLKIT_BRANCH/sandbox
set_mysql_version ./stop-sandbox 12349 12348 12347 12346 12345
echo $MYSQL_VERSION exit_status=$((exit_status | $?))
;; ./stop-sandbox 2903 2902 2901 2900
*) exit_status=$((exit_status | $?))
usage if [ $exit_status -eq 0 ]; then
exit_status=1 echo "Percona Toolkit test environment stopped."
;; else
DEBUG_SANDBOXES=1
err "Error stopping the Percona Toolkit test environment."
fi
;;
kill)
# This is a blunt approach for killing the entire test env
# when a polite stop fails. It uses kill -9 as a last resort.
for port in 12349 12348 12347 12346 12345 2903 2902 2901 2900; do
kill_sandbox $port
exit_status=$((exit_status | $?))
done
;;
restart)
shift;
$0 stop "$@"
$0 start "$@"
;;
status)
sandbox_status 'master' '12345'
master_status=$?
sandbox_status 'slave' '12346' '12345'
slave_status=$?
echo -n "Percona Test test environment is "
if [ $master_status -eq 0 ] && [ $slave_status -eq 0 ]; then
echo "ok!"
else
echo "invalid."
exit_status=1
fi
;;
version)
set_mysql_version
echo $MYSQL_VERSION
;;
*)
usage
exit_status=1
;;
esac esac
exit $exit_status exit $exit_status

View File

@@ -135,7 +135,7 @@ CREATE TABLE `innodb_ddl_log` (
`new_file_path` varchar(512) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, `new_file_path` varchar(512) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `thread_id` (`thread_id`) KEY `thread_id` (`thread_id`)
) /*!50100 TABLESPACE `mysql` */ ENGINE=InnoDB AUTO_INCREMENT=280 DEFAULT CHARSET=utf8mb4 STATS_PERSISTENT=0 ) /*!50100 TABLESPACE `mysql` */ ENGINE=InnoDB AUTO_INCREMENT=612 DEFAULT CHARSET=utf8mb4 STATS_PERSISTENT=0
mysql.innodb_dynamic_metadata mysql.innodb_dynamic_metadata
CREATE TABLE `innodb_dynamic_metadata` ( CREATE TABLE `innodb_dynamic_metadata` (

View File

@@ -46,7 +46,7 @@ $sb->load_file('master', "t/pt-online-schema-change/samples/pt-229.sql");
my $num_rows = 40000; my $num_rows = 40000;
diag("Loading $num_rows into the table. This might take some time."); diag("Loading $num_rows into the table. This might take some time.");
diag(`util/mysql_random_data_loader --host=127.1 --port=12345 --user=msandbox --password=msandbox test test_a $num_rows`); diag(`util/mysql_random_data_load --host=127.1 --port=12345 --user=msandbox --password=msandbox test test_a $num_rows`);
diag("$num_rows rows loaded. Starting tests."); diag("$num_rows rows loaded. Starting tests.");
$master_dbh->do("FLUSH TABLES"); $master_dbh->do("FLUSH TABLES");

View File

@@ -57,7 +57,7 @@ $sb->load_file('master', "t/pt-online-schema-change/samples/slave_lag.sql");
my $num_rows = 10000; my $num_rows = 10000;
diag("Loading $num_rows into the table. This might take some time."); diag("Loading $num_rows into the table. This might take some time.");
diag(`util/mysql_random_data_load_linux_amd64 --host=127.1 --port=12345 --user=msandbox --password=msandbox test pt178 $num_rows`); diag(`util/mysql_random_data_load --host=127.1 --port=12345 --user=msandbox --password=msandbox test pt178 $num_rows`);
# Run a full table scan query to ensure the slave is behind the master # Run a full table scan query to ensure the slave is behind the master
$master_dbh->do('RESET QUERY CACHE'); $master_dbh->do('RESET QUERY CACHE');

View File

@@ -42,7 +42,7 @@ $output = output(
is( is(
PerconaTest::count_checksum_results($output, 'rows'), PerconaTest::count_checksum_results($output, 'rows'),
$sandbox_version lt '5.7' ? 24 : 25, $sandbox_version ge '8.0' ? 30 : $sandbox_version lt '5.7' ? 24 : 25,
"Large BLOB/TEXT/BINARY Checksum" "Large BLOB/TEXT/BINARY Checksum"
); );

View File

@@ -1,3 +1,4 @@
DROP DATABASE IF EXISTS db1;
CREATE DATABASE db1; CREATE DATABASE db1;
USE db1; USE db1;
CREATE TABLE cp1251(f1 VARCHAR(100) CHARACTER SET LATIN1, f2 VARCHAR(100) CHARACTER SET CP1251) ENGINE=InnoDB; CREATE TABLE cp1251(f1 VARCHAR(100) CHARACTER SET LATIN1, f2 VARCHAR(100) CHARACTER SET CP1251) ENGINE=InnoDB;

View File

@@ -37,6 +37,7 @@ my $dbh = DBI->connect(
RaiseError => 1, RaiseError => 1,
PrintError => 1, PrintError => 1,
ShowErrorStatement => 1, ShowErrorStatement => 1,
# mysql_local_infile => 1,
}); });
$dbh->do("CREATE TABLE IF NOT EXISTS percona_test.load_data (i int)"); $dbh->do("CREATE TABLE IF NOT EXISTS percona_test.load_data (i int)");
@@ -44,7 +45,8 @@ $dbh->do("CREATE TABLE IF NOT EXISTS percona_test.load_data (i int)");
`echo 1 > /tmp/load_data_test.$$`; `echo 1 > /tmp/load_data_test.$$`;
eval { eval {
$dbh->do("LOAD DATA LOCAL INFILE '/tmp/load_data_test.$$' INTO TABLE percona_test.load_data"); $dbh->do("LOAD DATA INFILE '/tmp/load_data_test.$$' INTO TABLE percona_test.load_data");
#$dbh->do("LOAD DATA INFILE '/tmp/load_data_test.$$' INTO TABLE percona_test.load_data");
}; };
if ( $EVAL_ERROR ) { if ( $EVAL_ERROR ) {