File: 808

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 (142 lines) | stat: -rwxr-xr-x 3,936 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
140
141
142
#!/bin/sh
# PCP QA Test No. 808
# exercise pmlogger stale pid files issues
#
# Copyright (c) 2015 Red Hat.  All Rights Reserved.
# Copyright (c) 2015 Mark Goodwin.  All Rights Reserved.
#

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

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

_cleanup()
{
    cd $here
    if [ -n "$pid" ]
    then
	$sudo rm -f $PCP_TMP_DIR/pmlogger/$pid $PCP_RUN_DIR/pmlogger.$pid.socket
    fi
    $sudo rm -f $PCP_RUN_DIR/pmlogger.pid
    _restore_auto_restart pmlogger
    _service pmlogger restart | _filter_pcp_restart

    if $pmproxy_was_running
    then
	# pmproxy needs a chance to get stable ... otherwise we may see
	# badness in the PMNS for the pmproxy.* metrics if check's callback
	# checks the PMNS .. seen on vm11 (Debian 11.1)
	#
	echo "Restart pmproxy ..." >>$seq_full
	_service pmproxy restart >>$seq_full 2>&1
	_wait_for_pmproxy
    fi

    rm -rf $tmp.*
}

status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

_stop_auto_restart pmlogger

pmproxy_was_running=false
[ -f $PCP_RUN_DIR/pmproxy.pid ] && pmproxy_was_running=true
echo "pmproxy_was_running=$pmproxy_was_running" >>$seq_full

# real QA test starts here

pid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep '[ /][p]mlogger.*-P' | \
grep -v grep | awk '{print $2}'`

if [ ! -S "$PCP_RUN_DIR/pmlogger.$pid.socket" ]; then
    echo FAIL no primary pmlogger running? pid=$pid
    status=1
else
    echo found primary pmlogger and found control socket in PCP_RUN_DIR

    echo === killing the primary pmlogger with SIGKILL ===
    $sudo kill -9 $pid
    for i in 1 2 3 4 5
    do
	$sudo kill -0 $pid >/dev/null 2>&1 || break
	sleep 1
    done
    $sudo kill -0 $pid >/dev/null 2>&1 && echo "Arrggh, pid $pid won't die!"

    echo === restart primary logger ===
    if ! _service pmlogger start; then _exit 1; fi \
    | _filter_pcp_start
    _wait_for_pmlogger || _exit 1

    newpid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep '/[p]mlogger.*-P' | \
	grep -v grep | awk '{print $2}'`

    if [ -z "$newpid" ]; then
    	echo FAIL pmlogger failed to start 
	echo pid of killed primary logger is $pid
	echo === ls -l $PCP_RUN_DIR ===
	ls -l $PCP_RUN_DIR
	status=1
	exit
    fi

    # cleanup from SIGKILL
    #
    $sudo rm -f $PCP_TMP_DIR/pmlogger/$pid $PCP_RUN_DIR/pmlogger.pid $PCP_RUN_DIR/pmlogger.$pid.socket


#
# Next test: check primary logger restarts with legacy hardlinks present
# This is a corner case, but can happen.
#
    pid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep '/[p]mlogger.*-P' | \
    grep -v grep | awk '{print $2}'`

    echo === checking with stale legacy hard links
    echo === killing the primary pmlogger with SIGKILL ===
    $sudo kill -9 $pid
    for i in 1 2 3 4 5
    do
	$sudo kill -0 $pid >/dev/null 2>&1 || break
	sleep 1
    done
    $sudo kill -0 $pid >/dev/null 2>&1 && echo "Arrggh, pid $pid won't die!"

    # change the stale symlinks into hardlinks, to simulate an upgrade
    # from an earlier version of pcp (before we converted to symlinks)
    $sudo rm -f $PCP_TMP_DIR/pmlogger/primary
    $sudo ln $PCP_TMP_DIR/pmlogger/$pid $PCP_TMP_DIR/pmlogger/primary
    $sudo rm -f $PCP_RUN_DIR/pmlogger.primary.socket
    $sudo ln $PCP_RUN_DIR/pmlogger.$pid.socket $PCP_RUN_DIR/pmlogger.primary.socket

    echo === restart primary logger ===
    if ! _service pmlogger start; then _exit 1; fi \
    | _filter_pcp_start
    _wait_for_pmlogger || _exit 1

    newpid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep '/[p]mlogger.*-P' | \
	grep -v grep | awk '{print $2}'`

    if [ -z "$newpid" ]; then
    	echo FAIL pmlogger failed to start 
	echo pid of killed primary logger is $pid
	echo === ls -il $PCP_RUN_DIR ===
	ls -il $PCP_RUN_DIR
	status=1
	exit
    fi

    # cleanup from SIGKILL
    #
    $sudo rm -f $PCP_TMP_DIR/pmlogger/$pid $PCP_RUN_DIR/pmlogger.pid $PCP_RUN_DIR/pmlogger.$pid.socket

    # success
    status=0
fi

exit