summaryrefslogtreecommitdiff
path: root/qa/709
blob: fbbfff769cd16f2d13ee50305d0a9c188f1951a2 (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
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
#!/bin/sh
# PCP QA Test No. 709
# Exercise the python collectl implementation
#
# Copyright (c) 2012-2014, Red Hat.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

status=0	# success is the default!
$sudo rm -fr $tmp.* $seq.full
trap "cd $here; rm -fr $tmp.*; exit \$status" 0 1 2 3 15

remove_extra_whitespace()
{
    sed \
	-e 's/>>>.*<<<//g' \
	-e 's/[0-9]/9/g' \
	-e 's/9[9]*/9/g' \
	-e 's/  *$//' \
	-e '/^ *$/d' \
	-e 's/  */ /g' \
	-e 's/^ *//' \
	-e 's/RECORD.*$/RECORD/' \
	-e 's/<-*Int/<-Int/' \
	-e 's/Int-*>/Int->/' \
    # end
}

remove_extra_columns()
{
    sed \
	-e 's/^ *//' \
	-e 's/ [a-zA-Z0-9 ]* *$//' \
	-e 's/^#<-*-/#<--/g' \
	-e 's/-*->/--->/g' \
    # end
}

# using a given metric (arg1), check that each of its instances
# exists in output file (arg2).
#
check_instances()
{
    metric=$1
    file=$2
    eval set -- `pmprobe -I $metric`
    [ $? -eq 0 ] || exit 1
    shift  # skip metric name
    shift  # skip instance count
    while [ $# -gt 0 ]
    do
	instance="$1"
	shift
	grep -q "$instance" $file && continue
	echo "Instance $instance of $metric is missing from $file!"
    done
}

# real QA test starts here
mkdir $tmp.$seq
cd $tmp.$seq

#PYCOLLECTL=pmcollectl.py	# developer version
PYCOLLECTL=pmcollectl		# installed version
args="-c 2 -i 0.1"
$PYCOLLECTL $args -sc | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sd | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sn | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sj | remove_extra_whitespace | remove_extra_columns | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sm | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sc --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sd --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sn --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -sm --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1

$PYCOLLECTL $args -sN > $tmp.net 2>&1 
check_instances network.interface.total.bytes $tmp.net

$PYCOLLECTL $args -sD > $tmp.disk 2>&1 
check_instances disk.dev.total_bytes $tmp.disk

# need a generic way to test these on any system
# $PYCOLLECTL $args -sC | remove_extra_whitespace | tee -a $tmp.out 2>&1
# $PYCOLLECTL $args -sJ | remove_extra_whitespace | tee -a $tmp.out 2>&1
# $PYCOLLECTL $args -sCD | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -scd | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $args -scd --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1

# test playback
interval=0.1
$PYCOLLECTL -sdDcCnNjJm -f test.pmcollectl -c10 -i $interval
logargs="-c 2 -i $interval -p test.pmcollectl"
$PYCOLLECTL $logargs -sd | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $logargs -sc | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $logargs -sn | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $logargs -sm | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $logargs -sd --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $logargs -sc --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $logargs -sn --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
$PYCOLLECTL $logargs -sm --verbose | remove_extra_whitespace | tee -a $tmp.out 2>&1
cat $tmp.out >>$here/$seq.full

eval `pmafm test.pmcollectl remove`

# success, all done
status=0
exit