Commit ef477a10 authored by Julien Muchembled's avatar Julien Muchembled

tests: do not copy & paste default values for timeout/delay in expectXxx methods

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2672 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 75cd5ecb
...@@ -511,57 +511,55 @@ class NEOCluster(object): ...@@ -511,57 +511,55 @@ class NEOCluster(object):
raise AssertionError, 'Timeout while expecting condition. ' \ raise AssertionError, 'Timeout while expecting condition. ' \
'History: %s' % (opaque_history, ) 'History: %s' % (opaque_history, )
def expectAllMasters(self, node_count, state=None, timeout=0, delay=1): def expectAllMasters(self, node_count, state=None, *args, **kw):
def callback(last_try): def callback(last_try):
current_try = len(self.getMasterList(state=state)) current_try = len(self.getMasterList(state=state))
if last_try is not None and current_try < last_try: if last_try is not None and current_try < last_try:
raise AssertionError, 'Regression: %s became %s' % \ raise AssertionError, 'Regression: %s became %s' % \
(last_try, current_try) (last_try, current_try)
return (current_try == node_count, current_try) return (current_try == node_count, current_try)
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, *args, **kw)
def __expectNodeState(self, node_type, uuid, state, timeout=0, delay=1): def __expectNodeState(self, node_type, uuid, state, *args, **kw):
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.__getNodeState(node_type, 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, *args, **kw)
def expectMasterState(self, uuid, state, timeout=0, delay=1): def expectMasterState(self, uuid, state, *args, **kw):
self.__expectNodeState(NodeTypes.MASTER, uuid, state, timeout, self.__expectNodeState(NodeTypes.MASTER, uuid, state, *args, **kw)
delay)
def expectStorageState(self, uuid, state, timeout=0, delay=1): def expectStorageState(self, uuid, state, *args, **kw):
self.__expectNodeState(NodeTypes.STORAGE, uuid, state, self.__expectNodeState(NodeTypes.STORAGE, uuid, state, *args, **kw)
timeout, delay)
def expectRunning(self, process, timeout=0, delay=1): def expectRunning(self, process, *args, **kw):
self.expectStorageState(process.getUUID(), NodeStates.RUNNING, timeout, self.expectStorageState(process.getUUID(), NodeStates.RUNNING,
delay) *args, **kw)
def expectPending(self, process, timeout=0, delay=1): def expectPending(self, process, *args, **kw):
self.expectStorageState(process.getUUID(), NodeStates.PENDING, timeout, self.expectStorageState(process.getUUID(), NodeStates.PENDING,
delay) *args, **kw)
def expectUnknown(self, process, timeout=0, delay=1): def expectUnknown(self, process, *args, **kw):
self.expectStorageState(process.getUUID(), NodeStates.UNKNOWN, timeout, self.expectStorageState(process.getUUID(), NodeStates.UNKNOWN,
delay) *args, **kw)
def expectUnavailable(self, process, timeout=0, delay=1): def expectUnavailable(self, process, *args, **kw):
self.expectStorageState(process.getUUID(), self.expectStorageState(process.getUUID(),
NodeStates.TEMPORARILY_DOWN, timeout, delay) NodeStates.TEMPORARILY_DOWN, *args, **kw)
def expectPrimary(self, uuid=None, timeout=0, delay=1): def expectPrimary(self, uuid=None, *args, **kw):
def callback(last_try): def callback(last_try):
current_try = self.getPrimary() current_try = self.getPrimary()
if None not in (uuid, current_try) and uuid != current_try: if None not in (uuid, current_try) and uuid != current_try:
raise AssertionError, 'An unexpected primary arised: %r, ' \ raise AssertionError, 'An unexpected primary arised: %r, ' \
'expected %r' % (dump(current_try), dump(uuid)) 'expected %r' % (dump(current_try), dump(uuid))
return uuid is None or uuid == current_try, current_try return uuid is None or uuid == current_try, current_try
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, *args, **kw)
def expectOudatedCells(self, number, timeout=0, delay=1): def expectOudatedCells(self, number, *args, **kw):
def callback(last_try): def callback(last_try):
row_list = self.neoctl.getPartitionRowList()[1] row_list = self.neoctl.getPartitionRowList()[1]
number_of_oudated = 0 number_of_oudated = 0
...@@ -570,9 +568,9 @@ class NEOCluster(object): ...@@ -570,9 +568,9 @@ class NEOCluster(object):
if cell[1] == CellStates.OUT_OF_DATE: if cell[1] == CellStates.OUT_OF_DATE:
number_of_oudated += 1 number_of_oudated += 1
return number_of_oudated == number, number_of_oudated return number_of_oudated == number, number_of_oudated
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, *args, **kw)
def expectAssignedCells(self, process, number, timeout=0, delay=1): def expectAssignedCells(self, process, number, *args, **kw):
def callback(last_try): def callback(last_try):
row_list = self.neoctl.getPartitionRowList()[1] row_list = self.neoctl.getPartitionRowList()[1]
assigned_cells_number = 0 assigned_cells_number = 0
...@@ -581,30 +579,30 @@ class NEOCluster(object): ...@@ -581,30 +579,30 @@ class NEOCluster(object):
if cell[0] == process.getUUID(): if cell[0] == process.getUUID():
assigned_cells_number += 1 assigned_cells_number += 1
return assigned_cells_number == number, assigned_cells_number return assigned_cells_number == number, assigned_cells_number
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, *args, **kw)
def expectClusterState(self, state, timeout=0, delay=1): def expectClusterState(self, state, *args, **kw):
def callback(last_try): def callback(last_try):
current_try = self.neoctl.getClusterState() current_try = self.neoctl.getClusterState()
return current_try == state, current_try return current_try == state, current_try
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, *args, **kw)
def expectClusterRecovering(self, timeout=0, delay=1): def expectClusterRecovering(self, *args, **kw):
self.expectClusterState(ClusterStates.RECOVERING, timeout, delay) self.expectClusterState(ClusterStates.RECOVERING, *args, **kw)
def expectClusterVerifying(self, timeout=0, delay=1): def expectClusterVerifying(self, *args, **kw):
self.expectClusterState(ClusterStates.VERIFYING, timeout, delay) self.expectClusterState(ClusterStates.VERIFYING, *args, **kw)
def expectClusterRunning(self, timeout=0, delay=1): def expectClusterRunning(self, *args, **kw):
self.expectClusterState(ClusterStates.RUNNING, timeout, delay) self.expectClusterState(ClusterStates.RUNNING, *args, **kw)
def expectAlive(self, process, timeout=0, delay=1): def expectAlive(self, process, *args, **kw):
def callback(last_try): def callback(last_try):
current_try = process.isAlive() current_try = process.isAlive()
return current_try, current_try return current_try, current_try
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, *args, **kw)
def expectStorageNotKnown(self, process, timeout=0, delay=1): def expectStorageNotKnown(self, process, *args, **kw):
# /!\ Not Known != Unknown # /!\ Not Known != Unknown
process_uuid = process.getUUID() process_uuid = process.getUUID()
def expected_storage_not_known(last_try): def expected_storage_not_known(last_try):
...@@ -612,7 +610,7 @@ class NEOCluster(object): ...@@ -612,7 +610,7 @@ class NEOCluster(object):
if storage[2] == process_uuid: if storage[2] == process_uuid:
return False, storage return False, storage
return True, None return True, None
self.expectCondition(expected_storage_not_known, timeout, delay) self.expectCondition(expected_storage_not_known, *args, **kw)
def __del__(self): def __del__(self):
if self.cleanup_on_delete: if self.cleanup_on_delete:
......
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