mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
Test collect.sh. Use --run-time instead of --interval for collect loop. Fix and require per-test test names in util/test-bash-functions. Fix OPT_ERR in parse_options.sh.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TESTS=24
|
||||
TESTS=19
|
||||
|
||||
TMPFILE="$TEST_TMPDIR/parse-opts-output"
|
||||
TMPDIR="$TEST_TMPDIR"
|
||||
@@ -14,11 +14,105 @@ source "$LIB_DIR/safeguards.sh"
|
||||
source "$LIB_DIR/alt_cmds.sh"
|
||||
source "$LIB_DIR/collect.sh"
|
||||
|
||||
parse_options "$T_LIB_DIR/samples/bash/po002.sh" -- --defaults-file=/tmp/12345/my.sandbox.cnf
|
||||
parse_options "$T_LIB_DIR/samples/bash/po002.sh" --run-time 1 -- --defaults-file=/tmp/12345/my.sandbox.cnf
|
||||
|
||||
collect "$TMPDIR/collect" "2011_12_05"
|
||||
# Prefix (with path) for the collect files.
|
||||
local p="$TMPDIR/collect/2011_12_05"
|
||||
|
||||
# Default collect, no extras like gdb, tcpdump, etc.
|
||||
collect "$TMPDIR/collect" "2011_12_05" > $p-output 2>&1
|
||||
|
||||
# Even if this system doesn't have all the cmds, collect should still
|
||||
# create all the default files.
|
||||
ls -1 $TMPDIR/collect | sort > $TMPDIR/collect-files
|
||||
no_diff \
|
||||
$TMPDIR/collect-files \
|
||||
$T_LIB_DIR/samples/bash/collect001.txt \
|
||||
"Default collect files"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'Avail' $p-df" \
|
||||
"df"
|
||||
|
||||
# hostname is the last thing collected, so if it's ok,
|
||||
# then the sub reached its end.
|
||||
is \
|
||||
"`cat $p-hostname`" \
|
||||
"`hostname`" \
|
||||
"hostname"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q -i 'buffer pool' $p-innodbstatus1" \
|
||||
"innodbstatus1"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q -i 'buffer pool' $p-innodbstatus2" \
|
||||
"innodbstatus2"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'error log seems to be /tmp/12345/data/mysqld.log' $p-output" \
|
||||
"Finds MySQL error log"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'Status information:' $p-log_error" \
|
||||
"debug"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'COMMAND[ ]\+PID[ ]\+USER' $p-lsof" \
|
||||
"lsof"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'buf/buf0buf.c' $p-mutex-status1" \
|
||||
"mutex-status1"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'buf/buf0buf.c' $p-mutex-status2" \
|
||||
"mutex-status2"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q '^| Uptime' $p-mysqladmin" \
|
||||
"mysqladmin ext"
|
||||
|
||||
cmd_ok \
|
||||
"grep -qP 'Database\tTable\tIn_use' $p-opentables1" \
|
||||
"opentables1"
|
||||
|
||||
cmd_ok \
|
||||
"grep -qP 'Database\tTable\t\In_use' $p-opentables2" \
|
||||
"opentables2"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q '1. row' $p-processlist1" \
|
||||
"processlist1"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q '1. row' $p-processlist2" \
|
||||
"processlist2"
|
||||
|
||||
cmd_ok \
|
||||
"grep -q 'mysqld' $p-ps" \
|
||||
"ps"
|
||||
|
||||
cmd_ok \
|
||||
"grep -qP '^warning_count\t\d' $p-variables" \
|
||||
"variables"
|
||||
|
||||
local iters=$(cat $p-df | grep -c '^TS ')
|
||||
is "$iters" "1" "1 iteration/1s run time"
|
||||
|
||||
# ###########################################################################
|
||||
# Try longer run time.
|
||||
# ###########################################################################
|
||||
|
||||
parse_options "$T_LIB_DIR/samples/bash/po002.sh" --run-time 2 -- --defaults-file=/tmp/12345/my.sandbox.cnf
|
||||
|
||||
rm $TMPDIR/collect/*
|
||||
|
||||
collect "$TMPDIR/collect" "2011_12_05" > $p-output 2>&1
|
||||
|
||||
local iters=$(cat $p-df | grep -c '^TS ')
|
||||
is "$iters" "2" "2 iteration/2s run time"
|
||||
|
||||
# ############################################################################
|
||||
# Done
|
||||
# ############################################################################
|
||||
exit
|
||||
|
Reference in New Issue
Block a user