Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 1041
blob7bcd891de71b1971da6f63a3d38bc5696cf0e006
1 #!/bin/sh
2 # PCP QA Test No. 1041
3 # Exercise the libvirt PMDA - install, remove and values.
5 # Copyright (c) 2016 Red Hat.
7 # Expectations:
8 # 1) libvirtd installed and running
9 # - typically from libvirt package
10 # 2) libvirt Python API available
11 # - typically from libvirt-python
12 # 3) optionally one or more VMs up
13 # 4) libvirt.hv.* metrics always expected
14 # 5) with VMs available at least:
15 # - libvirt.dominfo.uuid
16 # - libvirt.dominfo.name
17 # - libvirt.dominfo.memory.{boot,current}
18 # - libvirt.dominfo.vcpu.*
19 # - libvirt.dominfo.type
20 # - libvirt.dominfo.os.type
21 # - libvirt.domstats.mem.*
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 . ./common.python
29 [ -d $PCP_PMDAS_DIR/libvirt ] || _notrun "libvirt PMDA directory is not installed"
30 $python -c "from pcp import pmda" >/dev/null 2>&1
31 [ $? -eq 0 ] || _notrun "python pcp pmda module not installed"
32 $python -c "import libvirt" >/dev/null 2>&1
33 [ $? -eq 0 ] || _notrun "python libvirt module not installed"
34 $python -c "import lxml" >/dev/null 2>&1
35 [ $? -eq 0 ] || _notrun "python lxml module not installed"
37 status=1 # failure is the default!
38 $sudo rm -rf $tmp.* $seq.full
40 pmdalibvirt_remove()
42 echo
43 echo "=== remove libvirt agent ==="
44 $sudo ./Remove >$tmp.out 2>&1
45 _filter_pmda_remove <$tmp.out
48 pmdalibvirt_install()
50 # start from known starting points
51 cd $PCP_PMDAS_DIR/libvirt
52 $sudo ./Remove >/dev/null 2>&1
53 $sudo $PCP_RC_DIR/pmcd stop
55 cat <<EOF >$tmp.config
56 [pmda]
57 #oldapi = False
58 user = root
59 uri = qemu:///system
60 EOF
61 echo "pmdalibvirt config:" >> $here/$seq.full
62 cat $tmp.config >> $here/$seq.full
64 [ -f $PCP_PMDAS_DIR/libvirt/libvirt.conf ] && \
65 $sudo cp $PCP_PMDAS_DIR/libvirt/libvirt.conf $tmp.backup
66 $sudo cp $tmp.config $PCP_PMDAS_DIR/libvirt/libvirt.conf
68 echo
69 echo "=== libvirt agent installation ==="
70 $sudo ./Install </dev/null >$tmp.out 2>&1
71 # Check metrics have appeared ... X metrics and Y values
72 _filter_pmda_install <$tmp.out \
73 | sed \
74 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
75 | $PCP_AWK_PROG '
76 /Check libvirt metrics have appeared/ { if ($7 >= 67 && $7 <= 100) $7 = "X"
77 if ($10 >= 14 && $10 <= 50) $10 = "Y"
79 / warnings, / { if ($9 >= 67 && $9 <= 100) $9 = "X"
80 if ($12 >= 14 && $12 <= 50) $12 = "Y"
82 { print }'
85 pmdalibvirt_cleanup()
87 if [ -f $tmp.backup ]; then
88 $sudo cp $tmp.backup $PCP_PMDAS_DIR/libvirt/libvirt.conf
89 $sudo rm $tmp.backup
90 else
91 $sudo rm -f $PCP_PMDAS_DIR/libvirt/libvirt.conf
93 _cleanup_pmda libvirt
96 _prepare_pmda libvirt
97 trap "pmdalibvirt_cleanup; exit \$status" 0 1 2 3 15
99 _filter()
101 sed \
102 -e '/No value(s) available/d' \
103 #end
106 # real QA test starts here
107 pmdalibvirt_install
109 echo
110 echo "=== verify metric values ==="
111 echo "from pminfo:" >>$here/$seq.full
112 pminfo -v libvirt 2>&1 \
113 | tee -a $here/$seq.full \
114 | _filter
116 pmdalibvirt_remove
117 status=0
118 exit