Combine and update some pt-mysql-summary tests to new format. Add is() to test-bash-functions.

This commit is contained in:
Daniel Nichter
2011-08-18 10:17:20 -06:00
parent c6841f60ee
commit 164176c149
14 changed files with 208 additions and 189 deletions

View File

@@ -226,12 +226,14 @@ parse_mysqld_instances () {
# /tmp/percona-toolkit. You have to specify the port for the instance you are
# interested in, in case there are multiple instances.
find_my_cnf_file() {
if test -n "$1" && $AP_GREP -- "/mysqld.*--port=$1" /tmp/percona-toolkit >/dev/null 2>&1 ; then
$AP_GREP -- "/mysqld.*--port=$1" /tmp/percona-toolkit \
local file=$1
local port=$2
if test -n "$port" && $AP_GREP -- "/mysqld.*--port=$port" $file >/dev/null 2>&1 ; then
$AP_GREP -- "/mysqld.*--port=$port" $file \
| $AP_AWK 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }' \
| head -n1
else
$AP_GREP '/mysqld' /tmp/percona-toolkit \
$AP_GREP '/mysqld' $file \
| $AP_AWK 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }' \
| head -n1
fi
@@ -525,37 +527,38 @@ find_max_trx_time() {
# Summarizes various things about InnoDB status that are not easy to see by eye.
format_innodb_status () {
name_val "Checkpoint Age" $(shorten $(find_checkpoint_age "${1}"))
name_val "InnoDB Queue" "$(awk '/queries inside/{print}' "${1}")"
name_val "Oldest Transaction" "$(find_max_trx_time "${1}") Seconds";
name_val "History List Len" $(awk '/History list length/{print $4}' "$1")
name_val "Read Views" $(awk '/read views open inside/{print $1}' "${1}")
name_val "Undo Log Entries" "$(summarize_undo_log_entries "${1}")"
name_val "Pending I/O Reads" "$(find_pending_io_reads "${1}")"
name_val "Pending I/O Writes" "$(find_pending_io_writes "${1}")"
name_val "Pending I/O Flushes" "$(find_pending_io_flushes "${1}")"
$AP_AWK -F, '/^---TRANSACTION/{print $2}' "${1}" \
local file=$1
name_val "Checkpoint Age" $(shorten $(find_checkpoint_age "${file}"))
name_val "InnoDB Queue" "$(awk '/queries inside/{print}' "${file}")"
name_val "Oldest Transaction" "$(find_max_trx_time "${file}") Seconds";
name_val "History List Len" $(awk '/History list length/{print $4}' "${file}")
name_val "Read Views" $(awk '/read views open inside/{print $1}' "${file}")
name_val "Undo Log Entries" "$(summarize_undo_log_entries "${file}")"
name_val "Pending I/O Reads" "$(find_pending_io_reads "${file}")"
name_val "Pending I/O Writes" "$(find_pending_io_writes "${file}")"
name_val "Pending I/O Flushes" "$(find_pending_io_flushes "${file}")"
$AP_AWK -F, '/^---TRANSACTION/{print $2}' "${file}" \
| $AP_SED -e 's/ [0-9]* sec.*//' | sort | uniq -c > /tmp/percona-toolkit2
name_val "Transaction States" "$(group_concat /tmp/percona-toolkit2)"
if $AP_GREP 'TABLE LOCK table' "${1}" >/dev/null ; then
if $AP_GREP 'TABLE LOCK table' "${file}" >/dev/null ; then
echo "Tables Locked"
$AP_AWK '/^TABLE LOCK table/{print $4}' "${1}" \
$AP_AWK '/^TABLE LOCK table/{print $4}' "${file}" \
| sort | uniq -c | sort -rn
fi
if $AP_GREP 'has waited at' "${1}" > /dev/null ; then
if $AP_GREP 'has waited at' "${file}" > /dev/null ; then
echo "Semaphore Waits"
$AP_GREP 'has waited at' "${1}" | cut -d' ' -f6-8 \
$AP_GREP 'has waited at' "${file}" | cut -d' ' -f6-8 \
| sort | uniq -c | sort -rn
fi
if $AP_GREP 'reserved it in mode' "${1}" > /dev/null; then
if $AP_GREP 'reserved it in mode' "${file}" > /dev/null; then
echo "Semaphore Holders"
$AP_AWK '/has reserved it in mode/{
print substr($0, 1 + index($0, "("), index($0, ")") - index($0, "(") - 1);
}' "${1}" | sort | uniq -c | sort -rn
}' "${file}" | sort | uniq -c | sort -rn
fi
if $AP_GREP -e 'Mutex at' -e 'lock on' "${1}" >/dev/null 2>&1; then
if $AP_GREP -e 'Mutex at' -e 'lock on' "${file}" >/dev/null 2>&1; then
echo "Mutexes/Locks Waited For"
$AP_GREP -e 'Mutex at' -e 'lock on' "${1}" | $AP_SED -e 's/^[XS]-//' -e 's/,.*$//' \
$AP_GREP -e 'Mutex at' -e 'lock on' "${file}" | $AP_SED -e 's/^[XS]-//' -e 's/,.*$//' \
| sort | uniq -c | sort -rn
fi
}
@@ -1243,7 +1246,7 @@ main() {
# ########################################################################
section Configuration_File
ps auxww 2>/dev/null | $AP_GREP mysqld > /tmp/percona-toolkit
cnf_file=$(find_my_cnf_file ${port});
cnf_file=$(find_my_cnf_file /tmp/percona-toolkit ${port});
if [ ! -e "${cnf_file}" ]; then
name_val "Config File" "Cannot autodetect, trying common locations"
cnf_file="/etc/my.cnf";

View File

@@ -1,6 +0,0 @@
#!/bin/bash
#find_my_cnf_file 12346
echo /tmp/12346/my.sandbox.cnf > $1
cp samples/ps-mysqld-001.txt /tmp/percona-toolkit

View File

@@ -1,6 +0,0 @@
#!/bin/bash
#find_my_cnf_file 12345
echo /var/lib/mysql/my.cnf > $1
cp samples/ps-mysqld-004.txt /tmp/percona-toolkit

View File

@@ -1,6 +0,0 @@
#!/bin/bash
#find_my_cnf_file
echo /var/lib/mysql/my.cnf > $1
cp samples/ps-mysqld-004.txt /tmp/percona-toolkit

View File

@@ -1,6 +0,0 @@
#!/bin/bash
#find_my_cnf_file
echo /tmp/12345/my.sandbox.cnf > $1
cp samples/ps-mysqld-001.txt /tmp/percona-toolkit

View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
TESTS=4
TEST_NAME="ps-mysqld-001.txt"
res=$(find_my_cnf_file samples/ps-mysqld-001.txt)
is "$res" "/tmp/12345/my.sandbox.cnf"
TEST_NAME="ps-mysqld-001.txt with port"
res=$(find_my_cnf_file samples/ps-mysqld-001.txt 12346)
is "$res" "/tmp/12346/my.sandbox.cnf"
TEST_NAME="ps-mysqld-004.txt"
res=$(find_my_cnf_file samples/ps-mysqld-004.txt)
is "$res" "/var/lib/mysql/my.cnf"
TEST_NAME="ps-mysqld-004.txt with port"
res=$(find_my_cnf_file samples/ps-mysqld-004.txt 12345)
is "$res" "/var/lib/mysql/my.cnf"

View File

@@ -1,52 +0,0 @@
#!/bin/bash
#format_innodb_status /tmp/percona-toolkit-innodb-status
cat <<EOF > $1
Checkpoint Age | 619k
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 3 Seconds
History List Len | 255
Read Views | 23
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
Pending I/O Reads | 14 buf pool reads, 6 normal AIO, 0 ibuf AIO, 23 preads
Pending I/O Writes | 63 buf pool (63 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (1 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 1 log
Transaction States | 1xACTIVE
Semaphore Waits
69 btr/btr0cur.c line 457
47 btr/btr0cur.c line 523
17 trx/trx0trx.c line 1621
12 row/row0sel.c line 3549
4 lock/lock0lock.c line 4944
3 lock/lock0lock.c line 5316
2 lock/lock0lock.c line 3224
2 btr/btr0sea.c line 1032
1 trx/trx0trx.c line 738
1 row/row0sel.c line 4574
1 lock/lock0lock.c line 5163
1 lock/lock0lock.c line 3249
1 ./include/btr0btr.ic line 53
1 fsp/fsp0fsp.c line 3395
1 btr/btr0cur.c line 672
1 btr/btr0cur.c line 450
Semaphore Holders
66 thread id 139960165583184
45 thread id 139960567171408
4 thread id 139960404199760
1 thread id 139961215367504
1 thread id 139960969292112
1 thread id 139960676096336
Mutexes/Locks Waited For
65 lock on RW-latch at 0x905d33d0 '&new_index->lock'
45 lock on RW-latch at 0x7f4bedbf8810 '&block->lock'
30 Mutex at 0xf89ab0 '&kernel_mutex'
15 lock on RW-latch at 0x90075530 '&btr_search_latch'
4 lock on RW-latch at 0x90a42ca0 '&new_index->lock'
1 lock on RW-latch at 0x90fe1c80 '&new_index->lock'
1 lock on RW-latch at 0x90078f10 '&space->latch'
1 lock on RW-latch at 0x7f4c0d3abba8 '&block->lock'
1 lock on RW-latch at 0x7f4bfc558040 '&block->lock'
1 lock on RW-latch at 0x7f4bd0a8c8d0 '&block->lock'
EOF
cp samples/innodb-status.001.txt /tmp/percona-toolkit-innodb-status

View File

@@ -1,35 +0,0 @@
#!/bin/bash
#format_innodb_status /tmp/percona-toolkit-innodb-status
cat <<'EOF' > $1
Checkpoint Age | 348M
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 4 Seconds
History List Len | 426
Read Views | 583
Undo Log Entries | 71 transactions, 247 total undo, 46 max undo
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 0 log
Transaction States | 1xACTIVE, 70xACTIVE (PREPARED)
Tables Locked
62 `citydb`.`player_buildings`
46 `citydb`.`players`
22 `citydb`.`city_grid`
17 `citydb`.`player_stats`
6 `citydb`.`player_contracts`
1 `citydb`.`player_achievements`
Semaphore Waits
23 trx/trx0undo.c line 1796
10 trx/trx0trx.c line 1888
8 trx/trx0trx.c line 1033
7 trx/trx0trx.c line 738
1 lock/lock0lock.c line 3770
1 ./include/log0log.ic line 322
Mutexes/Locks Waited For
33 Mutex at 0x2abf68b76a18 '&rseg->mutex'
16 Mutex at 0x48ace40 '&kernel_mutex'
1 Mutex at 0x2abf68b6c0d0 '&log_sys->mutex'
EOF
cp samples/innodb-status.002.txt /tmp/percona-toolkit-innodb-status

View File

@@ -1,19 +0,0 @@
#!/bin/bash
#format_innodb_status /tmp/percona-toolkit-innodb-status
cat <<'EOF' > $1
Checkpoint Age | 0k
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 35 Seconds
History List Len | 11
Read Views | 1
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 0 log
Transaction States | 1xACTIVE, 1xnot started
Tables Locked
1 `test`.`t`
EOF
cp samples/innodb-status.003.txt /tmp/percona-toolkit-innodb-status

View File

@@ -1,29 +0,0 @@
#!/bin/bash
#format_innodb_status /tmp/percona-toolkit-innodb-status
cat <<'EOF' > $1
Checkpoint Age | 93M
InnoDB Queue | 9 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 263 Seconds
History List Len | 1282
Read Views | 10
Undo Log Entries | 3 transactions, 276797 total undo, 153341 max undo
Pending I/O Reads | 50 buf pool reads, 48 normal AIO, 0 ibuf AIO, 2 preads
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 0 log
Transaction States | 9xACTIVE, 57xnot started
Semaphore Waits
3 row/row0sel.c line 3495
2 btr/btr0sea.c line 1024
1 btr/btr0sea.c line 1170
1 btr/btr0cur.c line 443
1 btr/btr0cur.c line 1501
Semaphore Holders
7 thread id 1220999488
1 thread id 1229429056
Mutexes/Locks Waited For
7 lock on RW-latch at 0x2aaab42120b8 created in file btr/btr0sea.c line 139
1 lock on RW-latch at 0x2ab2c679a550 created in file buf/buf0buf.c line 550
EOF
cp samples/innodb-status.004.txt /tmp/percona-toolkit-innodb-status

View File

@@ -0,0 +1,146 @@
#!/usr/bin/env bash
TESTS=4
# ############################################################################
TEST_NAME="innodb-status.001.txt"
# ############################################################################
cat <<EOF > $TMPDIR/expected
Checkpoint Age | 619k
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 3 Seconds
History List Len | 255
Read Views | 23
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
Pending I/O Reads | 14 buf pool reads, 6 normal AIO, 0 ibuf AIO, 23 preads
Pending I/O Writes | 63 buf pool (63 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (1 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 1 log
Transaction States | 1xACTIVE
Semaphore Waits
69 btr/btr0cur.c line 457
47 btr/btr0cur.c line 523
17 trx/trx0trx.c line 1621
12 row/row0sel.c line 3549
4 lock/lock0lock.c line 4944
3 lock/lock0lock.c line 5316
2 lock/lock0lock.c line 3224
2 btr/btr0sea.c line 1032
1 trx/trx0trx.c line 738
1 row/row0sel.c line 4574
1 lock/lock0lock.c line 5163
1 lock/lock0lock.c line 3249
1 ./include/btr0btr.ic line 53
1 fsp/fsp0fsp.c line 3395
1 btr/btr0cur.c line 672
1 btr/btr0cur.c line 450
Semaphore Holders
66 thread id 139960165583184
45 thread id 139960567171408
4 thread id 139960404199760
1 thread id 139961215367504
1 thread id 139960969292112
1 thread id 139960676096336
Mutexes/Locks Waited For
65 lock on RW-latch at 0x905d33d0 '&new_index->lock'
45 lock on RW-latch at 0x7f4bedbf8810 '&block->lock'
30 Mutex at 0xf89ab0 '&kernel_mutex'
15 lock on RW-latch at 0x90075530 '&btr_search_latch'
4 lock on RW-latch at 0x90a42ca0 '&new_index->lock'
1 lock on RW-latch at 0x90fe1c80 '&new_index->lock'
1 lock on RW-latch at 0x90078f10 '&space->latch'
1 lock on RW-latch at 0x7f4c0d3abba8 '&block->lock'
1 lock on RW-latch at 0x7f4bfc558040 '&block->lock'
1 lock on RW-latch at 0x7f4bd0a8c8d0 '&block->lock'
EOF
format_innodb_status samples/innodb-status.001.txt > $TMPDIR/got
no_diff $TMPDIR/got $TMPDIR/expected
# ############################################################################
TEST_NAME="innodb-status.002.txt"
# ############################################################################
cat <<'EOF' > $TMPDIR/expected
Checkpoint Age | 348M
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 4 Seconds
History List Len | 426
Read Views | 583
Undo Log Entries | 71 transactions, 247 total undo, 46 max undo
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 0 log
Transaction States | 1xACTIVE, 70xACTIVE (PREPARED)
Tables Locked
62 `citydb`.`player_buildings`
46 `citydb`.`players`
22 `citydb`.`city_grid`
17 `citydb`.`player_stats`
6 `citydb`.`player_contracts`
1 `citydb`.`player_achievements`
Semaphore Waits
23 trx/trx0undo.c line 1796
10 trx/trx0trx.c line 1888
8 trx/trx0trx.c line 1033
7 trx/trx0trx.c line 738
1 lock/lock0lock.c line 3770
1 ./include/log0log.ic line 322
Mutexes/Locks Waited For
33 Mutex at 0x2abf68b76a18 '&rseg->mutex'
16 Mutex at 0x48ace40 '&kernel_mutex'
1 Mutex at 0x2abf68b6c0d0 '&log_sys->mutex'
EOF
format_innodb_status samples/innodb-status.002.txt > $TMPDIR/got
no_diff $TMPDIR/got $TMPDIR/expected
# ############################################################################
TEST_NAME="innodb-status.003.txt"
# ############################################################################
cat <<'EOF' > $TMPDIR/expected
Checkpoint Age | 0k
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 35 Seconds
History List Len | 11
Read Views | 1
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 0 log
Transaction States | 1xACTIVE, 1xnot started
Tables Locked
1 `test`.`t`
EOF
format_innodb_status samples/innodb-status.003.txt > $TMPDIR/got
no_diff $TMPDIR/got $TMPDIR/expected
# ############################################################################
TEST_NAME="innodb-status.004.txt"
# ############################################################################
cat <<'EOF' > $TMPDIR/expected
Checkpoint Age | 93M
InnoDB Queue | 9 queries inside InnoDB, 0 queries in queue
Oldest Transaction | 263 Seconds
History List Len | 1282
Read Views | 10
Undo Log Entries | 3 transactions, 276797 total undo, 153341 max undo
Pending I/O Reads | 50 buf pool reads, 48 normal AIO, 0 ibuf AIO, 2 preads
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
Pending I/O Flushes | 0 buf pool, 0 log
Transaction States | 9xACTIVE, 57xnot started
Semaphore Waits
3 row/row0sel.c line 3495
2 btr/btr0sea.c line 1024
1 btr/btr0sea.c line 1170
1 btr/btr0cur.c line 443
1 btr/btr0cur.c line 1501
Semaphore Holders
7 thread id 1220999488
1 thread id 1229429056
Mutexes/Locks Waited For
7 lock on RW-latch at 0x2aaab42120b8 created in file btr/btr0sea.c line 139
1 lock on RW-latch at 0x2ab2c679a550 created in file buf/buf0buf.c line 550
EOF
format_innodb_status samples/innodb-status.004.txt > $TMPDIR/got
no_diff $TMPDIR/got $TMPDIR/expected

View File

@@ -1,6 +0,0 @@
#!/bin/bash
#fuzz 49
cat <<EOF > $1
50
EOF

View File

@@ -0,0 +1,6 @@
#!/bin/bash
TESTS=1
TEST_NAME="fuzz 49"
is $(fuzz 49) "50"

View File

@@ -98,7 +98,9 @@ result() {
echo "not ok $testno - $TEST_FILE $test_name"
failed_tests=$(( failed_tests + 1))
echo "# Failed '$test_command'" >&2
cat $TMPDIR/failed_result | sed -e 's/^/# /' -e '30q' >&2
if [ -f $TMPDIR/failed_result ]; then
cat $TMPDIR/failed_result | sed -e 's/^/# /' -e '30q' >&2
fi
fi
testno=$((testno + 1))
TEST_NUMBER=$((TEST_NUMBER + 1))
@@ -112,11 +114,19 @@ result() {
no_diff() {
local got=$1
local expected=$2
local test_command="diff $got $expected"
test_command="diff $got $expected"
eval $test_command > $TMPDIR/failed_result 2>&1
result $?
}
is() {
local got=$1
local expected=$2
test_command="\"$got\" == \"$expected\""
test "$got" = "$expected"
result $?
}
# ############################################################################
# Script starts here
# ############################################################################