mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-04 11:37:16 +00:00
119 lines
2.7 KiB
Bash
Executable File
119 lines
2.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# This script is used to do a test run on a Jenkins node. Jenkins jobs
|
|
# set env vars based on job params (like MYSQL and TEST_CMD) then execute
|
|
# this script which does the rest. When this script exists, the Jenkins
|
|
# job exists, so if some commands (like check-dev-env) fail, then the
|
|
# Jenkins job will fail too.
|
|
|
|
##############
|
|
# Set modes. #
|
|
##############
|
|
set +u
|
|
set -e
|
|
set -x
|
|
|
|
##################################
|
|
# Check for needed Perl modules. #
|
|
##################################
|
|
util/check-dev-env
|
|
|
|
#########################
|
|
# Check the system env. #
|
|
#########################
|
|
whoami
|
|
id
|
|
if [ "$(id -u)" = "0" ]; then
|
|
echo "Cannot run as root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
#####################################
|
|
# Install barebones MySQL binaries. #
|
|
#####################################
|
|
|
|
if uname -a | grep x86_64 >/dev/null 2>&1; then
|
|
ARCH="64"
|
|
else
|
|
ARCH="32"
|
|
fi
|
|
|
|
MYSQL_BIN_DIR="$HOME/mysql-bin"
|
|
[ -d "$MYSQL_BIN_DIR" ] || mkdir "$MYSQL_BIN_DIR"
|
|
|
|
find_mysql_base_dir() {
|
|
find "$MYSQL_BIN_DIR" -name "mysql-$1*" -type d | tail -n 1
|
|
}
|
|
|
|
MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)"
|
|
if [ -z "$MYSQL_BASE_DIR" ]; then
|
|
(
|
|
cd $MYSQL_BIN_DIR
|
|
wget -q -O mysql.tar.gz http://hackmysql.com/barebones/mysql/$MYSQL/$ARCH
|
|
tar xvfz mysql.tar.gz
|
|
rm mysql.tar.gz
|
|
)
|
|
MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)"
|
|
fi
|
|
|
|
if [ -z "$("$MYSQL_BASE_DIR/bin/mysqld" -V)" ]; then
|
|
echo "$MYSQL_BASE_DIR/bin/mysqld does not execute" >&2
|
|
exit 1
|
|
fi
|
|
|
|
##########################
|
|
# Set required env vars. #
|
|
##########################
|
|
export PERCONA_TOOLKIT_BRANCH="$PWD"
|
|
export PERCONA_TOOLKIT_SANDBOX="$MYSQL_BASE_DIR"
|
|
export PATH="$PATH:/usr/sbin:/usr/local/bin:$MYSQL_BASE_DIR/bin"
|
|
export LANG="en_US.UTF-8"
|
|
|
|
# ######################################### #
|
|
# Remove conf files that's shouldn't exist. #
|
|
# ######################################### #
|
|
rm -rf /tmp/pt-* || true
|
|
rm -rf /tmp/pt_* || true
|
|
rm -rf /tmp/percona* || true
|
|
rm ~/.pt-*conf* || true
|
|
rm ~/.my* || true
|
|
|
|
#############################
|
|
# Check and start test env. #
|
|
#############################
|
|
sandbox/test-env checkconfig || exit 1
|
|
sandbox/test-env stop || exit 1
|
|
sandbox/test-env kill || exit 1
|
|
sandbox/test-env start || exit 1
|
|
|
|
#######################
|
|
# Set debug env vars. #
|
|
#######################
|
|
if [ "$DEBUG_CODE" = "true" ]; then
|
|
export PTDEBUG=1
|
|
fi
|
|
|
|
if [ "$DEBUG_TEST" = "true" ]; then
|
|
export PTDEVDEBUG=1
|
|
fi
|
|
|
|
##################
|
|
# Run the tests. #
|
|
##################
|
|
EXIT_STATUS=0
|
|
TEST_CMD="${TEST_CMD:-"prove -r t/"}"
|
|
|
|
(
|
|
eval $TEST_CMD
|
|
)
|
|
EXIT_STATUS=$(($? | 0))
|
|
|
|
#############
|
|
# Clean up. #
|
|
#############
|
|
set +x
|
|
sandbox/test-env stop
|
|
set -x
|
|
|
|
exit $EXIT_STATUS
|