Rewrite find_my_cnf_file() so if a port is given only that port's cnf is returned, else nothing.

This commit is contained in:
Daniel Nichter
2012-10-24 11:17:34 -06:00
parent 15a2cf6c50
commit aacdd9db17
4 changed files with 63 additions and 35 deletions

View File

@@ -79,26 +79,50 @@ is \
"collect_internal_vars works"
# find_my_cnf_file
# 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, and the test machine shouldn't have
# any of the default files (/etc/my.cnf, etc.).
cnf_file=$(find_my_cnf_file "$p/mysqld-instances" ${port});
is \
"$cnf_file" \
"/tmp/12345/my.sandbox.cnf" \
"find_my_cnf_file gets the correct file"
is "$cnf_file" "" "find_my_cnf_file gets the correct file"
[ $? -ne 0 ] && diag "$p/mysqld-instances"
# ps-mysqld-001.txt has several instances:
# port 3306 cnf -
# port 12345 cnf /tmp/12345/my.sandbox.cnf
# port 12346 cnf /tmp/12346/my.sandbox.cnf
res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt")
is "$res" "/tmp/12345/my.sandbox.cnf" "ps-mysqld-001.txt"
is "$res" "" "ps-mysqld-001.txt no port"
res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt" 3306)
is "$res" "" "ps-mysqld-001.txt port but no cnf"
res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt" 999)
is "$res" "" "ps-mysqld-001.txt nonexistent port"
res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt" 12346)
is "$res" "/tmp/12346/my.sandbox.cnf" "ps-mysqld-001.txt with port"
is "$res" "/tmp/12346/my.sandbox.cnf" "ps-mysqld-001.txt port 12346"
res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt" 12345)
is "$res" "/tmp/12345/my.sandbox.cnf" "ps-mysqld-001.txt port 12345"
# ps-mysqld-004.txt has 1 instance without --port using
# --defaults-file=/var/lib/mysql/my.cnf
res=$(find_my_cnf_file "$samples/ps-mysqld-004.txt")
is "$res" "/var/lib/mysql/my.cnf" "ps-mysqld-004.txt"
is "$res" "/var/lib/mysql/my.cnf" "ps-mysqld-004.txt no port"
res=$(find_my_cnf_file "$samples/ps-mysqld-004.txt" 12345)
is "$res" "/var/lib/mysql/my.cnf" "ps-mysqld-004.txt with port"
is "$res" "" "ps-mysqld-004.txt port 12345"
# ps-mysqld-005.txt has the 3 sandbox instances, but 12347
# is first, which was causing bug 1070916.
res=$(find_my_cnf_file "$samples/ps-mysqld-005.txt" 12345)
is "$res" "" "ps-mysqld-005.txt port 12345 (bug 1070916)"
# collect_mysql_databases
$CMD_MYSQL $EXT_ARGV -ss -e 'SHOW DATABASES' > "$PT_TMPDIR/mysql_collect_databases" 2>/dev/null