-
Notifications
You must be signed in to change notification settings - Fork 13
/
issue-MB-3575.sh
executable file
·248 lines (185 loc) · 5.86 KB
/
issue-MB-3575.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
#!/bin/bash
rm -f /tmp/issue-MB-3575.out*
( cat << EOF
HTTP/1.0 200 OK
This is just a bad response that is not JSON.
EOF
) | nc -l 22100 &
( cat << EOF
{ "buckets": [
{"name":"default",
"foo":"bar",
"saslPassword": "",
"bucketType":"membase",
"nodes":[
{"replication":0.0,"clusterMembership":"active","status":"healthy",
"hostname":"127.0.0.1:22100",
"ports":{"proxy":11266,"direct":11277}}
],
"nodeLocator":"vbucket",
"vBucketServerMap":{
"hashAlgorithm":"CRC","numReplicas":0,
"serverList":["127.0.0.1:11277"],
"vBucketMap":[[0]]
}
}
] }
EOF
) > /tmp/issue-MB-3575-good.cfg
ruby ./t/rest_mock.rb /tmp/issue-MB-3575-good.cfg &
sleep 1
echo starting moxi
./moxi \
-z http://127.0.0.1:22100/bad,http://127.0.0.1:4567/pools/default/bucketsStreaming/default \
-Z port_listen=11266,downstream_conn_max=1,downstream_max=0,downstream_timeout=300,wait_queue_timeout=300,downstream_conn_queue_timeout=300,connect_timeout=300,auth_timeout=300 2>> /tmp/issue-MB-3575.out &
sleep 1
echo OK
killall moxi
killall nc
ps | grep ruby | grep rest_mock.rb | cut -d ' ' -f 1 - | xargs kill -KILL
echo --------------- >> /tmp/issue-MB-3575.out
( cat << EOF
HTTP/1.0 200 OK
This is just a bad response that is not JSON.
EOF
) | nc -l 22100 &
( cat << EOF
{ "buckets": [
{"name":"default",
"foo":"bar",
"saslPassword": "",
"bucketType":"membase",
"nodes":[
{"replication":0.0,"clusterMembership":"active","status":"healthy",
"hostname":"127.0.0.1:22100",
"ports":{"proxy":11266,"direct":11277}}
],
"nodeLocator":"vbucket",
"vBucketServerMap":{
"hashAlgorithm":"CRC","numReplicas":0,
"serverList":["127.0.0.1:11277"],
"vBucketMap":[[0]]
}
}
] }
EOF
) > /tmp/issue-MB-3575-good.cfg
ruby ./t/rest_mock.rb /tmp/issue-MB-3575-good.cfg &
sleep 1
echo starting moxi
./moxi \
-z http://127.0.0.1:4567/pools/default/bucketsStreaming/default,http://127.0.0.1:22100/bad \
-Z port_listen=11266,downstream_conn_max=1,downstream_max=0,downstream_timeout=300,wait_queue_timeout=300,downstream_conn_queue_timeout=300,connect_timeout=300,auth_timeout=300 2>> /tmp/issue-MB-3575.out &
sleep 1
echo OK
killall moxi
killall nc
ps | grep ruby | grep rest_mock.rb | cut -d ' ' -f 1 - | xargs kill -KILL
echo --------------- >> /tmp/issue-MB-3575.out
( cat << EOF
HTTP/1.0 200 OK
This is just a bad response that is not JSON.
EOF
) | nc -l 22100 &
( cat << EOF
HTTP/1.0 200 OK
This is just a bad response that is not JSON.
EOF
) | nc -l 22101 &
( cat << EOF
{ "buckets": [
{"name":"default",
"foo":"bar",
"saslPassword": "",
"bucketType":"membase",
"nodes":[
{"replication":0.0,"clusterMembership":"active","status":"healthy",
"hostname":"127.0.0.1:22100",
"ports":{"proxy":11266,"direct":11277}}
],
"nodeLocator":"vbucket",
"vBucketServerMap":{
"hashAlgorithm":"CRC","numReplicas":0,
"serverList":["127.0.0.1:11277"],
"vBucketMap":[[0]]
}
}
] }
EOF
) > /tmp/issue-MB-3575-good.cfg
ruby ./t/rest_mock.rb /tmp/issue-MB-3575-good.cfg &
sleep 1
echo starting moxi
./moxi \
-z http://127.0.0.1:22100/bad,http://127.0.0.1:22101/bad,http://127.0.0.1:4567/pools/default/bucketsStreaming/default \
-Z port_listen=11266,downstream_conn_max=1,downstream_max=0,downstream_timeout=300,wait_queue_timeout=300,downstream_conn_queue_timeout=300,connect_timeout=300,auth_timeout=300 2>> /tmp/issue-MB-3575.out &
sleep 1
echo OK
killall moxi
killall nc
ps | grep ruby | grep rest_mock.rb | cut -d ' ' -f 1 - | xargs kill -KILL
echo --------------- >> /tmp/issue-MB-3575.out
( cat << EOF
HTTP/1.0 200 OK
This is just a bad response that is not JSON.
EOF
) | nc -l 22100 &
( cat << EOF
HTTP/1.0 200 OK
This is just a bad response that is not JSON.
EOF
) | nc -l 22101 &
( cat << EOF
{ "buckets": [
{"name":"default",
"foo":"bar",
"saslPassword": "",
"bucketType":"membase",
"nodes":[
{"replication":0.0,"clusterMembership":"active","status":"healthy",
"hostname":"127.0.0.1:22100",
"ports":{"proxy":11266,"direct":11277}}
],
"nodeLocator":"vbucket",
"vBucketServerMap":{
"hashAlgorithm":"CRC","numReplicas":0,
"serverList":["127.0.0.1:11277"],
"vBucketMap":[[0]]
}
}
] }
EOF
) > /tmp/issue-MB-3575-good.cfg
ruby ./t/rest_mock.rb /tmp/issue-MB-3575-good.cfg &
sleep 1
echo starting moxi
./moxi \
-z http://127.0.0.1:22100/bad,http://127.0.0.1:4567/pools/default/bucketsStreaming/default,http://127.0.0.1:22101/bad \
-Z port_listen=11266,downstream_conn_max=1,downstream_max=0,downstream_timeout=300,wait_queue_timeout=300,downstream_conn_queue_timeout=300,connect_timeout=300,auth_timeout=300 2>> /tmp/issue-MB-3575.out &
sleep 1
echo OK
killall moxi
killall nc
ps | grep ruby | grep rest_mock.rb | cut -d ' ' -f 1 - | xargs kill -KILL
echo ----------------------
cut -d ' ' -f 4- /tmp/issue-MB-3575.out > /tmp/issue-MB-3575.out2
count=$( (diff /tmp/issue-MB-3575.out2 - <<EOF
ERROR: parse JSON failed, from REST server: http://127.0.0.1:22100/bad, This is just a bad response that is not JSON.
ERROR: invalid, empty config from REST server http://127.0.0.1:4567/pools/default/bucketsStreaming/default
---------------
ERROR: invalid, empty config from REST server http://127.0.0.1:4567/pools/default/bucketsStreaming/default
---------------
ERROR: parse JSON failed, from REST server: http://127.0.0.1:22100/bad, This is just a bad response that is not JSON.
ERROR: parse JSON failed, from REST server: http://127.0.0.1:22101/bad, This is just a bad response that is not JSON.
ERROR: invalid, empty config from REST server http://127.0.0.1:4567/pools/default/bucketsStreaming/default
---------------
ERROR: parse JSON failed, from REST server: http://127.0.0.1:22100/bad, This is just a bad response that is not JSON.
ERROR: invalid, empty config from REST server http://127.0.0.1:4567/pools/default/bucketsStreaming/default
EOF
) | wc -l)
if [[ $count -ne 0 ]] ; then
echo "FAIL count expect 0, got $count"
exit 1
fi
echo
echo "OK - issue-MB-3575 fixed"