~percona-toolkit-dev/percona-toolkit/pt-table-sync-binlog-format-only-if-not-statement

« back to all changes in this revision

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

MergeĀ lp:~percona-toolkit-dev/percona-toolkit/fix-945079-tmpdir-should-use-TEMP

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
plan 40
4
4
 
5
 
TMPDIR="$TEST_TMPDIR"
 
5
PT_TMPDIR="$TEST_PT_TMPDIR"
6
6
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
7
7
TOOL="pt-summary"
8
8
 
14
14
. "$LIB_DIR/collect_system_info.sh"
15
15
 
16
16
# Prefix (with path) for the collect files.
17
 
p="$TMPDIR/collect_mysql_info"
 
17
p="$PT_TMPDIR/collect_mysql_info"
18
18
samples="$PERCONA_TOOLKIT_BRANCH/t/pt-summary/samples"
19
19
 
20
20
mkdir "$p"
25
25
 
26
26
collect_system_data "$p"
27
27
 
28
 
p2="$TMPDIR/collect_mysql_info2"
 
28
p2="$PT_TMPDIR/collect_mysql_info2"
29
29
mkdir "$p2"
30
30
touch "$p2/some_empty_file"
31
31
collect_system_data "$p2"
32
32
 
33
33
cmd_ok "test ! -e \"$p2/some_empty_file\"" "collect_system_data removes empty files before exiting"
34
34
 
35
 
cat <<EOF > "$TMPDIR/expected"
 
35
cat <<EOF > "$PT_TMPDIR/expected"
36
36
Fusion-MPT SAS
37
37
EOF
38
 
find_raid_controller_lspci "$samples/lspci-001.txt" > "$TMPDIR/got"
39
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "lspci-001.txt"
 
38
find_raid_controller_lspci "$samples/lspci-001.txt" > "$PT_TMPDIR/got"
 
39
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "lspci-001.txt"
40
40
 
41
 
cat <<EOF > "$TMPDIR/expected"
 
41
cat <<EOF > "$PT_TMPDIR/expected"
42
42
LSI Logic Unknown
43
43
EOF
44
 
find_raid_controller_lspci "$samples/lspci-002.txt" > "$TMPDIR/got"
45
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "lspci-002.txt"
 
44
find_raid_controller_lspci "$samples/lspci-002.txt" > "$PT_TMPDIR/got"
 
45
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "lspci-002.txt"
46
46
 
47
 
cat <<EOF > "$TMPDIR/expected"
 
47
cat <<EOF > "$PT_TMPDIR/expected"
48
48
AACRAID
49
49
EOF
50
 
find_raid_controller_lspci "$samples/lspci-003.txt" > "$TMPDIR/got"
51
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "lspci-003.txt"
 
50
find_raid_controller_lspci "$samples/lspci-003.txt" > "$PT_TMPDIR/got"
 
51
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "lspci-003.txt"
52
52
 
53
 
cat <<EOF > "$TMPDIR/expected"
 
53
cat <<EOF > "$PT_TMPDIR/expected"
54
54
LSI Logic MegaRAID SAS
55
55
EOF
56
 
find_raid_controller_lspci "$samples/lspci-004.txt" > "$TMPDIR/got"
57
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "lspci-004.txt"
 
56
find_raid_controller_lspci "$samples/lspci-004.txt" > "$PT_TMPDIR/got"
 
57
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "lspci-004.txt"
58
58
 
59
 
cat <<EOF > "$TMPDIR/expected"
 
59
cat <<EOF > "$PT_TMPDIR/expected"
60
60
Fusion-MPT SAS
61
61
EOF
62
 
find_raid_controller_lspci "$samples/lspci-005.txt" > "$TMPDIR/got"
63
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "lspci-005.txt"
 
62
find_raid_controller_lspci "$samples/lspci-005.txt" > "$PT_TMPDIR/got"
 
63
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "lspci-005.txt"
64
64
 
65
 
cat <<EOF > "$TMPDIR/expected"
 
65
cat <<EOF > "$PT_TMPDIR/expected"
66
66
HP Smart Array
67
67
EOF
68
 
find_raid_controller_lspci "$samples/lspci-006.txt" > "$TMPDIR/got"
69
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "lspci-006.txt"
 
68
find_raid_controller_lspci "$samples/lspci-006.txt" > "$PT_TMPDIR/got"
 
69
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "lspci-006.txt"
70
70
 
71
71
# find_raid_controller_dmesg
72
72
 
73
 
cat <<EOF > "$TMPDIR/expected"
 
73
cat <<EOF > "$PT_TMPDIR/expected"
74
74
Fusion-MPT SAS
75
75
EOF
76
 
find_raid_controller_dmesg "$samples/dmesg-001.txt" > "$TMPDIR/got"
77
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "dmesg-001.txt"
 
76
find_raid_controller_dmesg "$samples/dmesg-001.txt" > "$PT_TMPDIR/got"
 
77
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "dmesg-001.txt"
78
78
 
79
 
cat <<EOF > "$TMPDIR/expected"
 
79
cat <<EOF > "$PT_TMPDIR/expected"
80
80
AACRAID
81
81
EOF
82
 
find_raid_controller_dmesg "$samples/dmesg-002.txt" > "$TMPDIR/got"
83
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "dmesg-002.txt"
 
82
find_raid_controller_dmesg "$samples/dmesg-002.txt" > "$PT_TMPDIR/got"
 
83
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "dmesg-002.txt"
84
84
 
85
 
cat <<EOF > "$TMPDIR/expected"
 
85
cat <<EOF > "$PT_TMPDIR/expected"
86
86
LSI Logic MegaRAID SAS
87
87
EOF
88
 
find_raid_controller_dmesg "$samples/dmesg-003.txt" > "$TMPDIR/got"
89
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "dmesg-003.txt"
 
88
find_raid_controller_dmesg "$samples/dmesg-003.txt" > "$PT_TMPDIR/got"
 
89
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "dmesg-003.txt"
90
90
 
91
 
cat <<EOF > "$TMPDIR/expected"
 
91
cat <<EOF > "$PT_TMPDIR/expected"
92
92
AACRAID
93
93
EOF
94
 
find_raid_controller_dmesg "$samples/dmesg-004.txt" > "$TMPDIR/got"
95
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "dmesg-004.txt"
 
94
find_raid_controller_dmesg "$samples/dmesg-004.txt" > "$PT_TMPDIR/got"
 
95
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "dmesg-004.txt"
96
96
 
97
 
cat <<EOF > "$TMPDIR/expected"
 
97
cat <<EOF > "$PT_TMPDIR/expected"
98
98
Fusion-MPT SAS
99
99
EOF
100
 
find_raid_controller_dmesg "$samples/dmesg-005.txt" > "$TMPDIR/got"
101
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "dmesg-005.txt"
102
 
 
103
 
# TODO is this right?
104
 
cat <<EOF > "$TMPDIR/expected"
105
 
EOF
106
 
find_raid_controller_dmesg "$samples/dmesg-006.txt" > "$TMPDIR/got"
107
 
cat "$TMPDIR/got"
108
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "dmesg-006.txt"
109
 
 
110
 
# TODO is this right?
111
 
cat <<EOF > "$TMPDIR/expected"
112
 
EOF
113
 
find_raid_controller_dmesg "$samples/dmesg-007.txt" > "$TMPDIR/got"
114
 
cat "$TMPDIR/got"
115
 
no_diff "$TMPDIR/got" "$TMPDIR/expected" "dmesg-007.txt"
 
100
find_raid_controller_dmesg "$samples/dmesg-005.txt" > "$PT_TMPDIR/got"
 
101
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "dmesg-005.txt"
 
102
 
 
103
# TODO is this right?
 
104
cat <<EOF > "$PT_TMPDIR/expected"
 
105
EOF
 
106
find_raid_controller_dmesg "$samples/dmesg-006.txt" > "$PT_TMPDIR/got"
 
107
cat "$PT_TMPDIR/got"
 
108
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "dmesg-006.txt"
 
109
 
 
110
# TODO is this right?
 
111
cat <<EOF > "$PT_TMPDIR/expected"
 
112
EOF
 
113
find_raid_controller_dmesg "$samples/dmesg-007.txt" > "$PT_TMPDIR/got"
 
114
cat "$PT_TMPDIR/got"
 
115
no_diff "$PT_TMPDIR/got" "$PT_TMPDIR/expected" "dmesg-007.txt"
116
116
 
117
117
# raid_controller
118
118
 
119
 
rm "$TMPDIR/raid_controller_outfile.tmp" 2>/dev/null
120
 
raid_controller "" "" > "$TMPDIR/raid_controller_outfile.tmp"
 
119
rm "$PT_TMPDIR/raid_controller_outfile.tmp" 2>/dev/null
 
120
raid_controller "" "" > "$PT_TMPDIR/raid_controller_outfile.tmp"
121
121
 
122
122
is \
123
 
   "$(get_var raid_controller "$TMPDIR/raid_controller_outfile.tmp")" \
 
123
   "$(get_var raid_controller "$PT_TMPDIR/raid_controller_outfile.tmp")" \
124
124
   "No RAID controller detected" \
125
125
   "raid_controller has a sane default"
126
126
 
127
 
rm "$TMPDIR/raid_controller_outfile.tmp" 2>/dev/null
128
 
raid_controller "" "$samples/lspci-001.txt" > "$TMPDIR/raid_controller_outfile.tmp"
 
127
rm "$PT_TMPDIR/raid_controller_outfile.tmp" 2>/dev/null
 
128
raid_controller "" "$samples/lspci-001.txt" > "$PT_TMPDIR/raid_controller_outfile.tmp"
129
129
is \
130
 
   "$(get_var raid_controller "$TMPDIR/raid_controller_outfile.tmp")" \
 
130
   "$(get_var raid_controller "$PT_TMPDIR/raid_controller_outfile.tmp")" \
131
131
   "Fusion-MPT SAS" \
132
132
   "raid_controller gets the correct result from an lspci file"
133
133
 
134
 
rm "$TMPDIR/raid_controller_outfile.tmp" 2>/dev/null
135
 
raid_controller "$samples/dmesg-004.txt" "" > "$TMPDIR/raid_controller_outfile.tmp"
 
134
rm "$PT_TMPDIR/raid_controller_outfile.tmp" 2>/dev/null
 
135
raid_controller "$samples/dmesg-004.txt" "" > "$PT_TMPDIR/raid_controller_outfile.tmp"
136
136
is \
137
 
   "$(get_var raid_controller "$TMPDIR/raid_controller_outfile.tmp")" \
 
137
   "$(get_var raid_controller "$PT_TMPDIR/raid_controller_outfile.tmp")" \
138
138
   "AACRAID" \
139
139
   "...Or from a dmseg file"
140
140
 
142
142
 
143
143
i=1
144
144
for expected in "" "" "" "" "" "Xen" "VirtualBox"; do
145
 
   find_virtualization_dmesg "$samples/dmesg-00$i.txt" > "$TMPDIR/got"
146
 
   is "$(cat "$TMPDIR/got")" "$expected" "dmesg-00$i.txt"
 
145
   find_virtualization_dmesg "$samples/dmesg-00$i.txt" > "$PT_TMPDIR/got"
 
146
   is "$(cat "$PT_TMPDIR/got")" "$expected" "dmesg-00$i.txt"
147
147
   i=$(($i + 1))
148
148
done
149
149
 
153
153
   local cmd="$1"
154
154
   local output="$2"
155
155
 
156
 
   printf "#!/usr/bin/env bash\necho \"${output}\"\n" > "$TMPDIR/${cmd}_replacement"
157
 
   chmod +x "$TMPDIR/${cmd}_replacement"
158
 
   eval "CMD_$(echo $cmd | tr '[a-z]' '[A-Z]')=\"$TMPDIR/${cmd}_replacement\""
 
156
   printf "#!/usr/bin/env bash\necho \"${output}\"\n" > "$PT_TMPDIR/${cmd}_replacement"
 
157
   chmod +x "$PT_TMPDIR/${cmd}_replacement"
 
158
   eval "CMD_$(echo $cmd | tr '[a-z]' '[A-Z]')=\"$PT_TMPDIR/${cmd}_replacement\""
159
159
}
160
160
 
161
161
test_linux_exclusive_collection () {
208
208
platform="$(get_var platform "$p/summary")"
209
209
 
210
210
if [ "$platform" = "Linux" ]; then
211
 
   mkdir "$TMPDIR/linux_data"
 
211
   mkdir "$PT_TMPDIR/linux_data"
212
212
   if [ -e "$p/sysctl" ]; then
213
 
      cp "$p/sysctl" "$TMPDIR/linux_data/sysctl"
 
213
      cp "$p/sysctl" "$PT_TMPDIR/linux_data/sysctl"
214
214
   fi
215
 
   test_linux_exclusive_collection "$TMPDIR/linux_data"
216
 
   rm -rf "$TMPDIR/linux_data"
 
215
   test_linux_exclusive_collection "$PT_TMPDIR/linux_data"
 
216
   rm -rf "$PT_TMPDIR/linux_data"
217
217
else
218
218
   skip 1 5 "Tests exclusive for Linux"
219
219
fi
257
257
      "AACRAID calls arcconf"
258
258
}
259
259
 
260
 
mkdir "$TMPDIR/raid_controller"
261
 
test_propietary_raid_controller "$TMPDIR/raid_controller"
 
260
mkdir "$PT_TMPDIR/raid_controller"
 
261
test_propietary_raid_controller "$PT_TMPDIR/raid_controller"
262
262
 
263
263
 
264
264
# notable_processes_info
270
270
if [ -e /proc/$forked_pid/oom_adj ] \
271
271
      && echo "-17" > /proc/$forked_pid/oom_adj 2>/dev/null; then
272
272
 
273
 
   notable_processes_info > "$TMPDIR/notable_procs"
 
273
   notable_processes_info > "$PT_TMPDIR/notable_procs"
274
274
   like \
275
 
      "$(cat "$TMPDIR/notable_procs")" \
 
275
      "$(cat "$PT_TMPDIR/notable_procs")" \
276
276
      "${forked_pid}\\s+-17" \
277
277
      "notable_proccesses_info finds the process we manually changed earlier"
278
278
 
309
309
      "..but if it's there, it gets called with the expected parameters "
310
310
}
311
311
 
312
 
mkdir "$TMPDIR/dmidecode_system_info"
313
 
test_dmidecode_system_info "$TMPDIR/dmidecode_system_info"
 
312
mkdir "$PT_TMPDIR/dmidecode_system_info"
 
313
test_dmidecode_system_info "$PT_TMPDIR/dmidecode_system_info"
314
314