fix graceful restart test

This commit is contained in:
clowwindy 2015-08-02 15:12:41 +08:00
parent b28de8e2f1
commit 177c639b19
3 changed files with 5 additions and 4 deletions

View file

@ -274,11 +274,11 @@ class UDPRelay(object):
def handle_periodic(self): def handle_periodic(self):
if self._closed: if self._closed:
if self._server_socket: if self._server_socket:
logging.info('closed UDP port %d', self._listen_port)
self._server_socket.close() self._server_socket.close()
self._server_socket = None self._server_socket = None
for sock in self._sockets: for sock in self._sockets:
sock.close() sock.close()
logging.info('closed UDP port %d', self._listen_port)
self._cache.sweep() self._cache.sweep()
self._client_fd_to_server_addr.sweep() self._client_fd_to_server_addr.sweep()

View file

@ -1,6 +1,6 @@
{ {
"server":"127.0.0.1", "server":"127.0.0.1",
"server_port":8387, "server_port":8388,
"local_port":1081, "local_port":1081,
"password":"aes_password", "password":"aes_password",
"timeout":15, "timeout":15,

View file

@ -23,6 +23,7 @@ sleep 1
# graceful restart server: send SIGQUIT to old process and start a new one # graceful restart server: send SIGQUIT to old process and start a new one
kill -s SIGQUIT $SERVER kill -s SIGQUIT $SERVER
sleep 0.5
$PYTHON shadowsocks/server.py -c tests/graceful.json --forbidden-ip "" & $PYTHON shadowsocks/server.py -c tests/graceful.json --forbidden-ip "" &
NEWSERVER=$! NEWSERVER=$!
@ -37,7 +38,7 @@ echo old server running: $OLD_SERVER_RUNNING1
sleep 1 sleep 1
# close connections on old server # close connections on old server
kill -s SIGINT $GCLI kill -s SIGKILL $GCLI
kill -s SIGKILL $GSERVER kill -s SIGKILL $GSERVER
kill -s SIGINT $LOCAL kill -s SIGINT $LOCAL
@ -49,6 +50,7 @@ OLD_SERVER_RUNNING2=$?
# old server should quit at this moment # old server should quit at this moment
echo old server running: $OLD_SERVER_RUNNING2 echo old server running: $OLD_SERVER_RUNNING2
kill -s SIGINT $SERVER
# new server is expected running # new server is expected running
kill -s SIGINT $NEWSERVER || exit 1 kill -s SIGINT $NEWSERVER || exit 1
@ -57,7 +59,6 @@ if [ $OLD_SERVER_RUNNING1 -ne 0 ]; then
fi fi
if [ $OLD_SERVER_RUNNING2 -ne 1 ]; then if [ $OLD_SERVER_RUNNING2 -ne 1 ]; then
kill -s SIGINT $SERVER
sleep 1 sleep 1
exit 1 exit 1
fi fi