mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 07:30:02 +00:00
Remove last references to Maakit. Update sandbox test env scripts.
This commit is contained in:
110
sandbox/test-env
110
sandbox/test-env
@@ -1,58 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script controls the Maatkit test environment. The mk test env is
|
||||
# a master-slave pair on ports 12345 and 12346, running from respective
|
||||
# directories in /tmp. This script attempts to ensure that all environment
|
||||
# vars like PERCONA_TOOLKIT_BRANCH and PERCONA_TOOLKIT_SANDBOX are correct. The
|
||||
# exit status is 0 on success and 1 on any failure. There's no option to
|
||||
# disable output, so just >/dev/null if you only care about the exit status.
|
||||
|
||||
_d() {
|
||||
if [ -z "$MKDEBUG" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Is there a way to echo directly to STDERR?
|
||||
# This is my hackish way.
|
||||
for msg; do
|
||||
echo "$msg" 1>/dev/null 1>&2
|
||||
done
|
||||
}
|
||||
# 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
|
||||
# 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() {
|
||||
echo
|
||||
for msg; do
|
||||
echo "$msg"
|
||||
done
|
||||
echo "See http://code.google.com/p/maatkit/wiki/Testing for more information."
|
||||
echo
|
||||
}
|
||||
|
||||
usage() {
|
||||
err "Usage: mk-test-env start|stop|restart|status|checkconfig|reset|kill" \
|
||||
"" \
|
||||
" start Start Maatkit test environment (mk test env)" \
|
||||
" stop Stop and remove mk test env" \
|
||||
" restart Stop and start mk test env" \
|
||||
" status Check and display status of mk test env" \
|
||||
" checkconfig Check and display configuration of mk test env" \
|
||||
" reset Reset mk test env master/slave bin logs" \
|
||||
" kill Kill mk test env (use if stop fails)" \
|
||||
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" \
|
||||
""
|
||||
}
|
||||
|
||||
mysql_basedir_ok() {
|
||||
local basedir=$1
|
||||
_d "basedir=$basedir"
|
||||
if [ ! -d "$basedir" ] || [ ! -d "$basedir/bin" ]; then
|
||||
_d "basedir invalid"
|
||||
return 0
|
||||
fi
|
||||
if [ ! -x "$basedir/bin/mysqld_safe" ]; then
|
||||
_d "$basedir/bin/mysqld_safe doesn't exist"
|
||||
return 0
|
||||
fi
|
||||
_d "basedir ok"
|
||||
return 1 # basedir is ok
|
||||
}
|
||||
|
||||
@@ -62,14 +44,11 @@ set_mysql_basedir() {
|
||||
BASEDIR_AUTO_DETECTED=1
|
||||
mysqld=`which mysqld 2>/dev/null`
|
||||
if [ -n "$mysqld" ]; then
|
||||
_d "Found mysqld: $mysqld"
|
||||
PERCONA_TOOLKIT_SANDBOX=`$mysqld --verbose --help 2>/dev/null | grep 'basedir ' | awk '{print $2}'`
|
||||
if [ -z "$PERCONA_TOOLKIT_SANDBOX" ]; then
|
||||
_d "$mysqld --verbose --help | grep | ask failed"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
_d "Could not find mysqld"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
@@ -132,14 +111,13 @@ sandbox_status() {
|
||||
local master_port=$3
|
||||
local status=0 # sandbox is ok, no problems
|
||||
|
||||
echo "Maatkit sandbox $type $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`
|
||||
_d "$type $port PID: $pid"
|
||||
if [ -n "$pid" ]; then
|
||||
echo "yes"
|
||||
echo -n " process $pid is alive - "
|
||||
@@ -208,7 +186,7 @@ sandbox_status() {
|
||||
|
||||
sandbox_is_running() {
|
||||
local p=$1
|
||||
ps axw | grep mysqld | grep /tmp/$p >/dev/null
|
||||
ps axw | grep mysqld | grep -v grep | grep /tmp/$p >/dev/null
|
||||
}
|
||||
|
||||
kill_sandbox() {
|
||||
@@ -237,13 +215,13 @@ kill_sandbox() {
|
||||
# Third and finaly check if the sandbox server is running.
|
||||
sandbox_is_running $p
|
||||
if [ $? -eq 0 ]; then
|
||||
err "Failed to kill sandbox $p (PID $pid1, $pid2)"
|
||||
err "Failed to kill MySQL test server on port $p (PID $pid1, $pid2)"
|
||||
rmdir=0
|
||||
else
|
||||
echo "Killed sandbox $p (PID $pid1, $pid2)"
|
||||
echo "Killed MySQL test server on port $p (PID $pid1, $pid2)"
|
||||
fi
|
||||
else
|
||||
echo "Killed sandbox $p"
|
||||
echo "Killed MySQL test server on port $p"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -255,12 +233,10 @@ kill_sandbox() {
|
||||
return
|
||||
}
|
||||
|
||||
print_sandbox_version() {
|
||||
if [ -n "$1" ]; then
|
||||
echo -n "Maatkit sandboxes running MySQL version "
|
||||
fi
|
||||
MYSQL_VERSION=""
|
||||
set_mysql_version() {
|
||||
if [ -d /tmp/12345 ] && [ -f /tmp/12345/use ]; then
|
||||
/tmp/12345/use -N -e "select version()" | head -n 2 | tail -n 1 | cut -d'.' -f1,2
|
||||
MYSQL_VERSION=$(/tmp/12345/use -N -e "select version()" | head -n 2 | tail -n 1 | cut -d'.' -f1,2)
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -280,12 +256,9 @@ opt=$1
|
||||
|
||||
exit_status=0
|
||||
|
||||
# Print some debug info about this run.
|
||||
_d "" "`date`" "cwd: `pwd`" "`env | grep PATH`" "$0 $*"
|
||||
|
||||
if [ $opt = 'checkconfig' ]; then
|
||||
checkconfig 1
|
||||
echo -n "Maatkit test environment config is "
|
||||
echo -n "Percona Toolkit test environment config is "
|
||||
if [ $conf_err -eq 0 ]; then
|
||||
echo "ok!"
|
||||
exit 0
|
||||
@@ -296,7 +269,7 @@ if [ $opt = 'checkconfig' ]; then
|
||||
else
|
||||
checkconfig
|
||||
if [ $conf_err -eq 1 ]; then
|
||||
err "The Maatkit test environment config is invalid." \
|
||||
err "The Percona Toolkit test environment config is invalid." \
|
||||
"Run '$0 checkconfig' to see the current configuration."
|
||||
exit 1
|
||||
fi
|
||||
@@ -307,7 +280,7 @@ fi
|
||||
# /usr/bin/mysqld Ver 5.1.34 for linux-gnu on x86_64 (MySQL Community Server)
|
||||
version=`$mysqld -V | awk '{print $3}' | cut -d. -f 1,2`;
|
||||
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/$version" ]; then
|
||||
err "Maatkit sandbox server version $version does not exists."
|
||||
err "Percona Toolkit sandbox server version $version does not exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -321,31 +294,36 @@ case $opt in
|
||||
exit_status=$?
|
||||
if [ "$version" != "4.0" ] && [ "$version" != "4.1" ]; then
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Loading sakila database..."
|
||||
echo -n "Loading sakila database... "
|
||||
./load-sakila-db 12345
|
||||
exit_status=$?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "FAILED"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
echo "Maatkit test environment started!"
|
||||
set_mysql_version
|
||||
echo "Percona Toolkit test environment started with MySQL v$MYSQL_VERSION."
|
||||
else
|
||||
# Stop but don't remove the sandboxes. The mysql error log
|
||||
# may say why MySQL failed to start.
|
||||
./stop-sandbox all >/dev/null 2>&1
|
||||
err "There was an error starting the Maatkit test environment."
|
||||
err "There was an error starting the Percona Toolkit test environment."
|
||||
fi
|
||||
print_sandbox_version 1
|
||||
;;
|
||||
stop)
|
||||
cd $PERCONA_TOOLKIT_BRANCH/sandbox
|
||||
./stop-sandbox remove all
|
||||
exit_status=$?
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
echo "Maatkit test environment stopped."
|
||||
echo "Percona Toolkit test environment stopped."
|
||||
else
|
||||
err "There was an error stopping the Maatkit test environment." \
|
||||
"The Maatkit sandboxes may still be running."
|
||||
err "There was an error stopping the Percona Toolkit test environment." \
|
||||
"The MySQL test servers may still be running."
|
||||
fi
|
||||
;;
|
||||
kill)
|
||||
@@ -364,7 +342,7 @@ case $opt in
|
||||
master_status=$?
|
||||
sandbox_status 'slave' '12346' '12345'
|
||||
slave_status=$?
|
||||
echo -n "Maaktit test environment is "
|
||||
echo -n "Percona Test test environment is "
|
||||
if [ $master_status -eq 0 ] && [ $slave_status -eq 0 ]; then
|
||||
echo "ok!"
|
||||
else
|
||||
@@ -373,9 +351,10 @@ case $opt in
|
||||
fi
|
||||
;;
|
||||
reset)
|
||||
# This resets the master and slave relay logs. It's used in
|
||||
# mk-table-sync/t/110_replicate_do_db.t. It's not checked;
|
||||
# user beware.
|
||||
# Several tests reset the bin logs so that queries from prior tests
|
||||
# don't replicate to new sandbox servers. This makes creating new
|
||||
# sandbox servers a lot faster. There's no check if this works or
|
||||
# not, so... yeah.
|
||||
/tmp/12345/use -e "RESET MASTER"
|
||||
/tmp/12346/use -e "RESET MASTER"
|
||||
/tmp/12346/use -e "STOP SLAVE"
|
||||
@@ -384,7 +363,8 @@ case $opt in
|
||||
exit_status=0
|
||||
;;
|
||||
version)
|
||||
print_sandbox_version
|
||||
set_mysql_version
|
||||
echo $MYSQL_VERSION
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
|
Reference in New Issue
Block a user