From cf6e4847b457674710d8c105b8e0469d5b29d756 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Fri, 29 Jun 2012 15:42:03 -0600 Subject: [PATCH 1/6] Changes to sandbox/jenkins-test: get 32-/64-bit barebones MySQL according to OS arch; use /Users/daniel for MySQL binaries; and remove ITERATIONS. --- sandbox/jenkins-test | 58 ++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/sandbox/jenkins-test b/sandbox/jenkins-test index 9ac848a6..227d3fd4 100755 --- a/sandbox/jenkins-test +++ b/sandbox/jenkins-test @@ -1,9 +1,10 @@ #!/bin/sh -###################################### -# Source our alt_cmds.sh for _seq(). # -###################################### -. lib/bash/alt_cmds.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. # @@ -20,17 +21,43 @@ util/check-dev-env ##################################### # Install barebones MySQL binaries. # ##################################### -if ! [ -d "mysql-${MYSQL}-barebones" ]; then - wget -q http://hackmysql.com/mysql-${MYSQL}-barebones.tar.gz - tar xvfz mysql-${MYSQL}-barebones.tar.gz + +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 http://hackmysql.com/barebones/mysql/$MYSQL/$ARCH + tarball=$(ls -t1 | head -n1) + tar xvfz "$tarball" + rm "$tarball" + ) + 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="$PWD/mysql-${MYSQL}-barebones" -export PATH="$PATH:/usr/sbin:$PWD/mysql-${MYSQL}-barebones/bin" +export PERCONA_TOOLKIT_SANDBOX="$MYSQL_BASE_DIR" +export PATH="$PATH:/usr/sbin:$MYSQL_BASE_DIR/bin" ############################# # Check and start test env. # @@ -55,13 +82,12 @@ fi # Run the tests. # ################## EXIT_STATUS=0 -ITERATIONS="${ITERATIONS:-1}" -for iter in $(_seq $ITERATIONS); do - ( - $TEST_CMD - ) - EXIT_STATUS=$(($? | 0)) -done +TEST_CMD="${TEST_CMD:-"prove -r t/"}" + +( + $TEST_CMD +) +EXIT_STATUS=$(($? | 0)) ############# # Clean up. # From e560b7e3dcc640b5b0f1993bc455ba70e650a55c Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Fri, 29 Jun 2012 15:55:06 -0600 Subject: [PATCH 2/6] Fix find cmd and mysqld -V test. wget to explicit file name. --- sandbox/jenkins-test | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sandbox/jenkins-test b/sandbox/jenkins-test index 227d3fd4..0a9fdd22 100755 --- a/sandbox/jenkins-test +++ b/sandbox/jenkins-test @@ -32,22 +32,21 @@ 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 + 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 http://hackmysql.com/barebones/mysql/$MYSQL/$ARCH - tarball=$(ls -t1 | head -n1) - tar xvfz "$tarball" - rm "$tarball" + 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 +if [ -z $("$MYSQL_BASE_DIR/bin/mysqld" -V) ]; then echo "$MYSQL_BASE_DIR/bin/mysqld does not execute" >&2 exit 1 fi From 80308dcb5d3a1d97266767f385c29a780fb80a1a Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Fri, 29 Jun 2012 16:12:33 -0600 Subject: [PATCH 3/6] Fix arch check and find_mysql_base_dir(). --- sandbox/jenkins-test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sandbox/jenkins-test b/sandbox/jenkins-test index 0a9fdd22..2b7ec977 100755 --- a/sandbox/jenkins-test +++ b/sandbox/jenkins-test @@ -22,7 +22,7 @@ util/check-dev-env # Install barebones MySQL binaries. # ##################################### -if [ $(uname -a | grep x86_64 >/dev/null 2>&1) ]; then +if uname -a | grep x86_64 >/dev/null 2>&1; then ARCH="64" else ARCH="32" @@ -32,10 +32,10 @@ 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 + find "$MYSQL_BIN_DIR" -name "mysql-$1*" -type d | tail -n 1 } -MYSQL_BASE_DIR=$(find_mysql_base_dir $MYSQL) +MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)" if [ -z "$MYSQL_BASE_DIR" ]; then ( cd $MYSQL_BIN_DIR @@ -43,7 +43,7 @@ if [ -z "$MYSQL_BASE_DIR" ]; then tar xvfz mysql.tar.gz rm mysql.tar.gz ) - MYSQL_BASE_DIR=$(find_mysql_base_dir $MYSQL) + MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)" fi if [ -z $("$MYSQL_BASE_DIR/bin/mysqld" -V) ]; then From c5fbee7541fd9b0c8e0f7ea34b8b6a4edb3b1175 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Fri, 29 Jun 2012 18:05:56 -0600 Subject: [PATCH 4/6] Add util/make-barebones. --- util/make-barebones | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 util/make-barebones diff --git a/util/make-barebones b/util/make-barebones new file mode 100755 index 00000000..620ffccf --- /dev/null +++ b/util/make-barebones @@ -0,0 +1,43 @@ +#!/bin/sh + +# This script makes a barebones tarball from a full MySQL binary tarball. +# A full tarball is > 150M, but a barebones is usually < 40M. The barebones +# tarballs are fetched from hackmysql.com by sandbox/jenkins-test to create +# MySQL sandboxes for testing. + +set -x + +tarball="$1" +version=$(echo $tarball | awk -F'-' '{print $2}') +full_dir=${tarball%".tar.gz"} + +tar xvfz $tarball \ + "$full_dir/COPYING" \ + "$full_dir/README" \ + "$full_dir/share/errmsg*" \ + "$full_dir/share/charset*" \ + "$full_dir/share/english*" \ + "$full_dir/bin/my_print_defaults" \ + "$full_dir/bin/mysql" \ + "$full_dir/bin/mysqld" \ + "$full_dir/bin/mysqladmin" \ + "$full_dir/bin/mysqlbinlog" \ + "$full_dir/bin/mysqld" \ + "$full_dir/bin/mysqld_safe" \ + "$full_dir/bin/safe_mysqld" + +echo "This tarball was created from $tarball. It contains only the files necessary for creating a Percona Toolkit sandbox test server." > $full_dir/README.barebones + +file_info=$(file "$full_dir/bin/mysqld") +if file "$full_dir/bin/mysqld" | grep -q "x86_64"; then + arch="x86_64" +else + arch="i386" +fi + +bare_dir="mysql-$version-$arch-barebones" +mv $full_dir $bare_dir +tar cvfz $bare_dir.tar.gz $bare_dir +rm -rf $bare_dir + +exit From 137e319afac1e2989266ca213e6b1b5efe4d5fff Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Fri, 29 Jun 2012 18:18:28 -0600 Subject: [PATCH 5/6] Fix mysqld -V test again. --- sandbox/jenkins-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sandbox/jenkins-test b/sandbox/jenkins-test index 2b7ec977..afd51ac9 100755 --- a/sandbox/jenkins-test +++ b/sandbox/jenkins-test @@ -46,7 +46,7 @@ if [ -z "$MYSQL_BASE_DIR" ]; then MYSQL_BASE_DIR="$(find_mysql_base_dir $MYSQL)" fi -if [ -z $("$MYSQL_BASE_DIR/bin/mysqld" -V) ]; then +if [ -z "$("$MYSQL_BASE_DIR/bin/mysqld" -V)" ]; then echo "$MYSQL_BASE_DIR/bin/mysqld does not execute" >&2 exit 1 fi From 07b0dbcb59a6cf99fb6e16fcfec1c74f208bd6ff Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Fri, 29 Jun 2012 18:29:08 -0600 Subject: [PATCH 6/6] Extract share/mysql from full MySQL 5.0 binaries. --- util/make-barebones | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/make-barebones b/util/make-barebones index 620ffccf..bc58f984 100755 --- a/util/make-barebones +++ b/util/make-barebones @@ -17,6 +17,9 @@ tar xvfz $tarball \ "$full_dir/share/errmsg*" \ "$full_dir/share/charset*" \ "$full_dir/share/english*" \ + "$full_dir/share/mysql/errmsg*" \ + "$full_dir/share/mysql/charset*" \ + "$full_dir/share/mysql/english*" \ "$full_dir/bin/my_print_defaults" \ "$full_dir/bin/mysql" \ "$full_dir/bin/mysqld" \