5 # Copyright (c) 2015 Red Hat
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 which socat
>/dev
/null
2>&1 || _notrun
"socat binary not installed"
18 port2
=55432 # just some random port
19 port1
=55431 # just some random port
20 echo |
$PCP_BINADM_DIR/telnet-probe localhost
$port1 \
21 && _notrun
"Someone already listening on port $port1"
22 echo |
$PCP_BINADM_DIR/telnet-probe localhost
$port2 \
23 && _notrun
"Someone already listening on port $port2"
24 # (technically, this is a TOCTTOU race condition)
27 status
=1 # failure is the default!
28 $sudo rm -rf $tmp.
* $seq.full
30 signal
=$PCP_BINADM_DIR/pmsignal
34 [ -z "$pmcd_pid" ] || sudo
$signal $pmcd_pid
35 [ -z "$socat_pid" ] || sudo
$signal $socat_pid
36 $sudo $PCP_RC_DIR/pmcd restart | _filter_pcp_start
38 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # ditch timestamps and exact hostnames
45 sed -e 's/^\[.*\]/[TIMESTAMP]/' |
46 sed -e 's/'$hostname'/HOSTNAME/'
51 # real QA test starts here
53 # We use socat to create a loopback proxy for pmcd on some oddball
54 # port, and have pmie be forced to talk to it there. The idea is that
55 # if pmie were to still use the host-name as a pmNewContext attempt,
56 # it will fail (since there won't be a pmcd there).
58 # see also qa/283 for "pmcd -p" testing.
59 $sudo $PCP_RC_DIR/pmcd stop
>/dev
/null
2>&1
60 # allow time to cleanup and close all sockets
66 echo "=== starting pmcd on port $port1 ===" |
tee -a $seq.full
70 $PCP_PMCD_PROG -f -l $tmp.log -p $port1 &
74 # Filter the stderr of this using a temp file
75 pmcd_pid
=`$sudo sh $tmp.sh 2>$tmp.tmp`
80 echo "=== starting socat on port $port2 ===" |
tee -a $seq.full
82 # Filter the stderr of this using a temp file
83 socat
-d -d TCP-LISTEN
:$port2,fork TCP
:localhost
:$port1 2>$tmp.socat
&
89 (sample.load > 40) -> print "found the meaning of %h %c %v";
93 for port
in $port2 $port1 44321 # the latter will fail
95 echo "=== running pmie via $port ===" |
tee -a $seq.full
96 pmie
-f -h localhost
:$port -c $tmp.pmie
-T 5s
> $tmp.out
2>&1
97 cat $tmp.out
>> $seq.full
98 cat $tmp.out | _filter_pmie
99 #(echo f $tmp.pmie; echo l; echo r 5s) | pmie -d -f -h localhost:$port | _filter_pmie
104 echo "pmie log" >> $seq.full
105 cat $tmp.log
>> $seq.full
106 echo "socat log" >> $seq.full
107 cat $tmp.socat
>> $seq.full