Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 761
blobd2168edb3b735c4486137cb9ff40e760ebcddac7
1 #!/bin/sh
2 # PCP QA Test No. 761
3 # Exercise the PMCD privileged co-process (root) PMDA
4 # Install, Remove and handling of different container
5 # engines container.* metrics.
7 # Copyright (c) 2014-2015 Red Hat.
10 seq=`basename $0`
11 echo "QA output created by $seq"
13 # get standard environment, filters and checks
14 . ./common.product
15 . ./common.filter
16 . ./common.check
18 case "$PCP_PLATFORM"
20 linux)
23 _notrun "No container support for PCP_PLATFORM $PCP_PLATFORM"
24 # NOTREACHED
26 esac
29 _get_libpcp_config
30 $unix_domain_sockets || _notrun "No unix domain socket support available"
32 root=$tmp.root
33 status=1 # failure is the default!
34 $sudo rm -rf $tmp.* $seq.full
36 root_cleanup()
38 cd $here
39 [ -d $root ] && sudo rm -fr $root
40 [ -f $tmp.conf.backup ] && sudo cp $tmp.conf.backup $PCP_DIR/etc/pcp.conf
41 rm -f $tmp.*
44 # do metrics one at a time, map all internal instance ids to N and sort
45 # instance lines
47 _check()
49 pminfo containers | LC_COLLATE=POSIX sort \
50 | while read metric
52 pminfo -f $metric >$tmp.tmp
53 grep -v ' inst \[' $tmp.tmp
54 sed -n -e '/inst \[/s/\[[0-9][0-9]*/[N/p' $tmp.tmp \
55 | LC_COLLATE=POSIX sort
56 done
59 _prepare_pmda root containers
60 trap "root_cleanup; exit \$status" 0 1 2 3 15
62 # backup main PCP config
63 cp $PCP_DIR/etc/pcp.conf $tmp.conf
64 cp $PCP_DIR/etc/pcp.conf $tmp.conf.backup
66 # simple testing script for LXC containers
67 cat >$tmp.test-lxc-info.sh <<EOF
68 #!/bin/bash
69 name="\$2"
70 test -d "\$PCP_LXC_DIR/\$name" || exit 0
71 echo "Name: \$name"
72 echo "State: RUNNING"
73 echo "PID: 17297"
74 echo "CPU use: 1.13 seconds"
75 EOF
76 chmod 755 $tmp.test-lxc-info.sh
77 export PCP_LXC_DIR=$root/var/lib/lxc
79 # real QA test starts here
80 $sudo $PCP_RC_DIR/pmcd stop | _filter_pcp_stop
81 echo >> $tmp.conf
82 echo "# from QA $seq ..." >> $tmp.conf
83 echo PCP_LXC_DIR=$root/var/lib/lxc >> $tmp.conf
84 echo PCP_LXC_INFO=$tmp.test-lxc-info.sh >> $tmp.conf
85 echo PCP_DOCKER_DIR=$root/var/lib/docker >> $tmp.conf
86 echo PCP_SYSTEMD_CGROUP=/tmp >> $tmp.conf
87 $sudo cp $tmp.conf $PCP_DIR/etc/pcp.conf
88 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
89 _wait_for_pmcd
91 echo "=== Checking empty containers configuration, no values"
92 pmprobe -v containers | LC_COLLATE=POSIX sort
93 echo "== done" && echo
95 tarballs=`echo $here/linux/containers-*.tgz | LC_COLLATE=POSIX sort`
96 for tgz in $tarballs
98 $sudo rm -fr $root
99 mkdir $root || _fail "root in use when processing $tgz"
100 cd $root
101 $sudo tar xzf $tgz
102 base=`basename $tgz`
104 echo "== Checking values for active containers"
105 _check
106 echo && echo "== done" && echo
107 cd $here
108 done
110 # success, all done
111 status=0
112 exit