-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_quick.sh
executable file
·196 lines (175 loc) · 4.99 KB
/
test_quick.sh
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/sh
#
# Copyright (c) 2011-2012 Kilian Klimek <kilian.klimek@googlemail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
UBER=${UBER:-./build/ubervisor}
if [ ! -x $UBER ]; then
echo $UBER not executable
exit 1
fi
ck0() {
MSG=$1
shift
RET=$1
shift
OUT=$1
shift
echo -n "$MSG..."
$@ > out 2> err
E=$?
if [ "$E" -eq "$RET" ]; then
if [ "$OUT" != "" ]; then
if [ "$OUT" = "$(cat out)" ]; then
echo ok
else
echo error
cat out
cat err
$UBER exit 2> /dev/null
exit 1
fi
else
echo ok
fi
else
echo Error: $E $RET
cat out
cat err
$UBER exit 2> /dev/null
exit 1
fi
rm -f out err
}
$UBER list > /dev/null 2> /dev/null
if [ "$?" = "0" ]; then
echo ubervisor appears to be running. aborting.
exit 1
fi
TMPDIR=`mktemp -d /tmp/uber_test_XXXX`
export UBERVISOR_SOCKET=$TMPDIR/socket
if [ -z "$TMPDIR" ]; then
echo failed to create TMDIR
exit 1
fi
st() {
$UBER update -s 2 tst
$UBER kill -s 9 tst > /dev/null
$UBER delete tst
}
ck0 server 0 '' $UBER server -d $TMPDIR -o /tmp/log
ck0 start 0 '' $UBER start tst /bin/sleep 10
ck0 delete 0 '' $UBER delete tst
ck0 list 0 '' $UBER list
ck0 'start -d' 0 '' $UBER start -d /tmp tst /bin/sleep 10
st
ck0 'start -i' 0 '' $UBER start -i 2 tst /bin/sleep 10
st
ck0 'start -o' 0 '' $UBER start -o $TMPDIR/bar tst /bin/sleep 10
st
ck0 'start -e' 0 '' $UBER start -e $TMPDIR/foo tst /bin/sleep 10
st
ck0 'start -k' 0 '' $UBER start -k 9 tst /bin/sleep 10
st
ck0 'start -s' 0 '' $UBER start -s 2 tst /bin/sleep 10
st
ck0 'start -s' 0 '' $UBER start -s start tst /bin/sleep 10
st
ck0 'start -s' 0 '' $UBER start -s stop tst /bin/sleep 10
st
ck0 'start -f' 0 '' $UBER start -f /bin/echo tst /bin/sleep 10
st
ck0 'start -H' 0 '' $UBER start -H /bin/echo tst /bin/sleep 10
st
ck0 start 0 '' $UBER start tst /bin/sleep 10
ck0 'update -o' 0 '' $UBER update -o $TMPDIR/x tst
ck0 'update -e' 0 '' $UBER update -e $TMPDIR/x2 tst
ck0 'update -d' 0 '' $UBER update -d /tmp tst
ck0 'update -k' 0 '' $UBER update -k 12 tst
ck0 'update -s stop' 0 '' $UBER update -s stop tst
ck0 'get -g' 0 '2' $UBER get -s tst
ck0 'update -s start' 0 '' $UBER update -s start tst
ck0 'get -g' 0 '1' $UBER get -s tst
ck0 'update -s 2' 0 '' $UBER update -s 2 tst
ck0 'update -i' 0 '' $UBER update -i 2 tst
ck0 'update -d' 0 '' $UBER update -d /tmp tst
ck0 'update -H' 0 '' $UBER update -H /bin/echo tst
ck0 'update -f' 0 '' $UBER update -f /bin/echo tst
ck0 kill 0 '' $UBER kill tst
ck0 kill_s 0 '' $UBER kill -s 9 tst
ck0 kill_i 0 '' $UBER kill -i 0 tst
ck0 'get -D' 0 '' $UBER get -D tst
ck0 'get -d' 0 '/tmp' $UBER get -d tst
ck0 'get -o' 0 "$TMPDIR/x" $UBER get -o tst
ck0 'get -e' 0 "$TMPDIR/x2" $UBER get -e tst
ck0 'get -u' 1 '' $UBER get -u tst
ck0 'get -g' 1 '' $UBER get -g tst
ck0 'get -s' 0 '2' $UBER get -s tst
ck0 'get -k' 0 '12' $UBER get -k tst
ck0 'get -H' 0 '/bin/echo' $UBER get -H tst
ck0 'get -f' 0 '/bin/echo' $UBER get -f tst
ck0 'get -i' 0 '2' $UBER get -i tst
ck0 delete 0 '' $UBER delete tst
ck0 delete 1 '' $UBER delete tst
ck0 start 0 '' $UBER start -d /tmp tst /bin/sleep 10
ck0 'get -d' 0 '' $UBER get -d tst
ck0 delete 0 '' $UBER delete tst
#ck0 exit 0 '' $UBER exit
UBERVISOR_RSH="$UBER proxy" $UBER exit
pgrep ubervisor
# test loading dumps
cat > $TMPDIR/test_dump1 << __EOF__
[
{'name': 'test',
'args': ["/bin/sleep", "2"]}
]
__EOF__
ck0 start 0 '' $UBER server -c $TMPDIR/test_dump1
ck0 get 0 '1' $UBER get -s test
ck0 dump 0 '' $UBER dump
$UBER exit
ck0 start 0 '' $UBER server -l
ck0 get 0 '1' $UBER get -s test
$UBER exit
TMPFILE=$TMPDIR/log0
$UBER server -o $TMPFILE 2> /dev/null
#
# test HUP handler
#
rm $TMPFILE
if [ -f $TMPFILE ]; then
echo 'err'
$UBER exit
exit 1
fi
killall -HUP ubervisor
if [ ! -f $TMPFILE ]; then
echo 'err'
$UBER exit
exit 1
fi
$UBER exit
rm -rf $TMPDIR