1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/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
#####################################
# 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:$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
|