forked from MetPX/sarracenia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sr_subscribe.sh
executable file
·302 lines (241 loc) · 7.02 KB
/
test_sr_subscribe.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/bin/ksh
SARRA_PATH=/usr/bin
SR_SUBSCRIBE=${SARRA_PATH}/sr_subscribe
mkdir /tmp/sr_sarra
cd /tmp/sr_sarra
echo killall ${SR_SUBSCRIBE##.*/}
killall ${SR_SUBSCRIBE##.*/} > /dev/null 2>&1
rm ./sr_susbscribe*.log ./toto* ./test/t* ./subscribe_test1.conf > /dev/null 2>&1
rmdir ./test > /dev/null 2>&1
cat << EOF > toto
0 123456789abcde
1 123456789abcde
2 123456789abcde
3 123456789abcde
4 123456789abcde
5 123456789abcde
6 123456789abcde
7 123456
89abcde
8 123456789abcde
9 123456789abcde
a 123456789abcde
b 123456789abcde
c 123456789abcde
d 123456789abcde
e 123456789abcde
EOF
cat << EOF > toto.p0
0 123456789abcde
1 123456789abcde
2 123456789abcde
3 123456789abcde
4 123456789abcde
5 123456789abcde
6 123456789abcde
7 123456
EOF
cat << EOF > toto.p1
89abcde
8 123456789abcde
9 123456789abcde
a 123456789abcde
b 123456789abcde
c 123456789abcde
d 123456789abcde
e 123456789abcde
EOF
# published files
cp toto /var/www/test/toto
cp toto /apps/px/test/toto
cp toto.p0 toto.128.2.0.0.d.Part
cp toto.p0 /var/www/test/toto.128.2.0.0.d.Part
cp toto.p0 /apps/px/test/toto.128.2.0.0.d.Part
cp toto.p1 toto.128.2.0.1.d.Part
cp toto.p1 /var/www/test/toto.128.2.0.1.d.Part
cp toto.p1 /apps/px/test/toto.128.2.0.1.d.Part
chmod 666 toto* /var/www/test/toto* /apps/px/test/toto*
cat << EOF > subscribe_test.conf
broker amqp://tsource@localhost/
exchange xs_tsource
topic_prefix v02.post
subtopic #
directory ${PWD}/test
accept .*
expire 300
EOF
mkdir ./test
rm ./.*.queue
function test1 {
echo -n "sr_post -b amqp://tsource@localhost/ -dr /var/www -p test/toto -u http://localhost/ -to alta ... "
$SR_SUBSCRIBE $* start > ./sr_subscribe_test1.log 2>&1 &
sleep 5
${SARRA_PATH}/sr_post -b amqp://tsource@localhost/ \
-p /var/www/test/toto \
-u sftp://vagrant@localhost \
-to alta > /dev/null 2>&1 \
/
}
# Define test functions
function test2 {
echo -n "sr_post -b amqp://tsource@localhost/ -dr /var/www -p test/toto -u http://localhost/ -to alta ... "
$SR_SUBSCRIBE $* start > ./sr_subscribe_test2.log 2>&1 &
sleep 5
#======== 1
${SARRA_PATH}/sr_post -b amqp://tsource@localhost/ \
-dr /var/www/ \
-p test/toto \
-u http://localhost/ \
-to alta > /dev/null 2>&1 \
/
sleep 5
touch ./test/test_no_4
DIFF=`diff toto ./test/toto`
if [[ $? != 0 ]]; then
N=-1
else
N=`diff toto ./test/toto|wc -l`
fi
if ((N==0)) ; then
echo OK
else
echo FAILED
exit 1
fi
rm ./test/*
#parts I
#======== 2
echo -n "sr_post -b amqp://tsource@localhost/ -dr /var/www -p test/toto -u http://localhost/test/toto --parts i,128 -to alta ... "
${SARRA_PATH}/sr_post -b amqp://tsource@localhost \
-dr /var/www \
-p test/toto \
-u http://localhost/ \
--parts i,128 \
-to alta > /dev/null 2>&1 \
/
sleep 5
touch ./test/test_no_5
DIFF=`diff toto ./test/toto`
if [[ $? != 0 ]]; then
N=-1
else
N=`diff toto ./test/toto|wc -l`
fi
if ((N==0)) ; then
echo OK
else
echo FAILED
exit 1
fi
rm ./test/*
#parts P
#======== 2
echo -n "sr_post -b amqp://tsource@localhost/ -dr /var/www -p test/toto.128.2.0.*.d.Part -u http://localhost/ -to alta ... "
${SARRA_PATH}/sr_post -b amqp://tsource@localhost/ \
-dr /var/www \
-p test/toto.128.2.0.1.d.Part \
-u http://localhost/ \
--parts p \
-to alta > /dev/null 2>&1 \
/
${SARRA_PATH}/sr_post -b amqp://tsource@localhost/ \
-dr /var/www \
-p test/toto.128.2.0.0.d.Part \
-u http://localhost/ \
--parts p \
-to alta > /dev/null 2>&1 \
/
sleep 5
touch ./test/test_no_6
DIFF=`diff toto ./test/toto`
if [[ $? != 0 ]]; then
N=-1
else
N=`diff toto ./test/toto|wc -l`
fi
if ((N==0)) ; then
echo OK
else
echo FAILED
exit 1
fi
rm ./test/*
# killall ${SR_SUBSCRIBE##.*/}
$SR_SUBSCRIBE $* stop >> ./sr_subscribe_test2.log 2>&1 &
}
function test4 {
echo -n "http instances/inserts ... "
$SR_SUBSCRIBE $* start > ./sr_subscribe_test4.log 2>&1 &
sleep 10
${SARRA_PATH}/sr_post -b amqp://tsource@localhost \
-dr /var/www \
-p test/toto \
-u http://localhost/ \
--parts i,1 -r \
-to alta > /dev/null 2>&1 \
/
sleep 30
touch ./test/test_no_8
DIFF=`diff toto ./test/toto`
if [[ $? != 0 ]]; then
N=-1
else
N=`diff toto ./test/toto|wc -l`
fi
if ((N==0)) ; then
echo OK
else
echo FAILED
exit 1
fi
rm ./test/*
sleep 10
# killall ${SR_SUBSCRIBE##.*/}
$SR_SUBSCRIBE $* stop >> ./sr_subscribe_test4.log 2>&1 &
}
function test5 {
echo "http inserts and truncated ... "
$SR_SUBSCRIBE $* start > ./sr_subscribe_test5.log 2>&1 &
sleep 10
cat toto | sed 's/12345/abcde/' > ./test/toto
echo abc >> ./test/toto
${SARRA_PATH}/sr_post -b amqp://tsource@localhost/ \
-dr /var/www \
-p test/toto \
-u http://localhost/ \
--parts i,11 -r \
-to alta > /dev/null 2>&1 \
/
sleep 30
touch ./test/test_no_9
DIFF=`diff toto ./test/toto`
if [[ $? != 0 ]]; then
N=-1
else
N=`diff toto ./test/toto|wc -l`
fi
if ((N==0)) ; then
echo OK
else
echo FAILED
exit 1
fi
rm ./test/toto*
sleep 10
# killall ${SR_SUBSCRIBE##.*/}
$SR_SUBSCRIBE $* stop >> ./sr_subscribe_test5.log 2>&1 &
}
# Run tests
echo
echo "* Running INPLACE test suite:"
test2 ./subscribe_test.conf
echo
echo "* Running INSTANCES AND INSERTS test suite:"
test4 ./subscribe_test.conf
echo
echo "* Running INSTANCES AND INSERTS AND TRUNCATE test suite:"
test5 ./subscribe_test.conf
rm ./sr_subscribe_*.log ./.*ubscribe_* ./toto* ./test/t* ./subscribe_tes*.conf > /dev/null 2>&1
rmdir ./test > /dev/null 2>&1
rm -rf /tmp/sr_sarra
exit 0