summaryrefslogtreecommitdiff
path: root/qa/375
blob: 82625fedcbdd51e2f60c487fc84bdc2fcb70d0d6 (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
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
#! /bin/sh
# PCP QA Test No. 374
# pmlogger (PCP 2.0) and pmlc (assorted) version compatibility
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

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

# get standard filters
. ./common.product
. ./common.filter
. ./common.check

PMCD_CONNECT_TIMEOUT=30
PMCD_REQUEST_TIMEOUT=30
export PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT

rm -f $seq.out
case $PCP_PLATFORM
in
    linux|darwin|solaris)
	if [ $PCP_VER -lt 3600 ]; then
	    ln $seq.$PCP_PLATFORM $seq.out || exit 1
	elif [ $PCP_VER -lt 3800 ]; then
	    ln $seq.$PCP_PLATFORM.2 $seq.out || exit 1
	else
	    ln $seq.$PCP_PLATFORM.3 $seq.out || exit 1
	fi
	;;
    *)
	_notrun "Need qualified output for $PCP_PLATFORM"
	;;
esac

_filter()
{
    _filter_pmdumplog \
    | sed \
	-e '/^pmlogger .* on host .* is logging metrics from host .*/d' \
	-e '/^PMCD host/d' \
	-e '/^TIMESTAMP started/d' \
    | $PCP_AWK_PROG '
$1 == "log" && $2 == "size"	{ if ($3 > 100 && $3 <= 200) $3 = "more than 100"
				  else if ($3 > 200 && $3 <= 300) $3 = "more than 200"
				}
				{ print }'
}

_speak_to_me()
{
    host=$1
    $sudo rm -f /tmp/$$.*
    _start_up_pmlogger -L -c /dev/null -l /tmp/$$.log /tmp/$$ </dev/null >/dev/null 2>&1
    _wait_for_pmlogger $pid /tmp/$$.log

    # the success cases
    #
    cat <<End-of-File | ssh -q pcpqa@$host "sh -c 'PMCD_CONNECT_TIMEOUT=$PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT=$PMCD_REQUEST_TIMEOUT pmlc'" >$tmp.out 2>$tmp.err
connect $pid@$me
status
new volume
status
flush
# singular, all instances
query { pmcd.simabi pmcd.control.register }
# some instances
query pmcd.agent.type [ "$PCP_PLATFORM" "pmcd" "sample"]
# non-leaf
query pmcd.pdu_in
# logging
log mandatory on once pmcd.agent.type ["$PCP_PLATFORM" "pmcd"]
log mandatory off pmcd.agent.type ["sample"]
End-of-File
    # do ssh again is probably long enough for "once" metrics above
    # to have been logged
    #
    cat <<End-of-File | ssh -q pcpqa@$host "sh -c 'PMCD_CONNECT_TIMEOUT=$PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT=$PMCD_REQUEST_TIMEOUT pmlc'" >>$tmp.out 2>>$tmp.err
connect $pid@$me
query pmcd.agent.type ["$PCP_PLATFORM" "pmcd" "sample"]
End-of-File
    cat $tmp.err $tmp.out | _filter

    # the failures
    #
    # echo "log mandatory on once sample" | pmlc -h $host $pid -D1
    echo "connect $pid@$me" | ssh -q pcpqa@$host "sh -c 'PMCD_CONNECT_TIMEOUT=$PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT=$PMCD_REQUEST_TIMEOUT pmlc'" >$tmp.out 2>$tmp.err
    cat $tmp.err $tmp.out | _filter

    # cleanup
    #
    if [ ! -z "$host" ]
    then
	$sudo $signal -s TERM $pid
	pid=''
    fi

}

_cleanup()
{
    if $need_clean
    then
	if [ ! -z "$pid" ]
	then
	    $sudo $signal -s TERM $pid
	    sleep 1
	    $sudo $signal -s KILL $pid
	    pid=''
	fi
	need_clean=false
    fi
    $sudo rm -f $tmp.*
    exit
}

need_clean=true
signal=$PCP_BINADM_DIR/pmsignal
status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

if [ -x $PCP_BINADM_DIR/pmhostname ]
then
    me=`pmhostname`
else
    host=`hostname`
    me=`_host_to_fqdn $host`
fi
pid=''

# real QA test starts here

for type in "-b 32 -v pcp>=2" "-b 64 -v pcp>=2"
do
    echo
    echo "=== pmlc host type: $type ==="
    host=`./getpmcdhosts -L -n 1 $type`
    if [ -z "$host" ]
    then
	_notrun "Cannot find a 64-bit host running PCP"
    else
	# echo $host
	_speak_to_me $host
    fi
done

# success, all done
status=0
exit