File: 761

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (139 lines) | stat: -rwxr-xr-x 3,700 bytes parent folder | download
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
#!/bin/sh
# PCP QA Test No. 761
# Exercise the PMCD privileged co-process (root) PMDA
# Install, Remove and handling of different container
# engines container.* metrics.
#
# Copyright (c) 2014-2015 Red Hat.
#

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

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

case "$PCP_PLATFORM"
in
    linux)
    	;;
    *)
	_notrun "No container support for PCP_PLATFORM $PCP_PLATFORM"
	# NOTREACHED
	;;
esac


_get_libpcp_config
$unix_domain_sockets || _notrun "No unix domain socket support available"

root=$tmp.root
status=1	# failure is the default!

root_cleanup()
{
    cd $here
    [ -d $root ] && $sudo rm -fr $root
    [ -f $tmp.conf.backup ] && $sudo cp $tmp.conf.backup $PCP_DIR/etc/pcp.conf
    _restore_pmda_install root || _exit 1
    rm -f $here/$seq.test-lxc-info.sh
    rm -rf $tmp.* $tmp
}

# do metrics one at a time, map all internal instance ids to N and sort
# instance lines
#
_check()
{
    pminfo containers | LC_COLLATE=POSIX sort \
    | while read metric
    do
	pminfo -f $metric >$tmp.tmp
	grep -v ' inst \[' $tmp.tmp
	sed -n -e '/inst \[/s/\[[0-9][0-9]*/[N/p' $tmp.tmp \
	| LC_COLLATE=POSIX sort
    done
}

_prepare_pmda root containers
trap "root_cleanup; exit \$status" 0 1 2 3 15

# backup main PCP config
cp $PCP_DIR/etc/pcp.conf $tmp.conf
cp $PCP_DIR/etc/pcp.conf $tmp.conf.backup

# simple testing script for LXC containers
cat >$here/$seq.test-lxc-info.sh <<EOF
#!/bin/sh
name="\$2"
test -d "\$PCP_LXC_DIR/\$name" || exit 0
echo "Name:           \$name"
echo "State:          RUNNING"
echo "PID:            17297"
echo "CPU use:        1.13 seconds"
EOF
chmod 755 $here/$seq.test-lxc-info.sh
PCP_LXC_DIR=$root/var/lib/lxc; export PCP_LXC_DIR

# real QA test starts here
echo zero | tee -a $seq_full
if ! _service pmcd status >>$seq_full; then _exit 1; fi
# systemd needs may not have caught up with a previous stop
# and the stop that comes below can cause a
#	Job for pmcd.service canceled.
# message.  So sleep a little in the hope that this fixes it ...
#
sleep 2
if ! _service pmcd status >>$seq_full; then _exit 1; fi
echo one | tee -a $seq_full
if ! _service pmcd stop; then _exit 1; fi \
| _filter_pcp_stop
echo two | tee -a $seq_full
if ! _service pmcd status >>$seq_full; then _exit 1; fi
_wait_pmcd_end || _exit 1
echo three | tee -a $seq_full

echo >> $tmp.conf
echo "# from QA $seq ..." >> $tmp.conf
echo PCP_LXC_DIR=$root/var/lib/lxc >> $tmp.conf
echo PCP_LXC_INFO=$here/$seq.test-lxc-info.sh >> $tmp.conf
echo PCP_DOCKER_DIR=$root/var/lib/docker >> $tmp.conf
echo PCP_SYSTEMD_CGROUP=/system.slice >> $tmp.conf
echo PCP_PODMAN_RUNDIR=$root/var/run/containers >> $tmp.conf
echo PCP_PODMAN_DATADIR=$root/var/lib/containers >> $tmp.conf
$sudo cp $tmp.conf $PCP_DIR/etc/pcp.conf
if ! _service pmcd restart 2>&1; then _exit 1; fi \
| _filter_pcp_restart
_wait_for_pmcd || _exit 1
if ! _service pmlogger restart 2>&1; then _exit 1; fi \
| _filter_pcp_restart
_wait_for_pmlogger || _exit 1
echo four | tee -a $seq_full
if ! _service pmcd status >>$seq_full; then _exit 1; fi
_wait_for_pmcd || _exit 1
_wait_for_pmlogger || _exit 1

echo "=== Checking empty containers configuration, no values"
pmprobe -v containers | LC_COLLATE=POSIX sort
echo "== done" && echo

tarballs=`echo $here/linux/containers-*.tgz | LC_COLLATE=POSIX sort`
for tgz in $tarballs
do
    $sudo rm -fr $root
    mkdir $root || _fail "root in use when processing $tgz"
    cd $root
    $sudo tar xzf $tgz
    base=`basename $tgz`

    echo "== Checking values for active containers in $base"
    _check
    echo && echo "== done" && echo
    cd $here
done

# success, all done
status=0
exit