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
|
#!/bin/sh
# PCP QA Test No. 1474
# exercise PM_CTXFLAG_METADATA_ONLY and pmlogrewrite
#
# Copyright (c) 2023 Ken McDonell. All Rights Reserved.
#
if [ $# -eq 0 ]
then
seq=`basename $0`
echo "QA output created by $seq"
else
# use $seq from caller, unless not set
[ -n "$seq" ] || seq=`basename $0`
echo "QA output created by `basename $0` $*"
fi
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
which xz >/dev/null 2>&1 || _notrun "No xz binary installed"
time=`which time`
[ -z "$time" ] && _notrun "can't find /bin/time nor /usr/bin/time"
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter()
{
sed \
-e "s@$tmp@TMP@g" \
# end
}
_summary()
{
$PCP_AWK_PROG '
$1 == "cputime:" { printf "'"$1"': %.2fcpu (%.2fusr + %.2fsys)\n",$2+$3, $2, $3 }
$1 != "cputime:" { print }'
}
# deal with differences in time(1) ... stdout reports <user time> <sys time>
# as floating point numbers of seconds
# known variants ...
# real 0m0.002s
# user 0m0.000s
# sys 0m0.002s
#
# real 0.0
# user 0.0
# sys 0.0
#
# 0.60user 0.01system ...
#
_time()
{
echo "_time: command: $*" >>$seq_full
$time $* >/dev/null 2>$tmp.clock
cat $tmp.clock >>$seq_full
sed -E <$tmp.clock \
-e '/^(real|user|sys)[ ]/{
s/([0-9])m/\1 /
s/([0-9])s$/\1/
}' \
-e '/[0-9]user [0-9]/{
s/user/ user/
s/system/ system/
}' \
| $PCP_AWK_PROG '
BEGIN { u = "?"; s = "?" }
$1 == "user" { if (NF == 3) u = 60*$2 + $3
if (NF == 2) u = $2
}
$1 == "sys" { if (NF == 3) s = 60*$2 + $3
if (NF == 2) s = $2
}
$2 == "user" && $4 == "system" {
u = $1
s = $3
}
END { print u,s }' \
| tee -a $seq_full
}
# archives/pcp-pidstat-process-args.0.xz is the largest QA archive(s)
# we have (to date) at 361Mb expanded ...
#
base=pcp-pidstat-process-args
mkdir $tmp
cd $tmp
pmlogcp $here/archives/$base .
_time xzcat $base.0.xz | sed -e 's/^/cputime: /' >$tmp.time
_summary <$tmp.time "data uncompress" | tee -a $seq_full >$tmp.tmp
data=`sed -n <$tmp.tmp -e '/[0-9]cpu (/{
s/cpu (.*//
s/.* //p
}'`
echo "data=$data" >>$seq_full
_time xzcat $base.meta.xz | sed -e 's/^/cputime: /' >$tmp.time
_summary <$tmp.time "metadata uncompress" | tee -a $seq_full >$tmp.tmp
metadata=`sed -n <$tmp.tmp -e '/[0-9]cpu (/{
s/cpu (.*//
s/.* //p
}'`
echo "metadata=$metadata" >>$seq_full
# real QA test starts here
_time pmlogrewrite -Dappl3 -qi $base | sed -e 's/^/cputime: /' >$tmp.time
_summary logrewrite <$tmp.time | tee -a $seq_full >$tmp.tmp
rewrite=`sed -n <$tmp.tmp -e '/[0-9]cpu (/{
s/cpu (.*//
s/.* //p
}'`
echo "rewrite=$rewrite" >>$seq_full
# expect the rewrite time to be closer to the metadata time than the
# data time
#
echo "$data $rewrite $metadata" | $PCP_AWK_PROG '
function abs(a,b)
{
if (a >= b)
return a-b
else
return b-a
}
{ d1 = abs($1 - $2)
d2 = abs($2 - $3)
if (d2 < d1)
print "pmlogrewrite time closer to metadata decompress than data decompress"
else
print "Failed closer test: data-to-pmlogrewrite",d1,"pmlogrewrite-to-metadata",d2
}'
# expect the data time to be _at least_ 40 times the rewrite time,
# but need to set bar at 20 times thanks to slow VMs
#
echo "$data $rewrite" | $PCP_AWK_PROG '
{ if ($1 >= 20 * $2)
print "pmlogrewrite time more than 20 times faster than data decompress time"
else
print "Failed 20 times test: pmlogrewrite",$2,"data decompress",$1
}'
# success, all done
exit
|