/
issue-MB-2972.sh
executable file
·116 lines (90 loc) · 2.96 KB
/
issue-MB-2972.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
#!/bin/sh
echo starting memcached simulant
./moxi -d -P /tmp/moxi-2972-test-memcached.pid -p 11277
( cat << EOF
HTTP/1.0 200 OK
{"name":"",
"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
) | nc -l 22100 &
echo starting moxi
./moxi -d -P /tmp/moxi-2972-test-moxi.pid \
-z http://127.0.0.1:22100/test \
-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
sleep 1
date
echo client request 0 - ensure moxi has started
echo incr a 0 | nc 127.0.0.1 11266
date
echo stopping memcached simulant...
kill -STOP `cat /tmp/moxi-2972-test-memcached.pid`
sleep 1
echo client request 1 - attempt get when memcached is down
echo get 1 | nc 127.0.0.1 11266 > /tmp/moxi-2972.out
if ! (echo "SERVER_ERROR proxy downstream timeout\r" | diff - /tmp/moxi-2972.out); then \
echo FAIL - did not get expected SERVER_ERROR
killall moxi
exit -1
fi
echo OK - got the expected SERVER_ERROR
killall moxi
echo ----------------------------------
( cat << EOF
HTTP/1.0 200 OK
{"name":"",
"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
) | nc -l 22100 &
echo starting moxi
./moxi -d -P /tmp/moxi-2972-test-moxi.pid \
-z http://127.0.0.1:22100/test \
-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
sleep 1
echo client request 2 - attempt get when memcached is down
echo get 1 | nc 127.0.0.1 11266 > /tmp/moxi-2972.out
if ! (echo "SERVER_ERROR proxy write to downstream 127.0.0.1\r" | diff - /tmp/moxi-2972.out); then \
echo FAIL - did not get expected SERVER_ERROR
killall moxi
exit -1
fi
echo OK - got the expected SERVER_ERROR
killall moxi
echo ----------------------------------
echo starting moxi
./moxi -d -P /tmp/moxi-2972-test-moxi.pid \
-z 11266=127.0.0.1:11277 \
-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
sleep 1
echo client request 1 - attempt get when memcached is down
echo get 1 | nc 127.0.0.1 11266 > /tmp/moxi-2972.out
if ! (echo "END\r" | diff - /tmp/moxi-2972.out); then \
echo FAIL - did not get expected END
killall moxi
exit -1
fi
echo OK - got the expected END
killall moxi