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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
#!/bin/sh
# PCP QA Test No. 626
# pmlogger_daily with -x 0 and previously failing to merge correctly
# ... list of files below comes from an observed interactive run
# of pmlogger_daily during -x 0 development
#
# Copyright (c) 2018 Ken McDonell. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
if which zstd >/dev/null 2>&1
then
PROG="zstd --rm --quiet"
SUFF=zst
elif which xz >/dev/null 2>&1
then
PROG=xz
SUFF=xz
elif which bzip2 >/dev/null 2>&1
then
PROG=bzip2
SUFF=bz2
elif which gzip >/dev/null 2>&1
then
PROG=gzip
SUFF=gz
else
_notrun "cannot find a compression program!"
fi
NEEDREWRITE=$PCP_LOG_DIR/pmlogger/.NeedRewrite
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
[ -f $NEEDREWRITE.$seq ] && $sudo mv $NEEDREWRITE.$seq $NEEDREWRITE
}
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
[ -f $NEEDREWRITE ] && $sudo mv $NEEDREWRITE $NEEDREWRITE.$seq
_setup_control()
{
echo '$version=1.1' >$tmp.control
for arg
do
echo "\$$arg" >>$tmp.control
done
echo "LOCALHOSTNAME n n $tmp $tmp.config" >>$tmp.control
cat $tmp.control >>$seq_full
}
_filter()
{
if [ $# -eq 0 ]
then
cmd=cat
elif [ -f "$1" ]
then
cmd="cat \"$1\""
else
return
fi
eval $cmd \
| tee -a $seq_full \
| sed \
-e '/pmlogger_daily.pid: Permission denied/d' \
-e '/no pmlogger instance running for host/d' \
-e '/^pmlogger_daily:.*\.control:[0-9]]$/d' \
-e '/logging for host .* unchanged/d' \
-e '/^rm: cannot remove .*pmlogger_daily.stamp/d' \
-e '/^cp: cannot create regular file .*pmlogger_daily.stamp/d' \
-e '/^cp: .*\/pmlogger_daily.stamp: Permission denied/d' \
-e '/^.[r-][w-][x-].*pmlogger_daily.stamp/d' \
-e '/^_save_prev_filename: unable to remove/d' \
-e '/^Warning: cannot save previous date-and-timestamp/d' \
-e '/^Warning: cannot install new date-and-timestamp/d' \
# end
}
_showfiles()
{
ls $tmp/* \
| sed \
-e "s@$tmp@TMP@" \
-e "s/\.$SUFF$/.compressed/" \
-e "s/\.xz$/.compressed/" \
-e "s/$DATE/DATE/" \
# end
}
cp archives/ok-foo.0 $tmp.0
$PROG $tmp.0 >>$seq_full 2>&1
mkdir $tmp
cat <<End-of-File | while read f
20180225.0.$SUFF
20180225.index
20180225.meta
20180226.0.$SUFF
20180226.index
20180226.meta
20180227.0.$SUFF
20180227.index
20180227.meta
20180301.0.$SUFF
20180301.index
20180301.meta
20180302.0.$SUFF
20180302.index
20180302.meta
20180303.0.$SUFF
20180303.index
20180303.meta
20180304.0.$SUFF
20180304.index
20180304.meta
20180306.0.$SUFF
20180306.index
20180306.meta
20180307.0.$SUFF
20180307.index
20180307.meta
20180308.0.$SUFF
20180308.index
20180308.meta
20180311.00.10.0.$SUFF
20180311.00.10.index
20180311.00.10.meta
20180311.19.16.0.$SUFF
20180311.19.16.index
20180311.19.16.meta
20180311.19.17.0.$SUFF
20180311.19.17.index
20180311.19.17.meta
20180311.19.18.0.$SUFF
20180311.19.18.index
20180311.19.18.meta
20180311.19.20-00.0.$SUFF
20180311.19.20-00.index
20180311.19.20-00.meta
20180311.19.20-01.0.$SUFF
20180311.19.20-01.index
20180311.19.20-01.meta
20180311.19.22.0.$SUFF
20180311.19.22.index
20180311.19.22.meta
20180311.19.23-00.0.$SUFF
20180311.19.23-00.index
20180311.19.23-00.meta
20180311.19.23.0.$SUFF
20180311.19.23.index
20180311.19.23.meta
20180311.19.24-00.0.$SUFF
20180311.19.24-00.index
20180311.19.24-00.meta
20180311.19.24.0.$SUFF
20180311.19.24.index
20180311.19.24.meta
20180311.19.28-00.0.$SUFF
20180311.19.28-00.index
20180311.19.28-00.meta
20180311.19.28-01.0.$SUFF
20180311.19.28-01.index
20180311.19.28-01.meta
20180311.19.28.0.$SUFF
20180311.19.28.index
20180311.19.28.meta
20180311.20.51.0.$SUFF
20180311.20.51.index
20180311.20.51.meta
20180311.20.56.0.$SUFF
20180311.20.56.10.$SUFF
20180311.20.56.11.$SUFF
20180311.20.56.12.$SUFF
20180311.20.56.1.$SUFF
20180311.20.56.2.$SUFF
20180311.20.56.3.$SUFF
20180311.20.56.4.$SUFF
20180311.20.56.5.$SUFF
20180311.20.56.6.$SUFF
20180311.20.56.7.$SUFF
20180311.20.56.8.$SUFF
20180311.20.56.9.$SUFF
20180311.20.56.index
20180311.20.56.meta
20180312.00.10.0.$SUFF
20180312.00.10.10.$SUFF
20180312.00.10.11.$SUFF
20180312.00.10.12.$SUFF
20180312.00.10.13.$SUFF
20180312.00.10.14.$SUFF
20180312.00.10.15.$SUFF
20180312.00.10.16.$SUFF
20180312.00.10.17.$SUFF
20180312.00.10.18.$SUFF
20180312.00.10.19.$SUFF
20180312.00.10.1.$SUFF
20180312.00.10.20.$SUFF
20180312.00.10.21.$SUFF
20180312.00.10.22.$SUFF
20180312.00.10.23.$SUFF
20180312.00.10.24.$SUFF
20180312.00.10.25.$SUFF
20180312.00.10.26.$SUFF
20180312.00.10.27.$SUFF
20180312.00.10.28.$SUFF
20180312.00.10.29.$SUFF
20180312.00.10.2.$SUFF
20180312.00.10.30.$SUFF
20180312.00.10.31.$SUFF
20180312.00.10.32.$SUFF
20180312.00.10.33.$SUFF
20180312.00.10.34.$SUFF
20180312.00.10.3.$SUFF
20180312.00.10.4.$SUFF
20180312.00.10.5.$SUFF
20180312.00.10.6.$SUFF
20180312.00.10.7.$SUFF
20180312.00.10.8.$SUFF
20180312.00.10.9.$SUFF
20180312.00.10.index
20180312.00.10.meta
20180312.08.45.0.$SUFF
20180312.08.45.index
20180312.08.45.meta
End-of-File
do
case $f
in
*.index)
cp archives/ok-foo.index $tmp/$f
;;
*.meta)
cp archives/ok-foo.meta $tmp/$f
;;
*.[0-9].$SUFF|*.[0-9][0-9].$SUFF)
# fake out the .$SUFF files with a compressed ok-foo.0
cp $tmp.0.$SUFF $tmp/$f
;;
*)
echo "$f - eh?"
exit
;;
esac
done
_showfiles >$tmp.before
# real QA test starts here
_setup_control PCP_COMPRESSAFTER=0 PCP_COMPRESS="'$PROG'"
pmlogger_daily -P -D -f -c $tmp.control -l $tmp.log >$tmp.out 2>$tmp.err
_filter $tmp.err; _filter $tmp.out; _filter $tmp.log
_showfiles >$tmp.after
echo
echo "diffs ... expect 20180311 and 20180312 archives to be merged"
diff $tmp.before $tmp.after
# success, all done
status=0
exit
|