From d44e8b539b474303d60831e027009b7c0d58af77 Mon Sep 17 00:00:00 2001 From: baron Date: Fri, 30 Mar 2012 17:04:25 -0400 Subject: [PATCH] clean up a couple of things causing tests to fail for me, and remove a feature that's not quite ready yet, and add another feature for innodb compression --- bin/pt-mysql-summary | 16 ++++++++-------- lib/bash/report_mysql_info.sh | 6 +++--- lib/bash/summary_common.sh | 16 ++++++++-------- t/pt-deadlock-logger/basics.t | 2 +- t/pt-mysql-summary/pt-mysql-summary.t | 8 +++++--- .../samples/expected_output_temp002.txt | 4 +--- .../samples/expected_output_temp003.txt | 3 --- .../samples/expected_output_temp004.txt | 3 --- 8 files changed, 26 insertions(+), 32 deletions(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 3128d037..193bea6e 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -700,20 +700,20 @@ has_symbols () { } setup_data_dir () { - local OPT_SAVE_DATA="$1" + local existing_dir="$1" local data_dir="" - if [ -z "$OPT_SAVE_DATA" ]; then + if [ -z "$existing_dir" ]; then mkdir "$TMPDIR/data" || die "Cannot mkdir $TMPDIR/data" data_dir="$TMPDIR/data" else - if [ ! -d "$OPT_SAVE_DATA" ]; then - mkdir "$OPT_SAVE_DATA" || die "Cannot mkdir $OPT_SAVE_DATA" - elif [ "$( ls "$OPT_SAVE_DATA" )" != "0" ]; then + if [ ! -d "$existing_dir" ]; then + mkdir "$existing_dir" || die "Cannot mkdir $existing_dir" + elif [ "$( ls -A "$existing_dir" )" ]; then die "--save-samples directory isn't empty, halting." fi - touch "$OPT_SAVE_DATA/test" || die "Cannot write to $OPT_SAVE_DATA" - rm "$OPT_SAVE_DATA/test" || die "Cannot rm $OPT_SAVE_DATA/test" - data_dir="$OPT_SAVE_DATA" + touch "$existing_dir/test" || die "Cannot write to $existing_dir" + rm "$existing_dir/test" || die "Cannot rm $existing_dir/test" + data_dir="$existing_dir" fi echo "$data_dir" } diff --git a/lib/bash/report_mysql_info.sh b/lib/bash/report_mysql_info.sh index a0aadab1..33f85038 100644 --- a/lib/bash/report_mysql_info.sh +++ b/lib/bash/report_mysql_info.sh @@ -1058,9 +1058,9 @@ report_mysql_summary () { section Instances parse_mysqld_instances "$dir/mysqld-instances" "$dir/mysql-variables" - section MySQL_Executable - name_val "Path to executable" "$( get_var pt-summary-internal-mysql_executable "$dir/mysql-variables" )" - name_val "Has symbols" "$( get_var "pt-summary-internal-symbols" "$dir/mysql-variables" )" + # TODO section MySQL_Executable + # TODO name_val "Path to executable" "$( get_var pt-summary-internal-mysql_executable "$dir/mysql-variables" )" + # TODO name_val "Has symbols" "$( get_var "pt-summary-internal-symbols" "$dir/mysql-variables" )" # ######################################################################## # General date, hostname, etc diff --git a/lib/bash/summary_common.sh b/lib/bash/summary_common.sh index 0df75194..eb7e9805 100644 --- a/lib/bash/summary_common.sh +++ b/lib/bash/summary_common.sh @@ -123,22 +123,22 @@ has_symbols () { } setup_data_dir () { - local OPT_SAVE_DATA="$1" + local existing_dir="$1" local data_dir="" - if [ -z "$OPT_SAVE_DATA" ]; then + if [ -z "$existing_dir" ]; then # User didn't specify a --save-data dir, so use a sub-dir in our tmpdir. mkdir "$TMPDIR/data" || die "Cannot mkdir $TMPDIR/data" data_dir="$TMPDIR/data" else # Check the user's --save-data dir. - if [ ! -d "$OPT_SAVE_DATA" ]; then - mkdir "$OPT_SAVE_DATA" || die "Cannot mkdir $OPT_SAVE_DATA" - elif [ "$( ls "$OPT_SAVE_DATA" )" != "0" ]; then + if [ ! -d "$existing_dir" ]; then + mkdir "$existing_dir" || die "Cannot mkdir $existing_dir" + elif [ "$( ls -A "$existing_dir" )" ]; then die "--save-samples directory isn't empty, halting." fi - touch "$OPT_SAVE_DATA/test" || die "Cannot write to $OPT_SAVE_DATA" - rm "$OPT_SAVE_DATA/test" || die "Cannot rm $OPT_SAVE_DATA/test" - data_dir="$OPT_SAVE_DATA" + touch "$existing_dir/test" || die "Cannot write to $existing_dir" + rm "$existing_dir/test" || die "Cannot rm $existing_dir/test" + data_dir="$existing_dir" fi echo "$data_dir" } diff --git a/t/pt-deadlock-logger/basics.t b/t/pt-deadlock-logger/basics.t index b2fcb432..1ced5546 100644 --- a/t/pt-deadlock-logger/basics.t +++ b/t/pt-deadlock-logger/basics.t @@ -81,7 +81,7 @@ foreach my $child ( keys %children ) { } # Test that there is a deadlock -$output = $dbh1->selectrow_hashref('show innodb status')->{status}; +$output = $dbh1->selectrow_hashref('show /*!40101 engine*/ innodb status')->{status}; like($output, qr/WE ROLL BACK/, 'There was a deadlock'); $output = `$cmd --print`; diff --git a/t/pt-mysql-summary/pt-mysql-summary.t b/t/pt-mysql-summary/pt-mysql-summary.t index 564dca58..c3ba7769 100644 --- a/t/pt-mysql-summary/pt-mysql-summary.t +++ b/t/pt-mysql-summary/pt-mysql-summary.t @@ -25,7 +25,7 @@ local $ENV{PTDEBUG} = ""; my $dir = tempdir( CLEANUP => 1 ); -`$trunk/bin/$tool --sleep 1 --save-samples $dir`; +`$trunk/bin/$tool --sleep 1 --save-samples $dir -- -P12345 -umsandbox -pmsandbox`; ok( -e $dir, @@ -40,7 +40,9 @@ is( "And leaves all files in there" ); -`$trunk/bin/$tool --sleep 1 --save-samples $dir`; +`rm -rf "$dir/"*`; + +`$trunk/bin/$tool --sleep 1 --save-samples $dir -- -P12345 -umsandbox -pmsandbox`; open my $fh, "<", "$dir/mysql-variables" or die "Can't open file: $!"; my $data = do { local $/; <$fh> }; @@ -57,7 +59,7 @@ undef($dir); # --databases # -my $out = `$trunk/bin/$tool --sleep 1 --databases mysql 2>/dev/null`; +my $out = `$trunk/bin/$tool --sleep 1 --databases mysql -- -P12345 -umsandbox -pmsandbox 2>/dev/null`; like( $out, diff --git a/t/pt-mysql-summary/samples/expected_output_temp002.txt b/t/pt-mysql-summary/samples/expected_output_temp002.txt index b3b83ed0..2fe7b801 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp002.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp002.txt @@ -2,9 +2,6 @@ Port Data Directory Nice OOM Socket ===== ========================== ==== === ====== 3306 /var/lib/mysql ? ? /var/run/mysqld/mysqld.sock -# MySQL Executable ########################################### - Path to executable | - Has symbols | Yes # Report On Port 3306 ######################################## User | hugmeir@localhost Time | 2012-03-23 21:05:32 (ART) @@ -177,6 +174,7 @@ Uptime 90000 1 1 Geospatial Types | No Foreign Keys | No Partitioning | No + InnoDB Compression | No SSL | No Explicit LOCK TABLES | No Delayed Insert | No diff --git a/t/pt-mysql-summary/samples/expected_output_temp003.txt b/t/pt-mysql-summary/samples/expected_output_temp003.txt index f8090732..fad40466 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp003.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp003.txt @@ -2,9 +2,6 @@ Port Data Directory Nice OOM Socket ===== ========================== ==== === ====== 12345 /tmp/12345/data 0 0 /tmp/12345/mysql_sandbox12345.sock -# MySQL Executable ########################################### - Path to executable | /home/vagrant/mysql-5.1.49-barebones/bin/mysql - Has symbols | Yes # Report On Port 12345 ####################################### User | msandbox@% Time | 2012-03-27 16:33:46 (BST) diff --git a/t/pt-mysql-summary/samples/expected_output_temp004.txt b/t/pt-mysql-summary/samples/expected_output_temp004.txt index d895c167..f5de6c54 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp004.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp004.txt @@ -2,9 +2,6 @@ Port Data Directory Nice OOM Socket ===== ========================== ==== === ====== 12345 /tmp/12345/data 0 0 /tmp/12345/mysql_sandbox12345.sock -# MySQL Executable ########################################### - Path to executable | /usr/bin/mysql - Has symbols | No # Report On Port 12345 ####################################### User | msandbox@% Time | 2012-03-27 09:16:44 (CEST)