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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
#!/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. #
#########################
env
df -h
w
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
APP="${FORK:-"mysql"}"
MYSQL_BIN_DIR="$HOME/mysql-bin"
[ -d "$MYSQL_BIN_DIR" ] || mkdir "$MYSQL_BIN_DIR"
find_mysql_base_dir() {
find "$MYSQL_BIN_DIR" -name "$APP-$1*" -type d | tail -n 1
}
MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)"
REFETCH_MYSQL="${REFETCH_MYSQL:-""}"
if [ "$MYSQL_BASE_DIR" -a "$REFETCH_MYSQL" ]; then
rm -rf "$MYSQL_BASE_DIR"
MYSQL_BASE_DIR=""
fi
if [ -z "$MYSQL_BASE_DIR" ]; then
(
cd $MYSQL_BIN_DIR
wget -q -O mysql.tar.gz http://hackmysql.com/barebones/$APP/$MYSQL/$ARCH \
|| exit 1
tar xvfz mysql.tar.gz
rm mysql.tar.gz
)
MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)"
fi
if [ $APP = "mysql" ]; then
mysqld_check="$("$MYSQL_BASE_DIR/bin/mysqld" -V)"
elif [ $APP = "pxc" ]; then
ip="$(perl -MNet::Address::IP::Local -le 'print Net::Address::IP::Local->public')"
mysqld_check="$("$MYSQL_BASE_DIR/bin/mysqld" -V --bind-address $ip)"
else
echo "Invalid FORK=$APP" >&2
exit 1
fi
if [ -z "$mysqld_check" ]; 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"
export USER="${USER:-"jenkins"}"
# ######################################### #
# 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
if [ $APP = "mysql" ]; then
sandbox/test-env start || exit 1
elif [ $APP = "pxc" ]; then
sandbox/test-env start cluster || exit 1
else
echo "Invalid FORK=$app" >&2
exit 1
fi
#######################
# 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. #
#############
sandbox/test-env stop
exit $EXIT_STATUS
|