Conditionalize the number of files expected: 14 or 15 depending on if the box has a default my.cnf somewhere.

This commit is contained in:
Daniel Nichter
2012-10-24 13:03:45 -06:00
parent 70b666add9
commit 9b920bc5a5
2 changed files with 26 additions and 18 deletions

View File

@@ -18,6 +18,19 @@ samples="$PERCONA_TOOLKIT_BRANCH/t/pt-mysql-summary/samples"
mkdir "$p"
# This is mostly for the find_my_cnf_file tests.
# Test machines may have one of these, and find_my_cnf_file will use
# the same if the specific port-based cnf file isn't found.
if [ -e "/etc/my.cnf" ]; then
sys_cnf_file="/etc/my.cnf"
elif [ -e "/etc/mysql/my.cnf" ]; then
sys_cnf_file="/etc/mysql/my.cnf"
elif [ -e "/var/db/mysql/my.cnf" ]; then
sys_cnf_file="/var/db/mysql/my.cnf";
else
sys_cnf_file=""
fi
parse_options "$BIN_DIR/pt-mysql-summary" --sleep 1 -- --defaults-file=/tmp/12345/my.sandbox.cnf
CMD_MYSQL="$(_which mysql)"
@@ -28,7 +41,13 @@ wait
file_count=$(ls "$p" | wc -l)
is $file_count 13 "Creates the correct number of files (without --databases)"
if [ "$sys_cnf_file" ]; then
n_files=14
else
n_files=13
fi
is $file_count $n_files "Creates the correct number of files (without --databases)"
awk '{print $1}' "$p/mysqld-instances" > "$PT_TMPDIR/collect_mysqld_instances1.test"
pids="$(_pidof mysqld)"
@@ -80,18 +99,6 @@ is \
# find_my_cnf_file
# Test machines may have one of these, and find_my_cnf_file will use
# the same if the specific port-based cnf file isn't found.
if [ -e "/etc/my.cnf" ]; then
sys_cnf_file="/etc/my.cnf"
elif [ -e "/etc/mysql/my.cnf" ]; then
sys_cnf_file="/etc/mysql/my.cnf"
elif [ -e "/var/db/mysql/my.cnf" ]; then
sys_cnf_file="/var/db/mysql/my.cnf";
else
sys_cnf_file=""
fi
# We know the port is 12345 (2nd to last test), but the sandbox is started
# with just --defaults-file, no --port, so find_my_cnf_file isn't going to
# be able to get the specific cnf file.

View File

@@ -32,13 +32,14 @@ ok(
"Using --save-samples doesn't mistakenly delete the target dir"
);
# If the box has a default my.cnf (e.g. /etc/my.cnf) there
# should be 15 files, else 14.
my @files = glob("$dir/*");
is(
scalar @files,
14,
my $n_files = scalar @files;
ok(
$n_files == 15 || $n_files == 14,
"And leaves all files in there"
);
) or diag($n_files, `ls -l $dir`);
undef($dir);