blob: dcf5df254af93f093321c9dd498626cdc082c7bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#! /bin/sh
# PCP QA Test No. 314
# Exercise pmie_daily functionality - log rotation
#
# Copyright (c) 2007 Aconex. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard filters
. ./common.product
. ./common.filter
. ./common.check
. ./localconfig
signal=$PCP_BINADM_DIR/pmsignal
status=1 # failure is the default!
trap "rm -fr $tmp.*; $sudo rm -fr /tmp/$seq; exit \$status" 0 1 2 3 15
# create a pmie config file, causing frequent output (to log)
cat > $tmp.config << EOF1
delta = 0.2 seconds;
fetched = simple.numfetch;
EOF1
echo "=== pmie config ===" >$seq.full
cat $tmp.config >>$seq.full
# create pmie control files and test out various good/bad conditions
cat > $tmp.control << EOF2
\$version=1.0
LOCALHOSTNAME n /tmp/$seq/1.good.log -v -c $tmp.config
EOF2
echo "=== pmie control ===" >>$seq.full
cat $tmp.control >>$seq.full
# real QA test starts here
$sudo $signal -a -s TERM pmie 2>/dev/null
$sudo rm -fr /tmp/$seq && mkdir /tmp/$seq || exit 1
id pcp >/dev/null 2>&1 && $sudo chown -R pcp:pcp /tmp/$seq
pmstore simple.numfetch 0 >/dev/null
# fire em all up
echo "Starting pmie process"
echo "=== pmie_check ===" >>$seq.full
$sudo $PCP_BINADM_DIR/pmie_check -c $tmp.control -VV >>$seq.full
ps $PCP_PS_ALL_FLAGS | grep '[p]mie' >>$seq.full
sleep 6 # fill original log a bit
cat /tmp/$seq/1.good.log >>$seq.full
ps $PCP_PS_ALL_FLAGS | grep '[p]mie' >>$seq.full
echo "Rotate, rotate..."
previous=`pmdate -1d %Y%m%d`
echo "=== pmie_daily ===" >>$seq.full
$sudo $PCP_BINADM_DIR/pmie_daily -c $tmp.control -VV >>$seq.full
ps $PCP_PS_ALL_FLAGS | grep '[p]mie' >>$seq.full
sleep 3 # fill rotated log a bit
echo "Shutdown pmie process"
echo "=== pmie_check ===" >>$seq.full
$sudo $PCP_BINADM_DIR/pmie_check -c $tmp.control -s -VV >>$seq.full
ps $PCP_PS_ALL_FLAGS | grep '[p]mie' >>$seq.full
grep rotated /tmp/$seq/1.good.log >/dev/null \
|| echo "First log not rotated?"
grep rotated /tmp/$seq/1.good.log.$previous >/dev/null \
|| echo "New log not started?"
# look for data in each log file, checking rotation actually did something
oldlines=`wc -l < /tmp/$seq/1.good.log.$previous 2>/dev/null || echo 0`
newlines=`wc -l < /tmp/$seq/1.good.log 2>/dev/null || echo 0`
# 5 samples / sec x ~6 sec x 2 lines per sample + 6 lines for header and footer
# so 66
_within_tolerance "Old logfile line count" "$oldlines" 66 %75 -v
# 5 samples / sec x ~3 sec x 2 lines per sample + 6 lines for header and footer
# so 36
_within_tolerance "New logfile line count" "$newlines" 36 %75 -v
echo "=== previous log ($oldlines lines) ===" >>$seq.full
cat /tmp/$seq/1.good.log.$previous >>$seq.full
echo "=== current log ($newlines lines) ===" >>$seq.full
cat /tmp/$seq/1.good.log >>$seq.full
# success, all done
status=0
exit
|