forked from cloudera/flume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-simple-dfo
executable file
·83 lines (65 loc) · 2.45 KB
/
test-simple-dfo
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
#!/usr/bin/env /bin/sh
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
####
# This test runs an agent in disk failover mode and verifies that a
# specific number of events were delivered. It expects that a node
# and master are running on the localhost
DIR=`dirname $0`/..
FLUME_HOME=${FLUME_HOME:-$DIR/flume-distribution/target/flume-*/flume*}
FLUME=${FLUME_HOME}/bin/flume
MASTER=localhost
NODE1=`hostname`
NODE2=`hostname`
FLUMELOGDIR=/tmp/test-dfo-`date +%Y%m%d-%H%M%S.%N`
# remove stale write-ahead or failover logs
rm -rf /tmp/flume/agent || { echo "Unable to delete $FLUMELOGDIR" ; exit 1 ; }
rm -rf $FLUMELOGDIR || { echo "Unable to delete $FLUMELOGDIR" ; exit 1 ; }
$FLUME shell <<EOF
connect $MASTER
# prespawn nodes on specified machines. If NODE1 and NODE2 are up,
# this avoids getting fails on logical nodes due to a node not having
# shown up
exec spawn $NODE1 collector
exec spawn $NODE2 node
# enough for two heartbeats, to get ips to master
exec noop 10000
## Setup an agent collector topology using autoBEChains.
exec config collector autoCollectorSource 'collectorSink("file://$FLUMELOGDIR","data",5000)'
exec config node 'asciisynth(500)' '{delay(200)=>autoDFOChain}'
## Wait for the node to become active, and then done.
waitForNodesActive 10000 node
waitForNodesDone 200000 node
## Yea! done.
exec decommission node
exec decommission collector
# waitForNodesDecommissioned
exec noop 5000
exec noop 5000
quit
EOF
if [ "$?" -ne 0 ] ; then
echo "flume shell script failed"; exit 1;
fi
sleep 5s
COUNT=`wc -l $FLUMELOGDIR/* | tail -1 | awk '{print $1}'`
echo count messages $COUNT
if [ "$COUNT" != 500 ] ; then
echo "FAIL"
exit -1
fi
echo "SUCCESS"
rm -rf $FLUMELOGDIR || { echo "test succeeded but failed to rm $FLUMELOGDIR" ; exit 1; }