mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-01 18:25:59 +00:00
WIP
This commit is contained in:
Binary file not shown.
@@ -28,10 +28,12 @@ relay_log = mysql-relay-bin
|
||||
report-host = 127.0.0.1
|
||||
report-port = PORT
|
||||
server-id = PORT
|
||||
#local_infile = ON
|
||||
#default_authentication_plugin=mysql_native_password
|
||||
|
||||
# fkc test
|
||||
binlog_format = STATEMENT
|
||||
performance_schema = ON
|
||||
#performance_schema = ON
|
||||
#performance-schema-instrument='wait/lock/metadata/sql/mdl=ON'
|
||||
#performance-schema-instrument='transaction=ON'
|
||||
secure-file-priv =
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
start_ts=$(date +%s)
|
||||
|
||||
PIDFILE="/tmp/PORT/data/mysql_sandboxPORT.pid"
|
||||
SOCKETFILE="/tmp/PORT/mysql_sandboxPORT.sock"
|
||||
PIDFILE="TMP_DIR/PORT/data/mysql_sandboxPORT.pid"
|
||||
SOCKETFILE="TMP_DIR/PORT/mysql_sandboxPORT.sock"
|
||||
BASEDIR="PERCONA_TOOLKIT_SANDBOX"
|
||||
|
||||
sandbox_is_alive() {
|
||||
@@ -11,14 +11,14 @@ sandbox_is_alive() {
|
||||
[ -f $PIDFILE -a -S $SOCKETFILE ] || return 1
|
||||
|
||||
# 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
|
||||
|
||||
# Second, MySQL is truly alive when it respond to a ping.
|
||||
# It's not enough that the mysqld process is running because
|
||||
# InnoDB can take time to create ibdata1, etc. So MySQL is
|
||||
# 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
|
||||
echo "return 0"
|
||||
|
||||
@@ -42,7 +42,7 @@ if [ -f "$PIDFILE" -o -S "$SOCKETFILE" ]; then
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
echo -n "Starting MySQL test server on port PORT... "
|
||||
@@ -51,11 +51,11 @@ echo -n "Starting MySQL test server on port PORT... "
|
||||
cwd=$PWD
|
||||
cd $BASEDIR
|
||||
|
||||
init_file="/tmp/PORT/mysql-init"
|
||||
init_file="TMP_DIR/PORT/mysql-init"
|
||||
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
|
||||
$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
|
||||
cd $PWD
|
||||
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
start_ts=$(date +%s)
|
||||
|
||||
PIDFILE="/tmp/PORT/data/mysql_sandboxPORT.pid"
|
||||
SOCKETFILE="/tmp/PORT/mysql_sandboxPORT.sock"
|
||||
PIDFILE="TMP_DIR/PORT/data/mysql_sandboxPORT.pid"
|
||||
SOCKETFILE="TMP_DIR/PORT/mysql_sandboxPORT.sock"
|
||||
BASEDIR="PERCONA_TOOLKIT_SANDBOX"
|
||||
|
||||
sandbox_is_alive() {
|
||||
@@ -11,14 +11,14 @@ sandbox_is_alive() {
|
||||
[ -f $PIDFILE -a -S $SOCKETFILE ] || return 1
|
||||
|
||||
# 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
|
||||
|
||||
# Second, MySQL is truly alive when it respond to a ping.
|
||||
# It's not enough that the mysqld process is running because
|
||||
# InnoDB can take time to create ibdata1, etc. So MySQL is
|
||||
# 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
|
||||
|
||||
return 0
|
||||
@@ -36,7 +36,7 @@ _seq() {
|
||||
echo -n "Stopping MySQL test server on port PORT... "
|
||||
|
||||
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
|
||||
|
||||
for i in $(_seq 60); do
|
||||
|
@@ -2,6 +2,6 @@
|
||||
|
||||
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
|
||||
|
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
TMP_DIR=${TMP_DIR:-/tmp}
|
||||
|
||||
# This script starts a Percona Toolkit sandbox sever. sandbox/test-env
|
||||
# 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.
|
||||
#
|
||||
# Exit 0 if the sandbox server started ok, else 1 and debug_sandbox()
|
||||
@@ -18,12 +19,12 @@ debug_sandbox() {
|
||||
set -x
|
||||
local port="$1"
|
||||
ps x | grep mysql >&2
|
||||
if [ -d "/tmp/$port" ]; then
|
||||
ls -lh /tmp/$port/* >&2
|
||||
cat /tmp/$port/data/mysqld.log >&2
|
||||
tail -n 100 /tmp/$port/data/genlog >&2
|
||||
if [ -d "${TMP_DIR}/$port" ]; then
|
||||
ls -lh ${TMP_DIR}/$port/* >&2
|
||||
cat ${TMP_DIR}/$port/data/mysqld.log >&2
|
||||
tail -n 100 ${TMP_DIR}/$port/data/genlog >&2
|
||||
else
|
||||
echo "/tmp/$port does not exist" >&2
|
||||
echo "${TMP_DIR}/$port does not exist" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -36,25 +37,25 @@ mysql_upgrade_on() {
|
||||
|
||||
make_sandbox() {
|
||||
# Make the sandbox dir and extract the base files.
|
||||
rm -rf /tmp/$port || die "Failed to rm /tmp/$port"
|
||||
mkdir /tmp/$port || die "Failed to mkdir /tmp/$port"
|
||||
rm -rf ${TMP_DIR}/$port || die "Failed to rm ${TMP_DIR}/$port"
|
||||
mkdir ${TMP_DIR}/$port || die "Failed to mkdir ${TMP_DIR}/$port"
|
||||
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
|
||||
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
|
||||
generating_database=1
|
||||
fi
|
||||
|
||||
for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do
|
||||
if [ -f $script ]; then
|
||||
cp $script /tmp/$port
|
||||
cp $script ${TMP_DIR}/$port
|
||||
fi
|
||||
done
|
||||
|
||||
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 cluster_name="${CLUSTER_NAME:-"pt_sandbox_cluster"}"
|
||||
@@ -67,84 +68,85 @@ make_sandbox() {
|
||||
|
||||
local this_listen_port=$(($port + 10))
|
||||
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
|
||||
|
||||
sed -e "s/ADDR/$ip/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||
sed -e "s!CLUSTER_AD!$cluster_address!g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||
sed -e "s/CLUSTER_NAME/$cluster_name/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||
sed -e "s/RECEIVE_PRT/$receive_port/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||
sed -e "s/LISTEN_PRT/$listen_port/g" -i.bak "/tmp/$port/my.sandbox.cnf"
|
||||
sed -e "s!LIBGALERA!$libgalera!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_DIR}/$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_DIR}/$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_DIR}/$port/my.sandbox.cnf"
|
||||
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!TMP_DIR!$TMP_DIR!g" -i.bak $file
|
||||
# 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!MYSQLD!$mysqld!g" -i.bak $file
|
||||
done
|
||||
rm /tmp/$port/*.bak >/dev/null 2>&1
|
||||
rm ${TMP_DIR}/$port/*.bak >/dev/null 2>&1
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
if [ -n "$GENLOG" ]; then
|
||||
echo "log=genlog" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "log=genlog" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
if [ -n "$SKIP_INNODB" ]; then
|
||||
echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "default-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "skip-innodb" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
echo "default-storage-engine=myisam" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
if [ -n "$QUERY_CACHE_SIZE" ]; then
|
||||
echo "query_cache_type=1" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "query_cache_size=$QUERY_CACHE_SIZE" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "query_cache_type=1" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
echo "query_cache_size=$QUERY_CACHE_SIZE" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
if [ -n "$GTID" ]; then
|
||||
echo "gtid_mode=on" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "enforce_gtid_consistency" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "gtid_mode=on" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
echo "enforce_gtid_consistency" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
if [ $generating_database -eq 0 ]; then
|
||||
# If the sandbox is a slave, set it read_only.
|
||||
if [ "$type" = "slave" ]; then
|
||||
echo "read_only" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "read_only" >> ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $generating_database -eq 1 ]; then
|
||||
echo "Creating default databases ..."
|
||||
if [ "$version" > "5.6" ]; then
|
||||
rm -f /tmp/empty-defaults.txt
|
||||
touch /tmp/empty-defaults.txt
|
||||
rm -rf /tmp/$port/data
|
||||
$PERCONA_TOOLKIT_SANDBOX/$mysqld --defaults-file=/tmp/${port}/my.sandbox.cnf --initialize
|
||||
rm -f ${TMP_DIR}/empty-defaults.txt
|
||||
touch ${TMP_DIR}/empty-defaults.txt
|
||||
rm -rf ${TMP_DIR}/$port/data
|
||||
$PERCONA_TOOLKIT_SANDBOX/$mysqld --defaults-file=${TMP_DIR}/${port}/my.sandbox.cnf --initialize
|
||||
else
|
||||
# MySQL up to 5.6 needs mysql_install_db
|
||||
# Support for it is a TODO
|
||||
@@ -152,7 +154,7 @@ make_sandbox() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
init_file="/tmp/$port/mysql-init"
|
||||
init_file="${TMP_DIR}/$port/mysql-init"
|
||||
rm -rf $init_file
|
||||
|
||||
$PERCONA_TOOLKIT_BRANCH/util/version_cmp $minor_version 5.7.5
|
||||
@@ -182,10 +184,10 @@ make_sandbox() {
|
||||
fi
|
||||
|
||||
# Start the sandbox and check that it has InnoDB.
|
||||
/tmp/$port/start
|
||||
${TMP_DIR}/$port/start
|
||||
if [ $? -eq 0 ]; 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
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Sandbox $type $port doesn't have InnoDB." >&2
|
||||
@@ -194,7 +196,7 @@ make_sandbox() {
|
||||
fi
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
@@ -202,7 +204,7 @@ make_sandbox() {
|
||||
if [ -n "$SYS_SCHEMA" ]; then
|
||||
local sys_dir="$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/sys"
|
||||
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
|
||||
else
|
||||
echo "Sandbox $type $port failed to start." >&2
|
||||
@@ -211,17 +213,17 @@ make_sandbox() {
|
||||
fi
|
||||
|
||||
|
||||
/tmp/$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 DATABASE IF NOT EXISTS percona_test";
|
||||
${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
|
||||
mysql_upgrade_on /tmp/$port/my.sandbox.cnf
|
||||
mysql_upgrade_on ${TMP_DIR}/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
# If the sandbox is a slave, start the slave.
|
||||
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/$port/use -e "start slave"
|
||||
${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_DIR}/$port/use -e "start slave"
|
||||
fi
|
||||
|
||||
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
|
||||
# a master-master though.
|
||||
if [ "$type" = "slave" ] && [ ! -d "/tmp/$master_port" ]; then
|
||||
die "Master sandbox does not exist: /tmp/$master_port"
|
||||
if [ "$type" = "slave" ] && [ ! -d "${TMP_DIR}/$master_port" ]; then
|
||||
die "Master sandbox does not exist: ${TMP_DIR}/$master_port"
|
||||
fi
|
||||
|
||||
# ###########################################################################
|
||||
@@ -327,7 +329,7 @@ fi
|
||||
# ###########################################################################
|
||||
# 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
|
||||
echo "Sandbox $port already started (found pid file $PIDFILE)"
|
||||
@@ -344,12 +346,12 @@ else
|
||||
make_sandbox
|
||||
|
||||
# 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/$mm2_port/use -e "start slave"
|
||||
${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_DIR}/$mm2_port/use -e "start slave"
|
||||
|
||||
# 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/$mm1_port/use -e "start slave"
|
||||
${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_DIR}/$mm1_port/use -e "start slave"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
TMP_DIR=${TMP_DIR:-/tmp}
|
||||
|
||||
die() {
|
||||
echo $1 >&2
|
||||
@@ -12,20 +13,20 @@ fi
|
||||
exit_status=0
|
||||
|
||||
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."
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -x "/tmp/$port/stop" ]; then
|
||||
/tmp/$port/stop
|
||||
if [ -x "${TMP_DIR}/$port/stop" ]; then
|
||||
${TMP_DIR}/$port/stop
|
||||
exit_status=$((exit_status | $?))
|
||||
else
|
||||
echo "/tmp/$port is missing files:" >&2
|
||||
ls -la /tmp/$port >&2
|
||||
echo "${TMP_DIR}/$port is missing files:" >&2
|
||||
ls -la ${TMP_DIR}/$port >&2
|
||||
fi
|
||||
|
||||
rm -rf /tmp/$port
|
||||
rm -rf ${TMP_DIR}/$port
|
||||
exit_status=$((exit_status | $?))
|
||||
done
|
||||
|
||||
|
698
sandbox/test-env
698
sandbox/test-env
@@ -1,262 +1,264 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
TMP_DIR=${TMP_DIR:-/tmp}
|
||||
|
||||
# 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
|
||||
# 12346 in /tmp/12346. This script attempts to ensure that all environment
|
||||
# environment is a master on port 12345 in ${TMP_DIR}/12345 and a slave on port
|
||||
# 12346 in ${TMP_DIR}/12346. This script attempts to ensure that all environment
|
||||
# vars like PERCONA_TOOLKIT_BRANCH and PERCONA_TOOLKIT_SANDBOX are correct.
|
||||
# Exist 0 on success/no errors, or 1 on any warnings or errors.
|
||||
|
||||
err() {
|
||||
for msg; do
|
||||
echo "$msg" >&2
|
||||
done
|
||||
for msg; do
|
||||
echo "$msg" >&2
|
||||
done
|
||||
|
||||
if [ "$DEBUG_SANDBOXES" ]; then
|
||||
echo
|
||||
echo "MySQL processes:" >&2
|
||||
ps x | grep mysql >&2
|
||||
if [ "$DEBUG_SANDBOXES" ]; then
|
||||
echo
|
||||
echo "MySQL processes:" >&2
|
||||
ps x | grep mysql >&2
|
||||
|
||||
echo
|
||||
for p in 12345 12346 12347; do
|
||||
echo "Sandbox $p:" >&2
|
||||
if [ -d "/tmp/$p" ]; then
|
||||
ls -lh /tmp/$p/* >&2
|
||||
echo
|
||||
cat /tmp/$p/data/mysqld.log >&2
|
||||
echo
|
||||
tail -n 100 /tmp/$p/data/genlog >&2
|
||||
else
|
||||
echo "/tmp/$p does not exist" >&2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo
|
||||
for p in 12345 12346 12347; do
|
||||
echo "Sandbox $p:" >&2
|
||||
if [ -d "${TMP_DIR}/$p" ]; then
|
||||
ls -lh ${TMP_DIR}/$p/* >&2
|
||||
echo
|
||||
cat ${TMP_DIR}/$p/data/mysqld.log >&2
|
||||
echo
|
||||
tail -n 100 ${TMP_DIR}/$p/data/genlog >&2
|
||||
else
|
||||
echo "${TMP_DIR}/$p does not exist" >&2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
usage() {
|
||||
err "Usage: test-env start|stop|restart|status|checkconfig|reset|kill" \
|
||||
"" \
|
||||
" start Start test servers in /tmp/PORT" \
|
||||
" stop Stop test servers and remvoe all /tmp/PORT" \
|
||||
" kill Kill test servers (use if stop fails)" \
|
||||
" restart Stop and start test servers" \
|
||||
" status Print status of test servers" \
|
||||
" checkconfig Check test env and test servers" \
|
||||
" reset Reset test server binary logs" \
|
||||
" version Print MySQL version of running test servers" \
|
||||
""
|
||||
err "Usage: test-env start|stop|restart|status|checkconfig|reset|kill" \
|
||||
"" \
|
||||
" start Start test servers in ${TMP_DIR}/PORT" \
|
||||
" stop Stop test servers and remvoe all ${TMP_DIR}/PORT" \
|
||||
" kill Kill test servers (use if stop fails)" \
|
||||
" restart Stop and start test servers" \
|
||||
" status Print status of test servers" \
|
||||
" checkconfig Check test env and test servers" \
|
||||
" reset Reset test server binary logs" \
|
||||
" version Print MySQL version of running test servers" \
|
||||
""
|
||||
}
|
||||
|
||||
mysql_basedir_ok() {
|
||||
local basedir=$1
|
||||
if [ ! -d "$basedir" ] || [ ! -d "$basedir/bin" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ ! -x "$basedir/bin/mysqld_safe" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1 # basedir is ok
|
||||
local basedir=$1
|
||||
if [ ! -d "$basedir" ] || [ ! -d "$basedir/bin" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ ! -x "$basedir/bin/mysqld_safe" ]; then
|
||||
return 0
|
||||
fi
|
||||
return 1 # basedir is ok
|
||||
}
|
||||
|
||||
set_mysql_basedir() {
|
||||
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/mysqld" ]; then
|
||||
mysqld="$PERCONA_TOOLKIT_SANDBOX/bin/mysqld"
|
||||
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" ]; then
|
||||
mysqld="$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld"
|
||||
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then
|
||||
mysqld="$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld"
|
||||
else
|
||||
err "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec."
|
||||
return 0
|
||||
fi
|
||||
mysql_basedir_ok $PERCONA_TOOLKIT_SANDBOX
|
||||
local basedir_ok=$?
|
||||
if [ $basedir_ok -eq 1 ]; then
|
||||
export PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX
|
||||
fi
|
||||
return $basedir_ok
|
||||
if [ -x "$PERCONA_TOOLKIT_SANDBOX/bin/mysqld" ]; then
|
||||
mysqld="$PERCONA_TOOLKIT_SANDBOX/bin/mysqld"
|
||||
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld" ]; then
|
||||
mysqld="$PERCONA_TOOLKIT_SANDBOX/sbin/mysqld"
|
||||
elif [ -x "$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld" ]; then
|
||||
mysqld="$PERCONA_TOOLKIT_SANDBOX/libexec/mysqld"
|
||||
else
|
||||
err "Cannot find executable mysqld in $PERCONA_TOOLKIT_SANDBOX/bin, $PERCONA_TOOLKIT_SANDBOX/sbin or $PERCONA_TOOLKIT_SANDBOX/libexec."
|
||||
return 0
|
||||
fi
|
||||
mysql_basedir_ok $PERCONA_TOOLKIT_SANDBOX
|
||||
local basedir_ok=$?
|
||||
if [ $basedir_ok -eq 1 ]; then
|
||||
export PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX
|
||||
fi
|
||||
return $basedir_ok
|
||||
}
|
||||
|
||||
checkconfig() {
|
||||
local print_conf=$1
|
||||
local stat=""
|
||||
conf_err=0
|
||||
local print_conf=$1
|
||||
local stat=""
|
||||
conf_err=0
|
||||
|
||||
if [ -z "$PERCONA_TOOLKIT_BRANCH" ] || [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
|
||||
conf_err=1
|
||||
stat="INVALID"
|
||||
else
|
||||
stat="ok"
|
||||
fi
|
||||
if [ $print_conf ]; then
|
||||
echo "PERCONA_TOOLKIT_BRANCH=$PERCONA_TOOLKIT_BRANCH - $stat"
|
||||
fi
|
||||
if [ -z "$PERCONA_TOOLKIT_BRANCH" ] || [ ! -d "$PERCONA_TOOLKIT_BRANCH" ]; then
|
||||
conf_err=1
|
||||
stat="INVALID"
|
||||
else
|
||||
stat="ok"
|
||||
fi
|
||||
if [ $print_conf ]; then
|
||||
echo "PERCONA_TOOLKIT_BRANCH=$PERCONA_TOOLKIT_BRANCH - $stat"
|
||||
fi
|
||||
|
||||
set_mysql_basedir
|
||||
if [ $? -ne 1 ]; then
|
||||
conf_err=1
|
||||
stat="INVALID"
|
||||
else
|
||||
stat="ok"
|
||||
fi
|
||||
if [ $print_conf ]; then
|
||||
echo -n "PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX - $stat"
|
||||
if [ -n "$BASEDIR_AUTO_DETECTED" ]; then
|
||||
echo " (auto-detected)"
|
||||
else
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
set_mysql_basedir
|
||||
if [ $? -ne 1 ]; then
|
||||
conf_err=1
|
||||
stat="INVALID"
|
||||
else
|
||||
stat="ok"
|
||||
fi
|
||||
if [ $print_conf ]; then
|
||||
echo -n "PERCONA_TOOLKIT_SANDBOX=$PERCONA_TOOLKIT_SANDBOX - $stat"
|
||||
if [ -n "$BASEDIR_AUTO_DETECTED" ]; then
|
||||
echo " (auto-detected)"
|
||||
else
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
return $conf_err
|
||||
return $conf_err
|
||||
}
|
||||
|
||||
sandbox_status() {
|
||||
local type=$1
|
||||
local port=$2
|
||||
local master_port=$3
|
||||
local status=0 # sandbox is ok, no problems
|
||||
local type=$1
|
||||
local port=$2
|
||||
local master_port=$3
|
||||
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 - "
|
||||
if [ -f "/tmp/$port/data/mysql_sandbox$port.pid" ]; then
|
||||
echo "yes"
|
||||
echo -n " PID file has a PID - "
|
||||
local pid=`cat /tmp/$port/data/mysql_sandbox$port.pid 2>/dev/null`
|
||||
if [ -n "$pid" ]; then
|
||||
echo "yes"
|
||||
echo -n " process $pid is alive - "
|
||||
kill -0 $pid >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -n " PID file exists - "
|
||||
if [ -f "${TMP_DIR}/$port/data/mysql_sandbox$port.pid" ]; then
|
||||
echo "yes"
|
||||
echo -n " PID file has a PID - "
|
||||
local pid=`cat ${TMP_DIR}/$port/data/mysql_sandbox$port.pid 2>/dev/null`
|
||||
if [ -n "$pid" ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "NO"
|
||||
status=1
|
||||
fi
|
||||
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"
|
||||
echo -n " process $pid is alive - "
|
||||
kill -0 $pid >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "NO"
|
||||
status=1
|
||||
echo "NO"
|
||||
status=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "NO"
|
||||
status=1
|
||||
fi
|
||||
return $status
|
||||
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_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() {
|
||||
local p=$1
|
||||
ps xw | grep mysqld | grep -v grep | grep /tmp/$p >/dev/null
|
||||
local p=$1
|
||||
ps xw | grep mysqld | grep -v grep | grep ${TMP_DIR}/$p >/dev/null
|
||||
}
|
||||
|
||||
kill_sandbox() {
|
||||
local p=$1
|
||||
local p=$1
|
||||
|
||||
# See if the sandbox server is running.
|
||||
sandbox_is_running $p
|
||||
if [ $? -eq 0 ]; then
|
||||
# Try to kill it with mysqladmin shutdown. We try different
|
||||
# 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 -uroot -pmsandbox shutdown >/dev/null 2>&1
|
||||
mysqladmin -h127.1 -P$p -uroot shutdown >/dev/null 2>&1
|
||||
sleep 2
|
||||
# See if the sandbox server is running.
|
||||
sandbox_is_running $p
|
||||
if [ $? -eq 0 ]; then
|
||||
# Try to kill it with mysqladmin shutdown. We try different
|
||||
# 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 -uroot -pmsandbox shutdown >/dev/null 2>&1
|
||||
mysqladmin -h127.1 -P$p -uroot shutdown >/dev/null 2>&1
|
||||
sleep 2
|
||||
|
||||
# See if the sandbox server is still running.
|
||||
sandbox_is_running $p
|
||||
if [ $? -eq 0 ]; then
|
||||
# Kill both mysqld_safe and mysqld.
|
||||
pid1=`ps xw | grep -v grep | grep mysqld_safe | grep /tmp/$p | awk '{print $1}'`
|
||||
pid2=`ps xw | grep -v grep | grep -v mysqld_safe | grep mysqld | grep /tmp/$p | awk '{print $1}'`
|
||||
[ "$pid1" ] && kill -9 $pid1 # Die, damn you, die!
|
||||
[ "$pid2" ] && kill -9 $pid2
|
||||
sleep 2
|
||||
# See if the sandbox server is still running.
|
||||
sandbox_is_running $p
|
||||
if [ $? -eq 0 ]; then
|
||||
# Kill both mysqld_safe and mysqld.
|
||||
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_DIR}/$p | awk '{print $1}'`
|
||||
[ "$pid1" ] && kill -9 $pid1 # Die, damn you, die!
|
||||
[ "$pid2" ] && kill -9 $pid2
|
||||
sleep 2
|
||||
|
||||
# Third and finaly check if the sandbox server is running.
|
||||
sandbox_is_running $p
|
||||
if [ $? -eq 0 ]; then
|
||||
err "Failed to kill MySQL test server on port $p (PID $pid1, $pid2)"
|
||||
return 1
|
||||
else
|
||||
echo "Killed MySQL test server on port $p (PID $pid1, $pid2)"
|
||||
fi
|
||||
else
|
||||
echo "Killed MySQL test server on port $p"
|
||||
fi
|
||||
fi
|
||||
# Third and finaly check if the sandbox server is running.
|
||||
sandbox_is_running $p
|
||||
if [ $? -eq 0 ]; then
|
||||
err "Failed to kill MySQL test server on port $p (PID $pid1, $pid2)"
|
||||
return 1
|
||||
else
|
||||
echo "Killed MySQL test server on port $p (PID $pid1, $pid2)"
|
||||
fi
|
||||
else
|
||||
echo "Killed MySQL test server on port $p"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "/tmp/$p" ]; then
|
||||
rm -rf /tmp/$p
|
||||
echo "Removed /tmp/$p"
|
||||
fi
|
||||
if [ -d "${TMP_DIR}/$p" ]; then
|
||||
rm -rf ${TMP_DIR}/$p
|
||||
echo "Removed ${TMP_DIR}/$p"
|
||||
fi
|
||||
|
||||
return 0
|
||||
return 0
|
||||
}
|
||||
|
||||
MYSQL_VERSION=""
|
||||
set_mysql_version() {
|
||||
if [ -d /tmp/12345 ] && [ -f /tmp/12345/use ]; then
|
||||
MYSQL_VERSION=$(/tmp/12345/use -ss -e "SELECT VERSION()" \
|
||||
| cut -d'.' -f1,2)
|
||||
fi
|
||||
if [ -d ${TMP_DIR}/12345 ] && [ -f ${TMP_DIR}/12345/use ]; then
|
||||
MYSQL_VERSION=$(${TMP_DIR}/12345/use -ss -e "SELECT VERSION()" \
|
||||
| cut -d'.' -f1,2)
|
||||
fi
|
||||
}
|
||||
|
||||
_seq() {
|
||||
local i="$1"
|
||||
awk "BEGIN { for(i=1; i<=$i; i++) print i; }"
|
||||
local i="$1"
|
||||
awk "BEGIN { for(i=1; i<=$i; i++) print i; }"
|
||||
}
|
||||
|
||||
# ###########################################################################
|
||||
# Sanity check the cmd line options.
|
||||
# ###########################################################################
|
||||
if [ $# -lt 1 ]; then
|
||||
usage
|
||||
exit 1
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
opt=$1
|
||||
@@ -272,158 +274,158 @@ if [ -e ${PERCONA_TOOLKIT_SANDBOX}/lib/mysql/libjemalloc.so ]; then
|
||||
fi
|
||||
|
||||
if [ $opt = 'checkconfig' ]; then
|
||||
checkconfig 1
|
||||
echo -n "Percona Toolkit test environment config is "
|
||||
if [ $conf_err -eq 0 ]; then
|
||||
echo "ok!"
|
||||
exit 0
|
||||
else
|
||||
echo "invalid."
|
||||
exit 1
|
||||
fi
|
||||
checkconfig 1
|
||||
echo -n "Percona Toolkit test environment config is "
|
||||
if [ $conf_err -eq 0 ]; then
|
||||
echo "ok!"
|
||||
exit 0
|
||||
else
|
||||
echo "invalid."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
checkconfig
|
||||
if [ $conf_err -eq 1 ]; then
|
||||
err "The Percona Toolkit test environment config is invalid." \
|
||||
"Run '$0 checkconfig' to see the current configuration."
|
||||
exit 1
|
||||
fi
|
||||
checkconfig
|
||||
if [ $conf_err -eq 1 ]; then
|
||||
err "The Percona Toolkit test environment config is invalid." \
|
||||
"Run '$0 checkconfig' to see the current configuration."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
case $opt in
|
||||
start)
|
||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
./start-sandbox "${2:-"master"}" 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
set_mysql_version
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
if [ "${2:-""}" = "channels" ] && [ "$MYSQL_VERSION" '>' "5.6" ]; then
|
||||
./start-sandbox master 12346
|
||||
exit_status=$((exit_status | $?))
|
||||
./start-sandbox master 12347
|
||||
exit_status=$((exit_status | $?))
|
||||
/tmp/12345/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
/tmp/12346/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
/tmp/12347/use < $PERCONA_TOOLKIT_BRANCH/sandbox/slave_channels.sql
|
||||
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"
|
||||
start)
|
||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
./start-sandbox "${2:-"master"}" 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
set_mysql_version
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
if [ "${2:-""}" = "channels" ] && [ "$MYSQL_VERSION" '>' "5.6" ]; then
|
||||
./start-sandbox master 12346
|
||||
exit_status=$((exit_status | $?))
|
||||
./start-sandbox master 12347
|
||||
exit_status=$((exit_status | $?))
|
||||
${TMP_DIR}/12345/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12346/use < $PERCONA_TOOLKIT_BRANCH/sandbox/gtid_on.sql
|
||||
exit_status=$?
|
||||
${TMP_DIR}/12347/use < $PERCONA_TOOLKIT_BRANCH/sandbox/slave_channels.sql
|
||||
exit_status=$?
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
fi
|
||||
|
||||
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
|
||||
./start-sandbox "${2:-"slave"}" 12346 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
./start-sandbox "${2:-"slave"}" 12347 12346
|
||||
exit_status=$((exit_status | $?))
|
||||
fi
|
||||
|
||||
# Create percona_test db and checksum all the tables.
|
||||
../util/checksum-test-dataset
|
||||
|
||||
# LOAD DATA is disabled or broken on some boxes.
|
||||
# PerconaTest exports $can_load_data which is true
|
||||
# if percona_test.load_data has a row with 1,
|
||||
# signaling that LOAD DATA LOCAL INFILE worked.
|
||||
../util/check-load-data
|
||||
|
||||
ping=$(/tmp/12345/use -ss -e "SELECT MD5(RAND())")
|
||||
/tmp/12345/use -e "SET AUTOCOMMIT=1; REPLACE INTO percona_test.sentinel (id, ping) VALUES (1, '$ping')";
|
||||
echo -n "Waiting for replication to finish..."
|
||||
for i in $(_seq 60); do
|
||||
pong=$(/tmp/12347/use -ss -e "SELECT ping FROM percona_test.sentinel WHERE id=1 AND ping='$ping'" 2>/dev/null)
|
||||
[ "$ping" = "$pong" ] && break
|
||||
echo -n '.'
|
||||
sleep 1
|
||||
done
|
||||
if [ "$ping" = "$pong" ]; then
|
||||
echo " OK"
|
||||
else
|
||||
echo " FAILED"
|
||||
exit_status=$((exit_status | 1))
|
||||
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_DIR}/12345/stop >/dev/null
|
||||
${TMP_DIR}/12345/start >/dev/null
|
||||
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}')
|
||||
if [ ${size:-0} -ne 3 ]; then
|
||||
echo "FAILED"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
echo "Percona Toolkit test environment started with MySQL v$MYSQL_VERSION."
|
||||
else
|
||||
DEBUG_SANDBOXES=1
|
||||
err "There was an error starting the Percona Toolkit test environment."
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
./stop-sandbox 12349 12348 12347 12346 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
./stop-sandbox 2903 2902 2901 2900
|
||||
exit_status=$((exit_status | $?))
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
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
|
||||
;;
|
||||
|
||||
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
|
||||
|
||||
# Create percona_test db and checksum all the tables.
|
||||
../util/checksum-test-dataset
|
||||
|
||||
# LOAD DATA is disabled or broken on some boxes.
|
||||
# PerconaTest exports $can_load_data which is true
|
||||
# if percona_test.load_data has a row with 1,
|
||||
# signaling that LOAD DATA LOCAL INFILE worked.
|
||||
../util/check-load-data
|
||||
|
||||
ping=$(${TMP_DIR}/12345/use -ss -e "SELECT MD5(RAND())")
|
||||
${TMP_DIR}/12345/use -e "SET AUTOCOMMIT=1; REPLACE INTO percona_test.sentinel (id, ping) VALUES (1, '$ping')";
|
||||
echo -n "Waiting for replication to finish..."
|
||||
for i in $(_seq 60); do
|
||||
pong=$(${TMP_DIR}/12347/use -ss -e "SELECT ping FROM percona_test.sentinel WHERE id=1 AND ping='$ping'" 2>/dev/null)
|
||||
[ "$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
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
echo "Percona Toolkit test environment started with MySQL v$MYSQL_VERSION."
|
||||
else
|
||||
DEBUG_SANDBOXES=1
|
||||
err "There was an error starting the Percona Toolkit test environment."
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
./stop-sandbox 12349 12348 12347 12346 12345
|
||||
exit_status=$((exit_status | $?))
|
||||
./stop-sandbox 2903 2902 2901 2900
|
||||
exit_status=$((exit_status | $?))
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
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
|
||||
|
||||
exit $exit_status
|
||||
|
@@ -135,7 +135,7 @@ CREATE TABLE `innodb_ddl_log` (
|
||||
`new_file_path` varchar(512) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
|
||||
PRIMARY KEY (`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
|
||||
CREATE TABLE `innodb_dynamic_metadata` (
|
||||
|
@@ -46,7 +46,7 @@ $sb->load_file('master', "t/pt-online-schema-change/samples/pt-229.sql");
|
||||
|
||||
my $num_rows = 40000;
|
||||
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.");
|
||||
$master_dbh->do("FLUSH TABLES");
|
||||
|
@@ -57,7 +57,7 @@ $sb->load_file('master', "t/pt-online-schema-change/samples/slave_lag.sql");
|
||||
|
||||
my $num_rows = 10000;
|
||||
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
|
||||
$master_dbh->do('RESET QUERY CACHE');
|
@@ -42,7 +42,7 @@ $output = output(
|
||||
|
||||
is(
|
||||
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"
|
||||
);
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
DROP DATABASE IF EXISTS db1;
|
||||
CREATE DATABASE db1;
|
||||
USE db1;
|
||||
CREATE TABLE cp1251(f1 VARCHAR(100) CHARACTER SET LATIN1, f2 VARCHAR(100) CHARACTER SET CP1251) ENGINE=InnoDB;
|
||||
|
@@ -37,6 +37,7 @@ my $dbh = DBI->connect(
|
||||
RaiseError => 1,
|
||||
PrintError => 1,
|
||||
ShowErrorStatement => 1,
|
||||
# mysql_local_infile => 1,
|
||||
});
|
||||
|
||||
$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.$$`;
|
||||
|
||||
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 ) {
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user