Commit d112bfbd authored by Julien Muchembled's avatar Julien Muchembled

neoctl: do not wait forever if master disconnects

parent 57956ec9
...@@ -42,14 +42,10 @@ class CommandEventHandler(EventHandler): ...@@ -42,14 +42,10 @@ class CommandEventHandler(EventHandler):
super(CommandEventHandler, self).connectionFailed(conn) super(CommandEventHandler, self).connectionFailed(conn)
self.__disconnected() self.__disconnected()
def ack(self, conn, msg): def error(self, conn, code, message, **kw):
self.__respond((Packets.Error, ErrorCodes.ACK, msg)) if code == ErrorCodes.DENIED:
sys.exit(message)
def denied(self, conn, msg): self.__respond((Packets.Error, code, message))
sys.exit(msg)
def notReady(self, conn, msg):
self.__respond((Packets.Error, ErrorCodes.NOT_READY, msg))
def __answer(packet_type): def __answer(packet_type):
def answer(self, conn, *args): def answer(self, conn, *args):
......
...@@ -2856,6 +2856,15 @@ class Test(NEOThreadedTest): ...@@ -2856,6 +2856,15 @@ class Test(NEOThreadedTest):
self.assertRaises(SystemExit, cluster.neoctl.setClusterState, self.assertRaises(SystemExit, cluster.neoctl.setClusterState,
ClusterStates.STARTING_BACKUP) ClusterStates.STARTING_BACKUP)
@with_cluster()
def testNeoctlVsDisconnectingMaster(self, cluster):
def setClusterState(orig, conn, *args):
conn.close()
with Patch(cluster.master.administration_handler,
setClusterState=setClusterState):
self.assertRaises(RuntimeError, cluster.neoctl.setClusterState,
ClusterStates.STARTING_BACKUP)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment