(temp commit, syncing up)

This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-03-20 11:21:16 -03:00
parent 3cfb1c0af7
commit 31afeb73b5
14 changed files with 3624 additions and 852 deletions

View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
plan 3
TMPDIR="$TEST_TMPDIR"
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
TOOL="pt-mysql-summary"
. "$LIB_DIR/log_warn_die.sh"
. "$LIB_DIR/alt_cmds.sh"
. "$LIB_DIR/summary_common.sh"
. "$LIB_DIR/collect_mysql_info.sh"
# Prefix (with path) for the collect files.
local p="$TMPDIR/collect_mysql_info"
mkdir "$p"
parse_options "$BIN_DIR/pt-mysql-summary" --sleep 1 -- --defaults-file=/tmp/12345/my.sandbox.cnf
CMD_MYSQL="$(_which mysql)"
CMD_MYSQLDUMP="$(_which mysqldump)"
collect_mysql_info "$p" 1>/dev/null
wait
file_count=$(ls "$p" | wc -l)
is $file_count 12 "Creates the correct number of files (without --dump-schemas)"
grep -v grep "$p/percona-toolkit-mysqld-instances" | awk '{print $2}' > "$TMPDIR/collect_mysqld_instances1.test"
ps auxww 2>/dev/null | grep mysqld | grep -v grep | awk '{print $2}' > "$TMPDIR/collect_mysqld_instances2.test"
no_diff \
"$TMPDIR/collect_mysqld_instances1.test" \
"$TMPDIR/collect_mysqld_instances2.test" \
"collect_mysql_info() finds the correct instances"
collect_mysqld_instances "$TMPDIR/collect_mysqld_instances3.test"
no_diff \
"$TMPDIR/collect_mysqld_instances3.test" \
"$TMPDIR/collect_mysqld_instances2.test" \
"(sanity check) which are the same that collect_mysqld_instances() does"
$CMD_MYSQL $EXT_ARGV -ss -e 'SHOW /*!50000 GLOBAL*/ STATUS' > "$TMPDIR/collect_mysql_status"
no_diff \
"$p/percona-toolkit-mysql-status" \
"$TMPDIR/collect_mysql_status" \
"collect_mysql_info() finds the correct instances"

View File

@@ -0,0 +1,90 @@
#!/usr/bin/env bash
plan 12
. "$LIB_DIR/report_formatting.sh"
is \
"$(shorten 10485760 1)" \
"10.0M" \
"10485760, 1 precision, default divisor => 10.0M"
is \
"$(shorten 3145728000 1)" \
"2.9G" \
"10485760, 1 precision, default divisor => 2.9G"
is \
"$(shorten 3145728000 1 1000)" \
"3.0G" \
"Opt-in to the 2.1 behavior works"
is \
"$(shorten 0 0)" \
"0" \
"0, 0 precision, default divisor => 0"
is \
"$(shorten 1572864000 1)" \
"1.5G" \
"1572864000, 1 precision, default divisor => 1.5G"
is \
"$(shorten 1572864000 1 1000)" \
"1.5G" \
"1572864000, 1 precision, divisor 1000 => 1.5G"
is \
"$(shorten 364 0)" \
"364" \
"364, 0 precision, default divisor => 364"
is \
"$(shorten 364 1)" \
"364.0" \
"364, 1 precision, default divisor => 364"
is \
"$(shorten 649216 1)" \
"634.0k" \
"649216, 1 precision, default divisor => 634.0k"
is \
"$(shorten 6492100000006 1)" \
"5.9T" \
"6492100000006, 1 precision, default divisor => 5.9T"
is \
"$(shorten 6492100000006 1 1000)" \
"6.5T" \
"6492100000006, 1 precision, divisor 1000 => 6.5T"
# section
is \
"$(section "A")" \
"# A ##########################################################" \
"Sanity check, section works"
is \
"$(section "A B C")" \
"# A#B#C ######################################################" \
"section replaces all spaces with #s"
is \
"$(section "A_B_C")" \
"# A B C ######################################################" \
"..and all underscores with spaces"
# name_val
NAME_VAL_LEN=0
is \
"$(name_val "A" "B")" \
"A | B" \
"name_val and NAME_VAL_LEN work"
# ###########################################################################
# Done
# ###########################################################################