~percona-toolkit-dev/percona-toolkit/2.0

« back to all changes in this revision

Viewing changes to t/lib/bash/collect.sh

  • Committer: Daniel Nichter
  • Date: 2011-12-27 22:37:09 UTC
  • mfrom: (109.2.27 bash-tool-libs)
  • Revision ID: daniel@percona.com-20111227223709-v227ijlpw51qxl5z
MergeĀ lp:~daniel-nichter/percona-toolkit/bash-tool-libs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env bash
 
2
 
 
3
TESTS=18
 
4
 
 
5
TMPFILE="$TEST_TMPDIR/parse-opts-output"
 
6
TMPDIR="$TEST_TMPDIR"
 
7
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
 
8
 
 
9
mkdir "$TMPDIR/collect" 2>/dev/null
 
10
 
 
11
source "$LIB_DIR/log_warn_die.sh"
 
12
source "$LIB_DIR/parse_options.sh"
 
13
source "$LIB_DIR/safeguards.sh"
 
14
source "$LIB_DIR/alt_cmds.sh"
 
15
source "$LIB_DIR/collect.sh"
 
16
 
 
17
parse_options "$T_LIB_DIR/samples/bash/po002.sh" --run-time 1 -- --defaults-file=/tmp/12345/my.sandbox.cnf
 
18
 
 
19
# Prefix (with path) for the collect files.
 
20
local p="$TMPDIR/collect/2011_12_05"
 
21
 
 
22
# Default collect, no extras like gdb, tcpdump, etc.
 
23
collect "$TMPDIR/collect" "2011_12_05" > $p-output 2>&1
 
24
 
 
25
# Even if this system doesn't have all the cmds, collect should still
 
26
# create all the default files.
 
27
ls -1 $TMPDIR/collect | sort > $TMPDIR/collect-files
 
28
no_diff \
 
29
   $TMPDIR/collect-files \
 
30
   $T_LIB_DIR/samples/bash/collect001.txt \
 
31
   "Default collect files"
 
32
 
 
33
cmd_ok \
 
34
   "grep -q 'Avail' $p-df" \
 
35
   "df"
 
36
 
 
37
# hostname is the last thing collected, so if it's ok,
 
38
# then the sub reached its end.
 
39
is \
 
40
   "`cat $p-hostname`" \
 
41
   "`hostname`" \
 
42
   "hostname"
 
43
 
 
44
cmd_ok \
 
45
   "grep -q -i 'buffer pool' $p-innodbstatus1" \
 
46
   "innodbstatus1"
 
47
 
 
48
cmd_ok \
 
49
   "grep -q -i 'buffer pool' $p-innodbstatus2" \
 
50
   "innodbstatus2"
 
51
 
 
52
cmd_ok \
 
53
   "grep -q 'error log seems to be /tmp/12345/data/mysqld.log' $p-output" \
 
54
   "Finds MySQL error log"
 
55
 
 
56
cmd_ok \
 
57
   "grep -q 'Status information:' $p-log_error" \
 
58
   "debug"
 
59
 
 
60
cmd_ok \
 
61
   "grep -q 'COMMAND[ ]\+PID[ ]\+USER' $p-lsof" \
 
62
   "lsof"
 
63
 
 
64
cmd_ok \
 
65
   "grep -q 'buf0buf.c' $p-mutex-status1" \
 
66
   "mutex-status1"
 
67
 
 
68
cmd_ok \
 
69
   "grep -q 'buf0buf.c' $p-mutex-status2" \
 
70
   "mutex-status2"
 
71
 
 
72
cmd_ok \
 
73
   "grep -q '^| Uptime' $p-mysqladmin" \
 
74
   "mysqladmin ext"
 
75
 
 
76
cmd_ok \
 
77
   "grep -qP 'Database\tTable\tIn_use' $p-opentables1" \
 
78
   "opentables1"
 
79
 
 
80
cmd_ok \
 
81
   "grep -qP 'Database\tTable\t\In_use' $p-opentables2" \
 
82
   "opentables2"
 
83
 
 
84
cmd_ok \
 
85
   "grep -q '1. row' $p-processlist" \
 
86
   "processlist"
 
87
 
 
88
cmd_ok \
 
89
   "grep -q 'mysqld' $p-ps" \
 
90
   "ps"
 
91
 
 
92
cmd_ok \
 
93
   "grep -qP '^wait_timeout\t\d' $p-variables" \
 
94
   "variables"
 
95
 
 
96
local iters=$(cat $p-df | grep -c '^TS ')
 
97
is "$iters" "1" "1 iteration/1s run time"
 
98
 
 
99
# ###########################################################################
 
100
# Try longer run time.
 
101
# ###########################################################################
 
102
 
 
103
parse_options "$T_LIB_DIR/samples/bash/po002.sh" --run-time 2 -- --defaults-file=/tmp/12345/my.sandbox.cnf
 
104
 
 
105
rm $TMPDIR/collect/*
 
106
 
 
107
collect "$TMPDIR/collect" "2011_12_05" > $p-output 2>&1
 
108
 
 
109
local iters=$(cat $p-df | grep -c '^TS ')
 
110
is "$iters" "2" "2 iteration/2s run time"
 
111
 
 
112
# ############################################################################
 
113
# Done
 
114
# ############################################################################