pmrep: fix archive end time reporting
[pcp.git] / qa / 532
blobc78f316a689209405c357b8254492db4fe624840
1 #! /bin/sh
2 # PCP QA Test No. 532
3 # pmlogger_check with *-xx.* archives and .meta files in subdirs
4 # (loosely based on 530 and 338)
6 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 # Note: for reasons that are not understood, this test sometimes fails
9 # but passes when rerun
12 seq=`basename $0`
13 echo "QA output created by $seq"
15 # get standard filters
16 . ./common.product
17 . ./common.filter
18 . ./common.check
20 _filter()
22 tee -a $seq.full \
23 | sed -f $tmp/sed \
24 | sed \
25 -e "s;$tmp;TMP;g" \
26 -e "s/local:/HOST/g" \
27 -e "s/`hostname`/HOST/g" \
28 -e "s/`hostname | sed -e 's/\..*//'`/HOST/g" \
29 -e '/\/var\/adm\/pcplog\/NOTICES/d' \
30 -e 's/-rw-r--r--\./-rw-r--r--/' \
31 | $PCP_AWK_PROG '
32 /-rw-r--r--/ { print $1,"...",$5,"...",$9; next }
33 { print }' \
34 | _filter_cron_scripts
37 status=1 # failure is the default!
38 trap "cd $here; $sudo rm -rf $tmp $tmp.*; $sudo mv $PCP_LOG_DIR/NOTICES.$$ $PCP_LOG_DIR/NOTICES; exit \$status" 0 1 2 3 15
40 # take explicit control of the umask
42 umask 022
44 $sudo mv $PCP_LOG_DIR/NOTICES $PCP_LOG_DIR/NOTICES.$$
45 rm -f $seq.full
46 rm -rf $tmp $tmp.*
47 mkdir $tmp
48 mkdir $tmp/foo
50 # real QA test starts here
51 verbose=-V
52 echo >$tmp/sed
53 for day in 0 1 2 3
55 fmt=%Y%m%d
57 for hour in 1 4 16
59 [ $day -gt 0 -a $hour -gt 1 ] && continue
60 # aiming for the time to be hour:10, hour:20 and hour:30 on
61 # each day, even if that is ahead of NOW for today
63 now_hr=`pmdate %H`
64 hr_set=`expr $hour - $now_hr`
65 [ "$hr_set" -ge 0 ] && hr_set="+$hr_set"
66 now_min=`pmdate %M`
67 min_set10=`expr 10 - $now_min`
68 [ "$min_set10" -ge 0 ] && min_set10="+$min_set10"
69 min_set20=`expr 20 - $now_min`
70 [ "$min_set20" -ge 0 ] && min_set20="+$min_set20"
71 min_set30=`expr 30 - $now_min`
72 [ "$min_set30" -ge 0 ] && min_set30="+$min_set30"
73 namea=`pmdate -${day}d ${hr_set}H ${min_set10}M $fmt.%H.%M`
74 nameb=`pmdate -${day}d ${hr_set}H ${min_set20}M $fmt.%H.%M`
75 namec=`pmdate -${day}d ${hr_set}H ${min_set30}M $fmt.%H.%M`
76 yesterday=`pmdate -1d ${hr_set}H ${min_set10}M $fmt`
77 stampa=`echo $namea | sed -e 's/\.//g'`
78 stampb=`echo $nameb | sed -e 's/\.//g'`
79 stampc=`echo $namec | sed -e 's/\.//g'`
80 nameb=${namea}-00
81 namec=${namea}-01
82 echo "s/$namea/NOW-$day.${hour}H.MM/g" >>$tmp/sed
83 echo "s/$nameb/NOW-$day.${hour}H.MM-00/g" >>$tmp/sed
84 echo "s/$namec/NOW-$day.${hour}H.MM-01/g" >>$tmp/sed
86 for ext in 0 index meta
88 if [ $hour -ne 4 ]
89 then
90 cp archives/arch_a.$ext $tmp/$namea.$ext
91 touch -t $stampa $tmp/$namea.$ext
93 cp archives/arch_b.$ext $tmp/$nameb.$ext
94 touch -t $stampb $tmp/$nameb.$ext
95 cp archives/arch_b.$ext $tmp/$namec.$ext
96 touch -t $stampc $tmp/$namec.$ext
97 done
98 done
99 done
101 ( cd $tmp; tar cf - *.0 *.meta *.index 2>/dev/null ) \
102 | ( cd $tmp/foo; tar xpf - 2>/dev/null )
104 echo "s/NOW-0/TODAY/g" >>$tmp/sed
105 echo "s/NOW-1/YESTERDAY/g" >>$tmp/sed
106 echo "s/`pmdate %Y%m%d`/TODAY/g" >>$tmp/sed
107 echo "s/$yesterday/YESTERDAY/g" >>$tmp/sed
109 echo >$tmp/control '$version=1.1
110 LOCALHOSTNAME n n '"$tmp"' ./config'
112 echo
113 echo "Before ..."
114 ls $tmp | sed -f $tmp/sed | LC_COLLATE=POSIX sort | tee $tmp.before
115 ls -l $tmp >>$seq.full
117 # list of culled files is in directory order, hence the cut and sort
118 # complexity at the end of this pipeline
120 echo
121 $sudo $PCP_BINADM_DIR/pmlogger_daily -o -c $tmp/control -k 2 $verbose -l $tmp.log
122 $sudo cat $tmp.log \
123 | _filter \
124 | $PCP_AWK_PROG '
125 state == 0 { print >"'$tmp.out.0'"
126 if ($0 ~ /older than 2 days/) state = 1
127 next
129 state == 1 && NF == 0 { state = 2 }
130 state == 1 { for (i = 1; i <= NF; i++) print $i >"'$tmp.out.1'" }'
131 cat $tmp.out.0
132 LC_COLLATE=POSIX sort $tmp.out.1
134 echo "out.0 ..." >>$seq.full
135 cat $tmp.out.0 >>$seq.full
136 echo "out.1 ..." >>$seq.full
137 cat $tmp.out.1 >>$seq.full
139 echo
140 echo "After ..."
141 ls $tmp | sed -f $tmp/sed | LC_COLLATE=POSIX sort | tee $tmp.after
143 pmdumplog -a $tmp/$yesterday >>$seq.full
145 echo
146 echo "Differences ..."
147 diff $tmp.before $tmp.after
149 # all done
150 status=0
151 exit