Commit 4b5ab029 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Genericize expectMasterState(), wait after a kill() in __del__.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1199 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d4fc6235
...@@ -119,6 +119,7 @@ class NEOProcess: ...@@ -119,6 +119,7 @@ class NEOProcess:
# If we get killed, kill subprocesses aswell. # If we get killed, kill subprocesses aswell.
try: try:
self.kill(signal.SIGKILL) self.kill(signal.SIGKILL)
self.wait()
except: except:
# We can ignore all exceptions at this point, since there is no # We can ignore all exceptions at this point, since there is no
# garanteed way to handle them (other objects we would depend on # garanteed way to handle them (other objects we would depend on
...@@ -333,8 +334,8 @@ class NEOCluster(object): ...@@ -333,8 +334,8 @@ class NEOCluster(object):
def getStorageNodeList(self, state=None): def getStorageNodeList(self, state=None):
return self.__getNodeList(protocol.STORAGE_NODE_TYPE, state) return self.__getNodeList(protocol.STORAGE_NODE_TYPE, state)
def getMasterNodeState(self, uuid): def __getNodeState(self, node_type, uuid):
node_list = self.getMasterNodeList() node_list = self.__getNodeList(node_type)
for node_type, address, node_uuid, state in node_list: for node_type, address, node_uuid, state in node_list:
if node_uuid == uuid: if node_uuid == uuid:
break break
...@@ -342,6 +343,9 @@ class NEOCluster(object): ...@@ -342,6 +343,9 @@ class NEOCluster(object):
state = None state = None
return state return state
def getMasterNodeState(self, uuid):
return self.__getNodeState(protocol.MASTER_NODE_TYPE, uuid)
def getPrimaryMaster(self): def getPrimaryMaster(self):
try: try:
current_try = self.neoctl.getPrimaryMaster() current_try = self.neoctl.getPrimaryMaster()
...@@ -373,14 +377,22 @@ class NEOCluster(object): ...@@ -373,14 +377,22 @@ class NEOCluster(object):
return (current_try == node_count, current_try) return (current_try == node_count, current_try)
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, timeout, delay)
def expectMasterState(self, uuid, state, timeout=0, delay=1): def __expectNodeState(self, node_type, uuid, state, timeout=0, delay=1):
if not isinstance(state, (tuple, list)): if not isinstance(state, (tuple, list)):
state = (state, ) state = (state, )
def callback(last_try): def callback(last_try):
current_try = self.getMasterNodeState(uuid) current_try = self.__getNodeState(node_type, uuid)
return current_try in state, current_try return current_try in state, current_try
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, timeout, delay)
def expectMasterState(self, uuid, state, timeout=0, delay=1):
self.__expectNodeState(protocol.MASTER_NODE_TYPE, uuid, state, timeout,
delay)
def expectStorageState(self, uuid, state, timeout=0, delay=1):
self.__expectNodeState(protocol.STORAGE_NODE_TYPE, uuid, state,
timeout,delay)
def expectPrimaryMaster(self, uuid=None, timeout=0, delay=1): def expectPrimaryMaster(self, uuid=None, timeout=0, delay=1):
def callback(last_try): def callback(last_try):
current_try = self.getPrimaryMaster() current_try = self.getPrimaryMaster()
......
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