Commit ff6459a9 authored by Vincent Pelletier's avatar Vincent Pelletier

Make __expectNotKnown generic as expectStorageNotKnown.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2210 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 4085633a
...@@ -503,6 +503,16 @@ class NEOCluster(object): ...@@ -503,6 +503,16 @@ class NEOCluster(object):
return current_try, current_try return current_try, current_try
self.expectCondition(callback, timeout, delay) self.expectCondition(callback, timeout, delay)
def expectStorageNotKnown(self, process, timeout=0, delay=1):
# /!\ Not Known != Unknown
process_uuid = process.getUUID()
def expected_storage_not_known(last_try):
for storage in self.getStorageList():
if storage[2] == process_uuid:
return False, storage
return True, None
self.expectCondition(expected_storage_not_known, timeout, delay)
def __del__(self): def __del__(self):
if self.cleanup_on_delete: if self.cleanup_on_delete:
os.removedirs(self.temp_dir) os.removedirs(self.temp_dir)
......
...@@ -130,16 +130,6 @@ class StorageTests(NEOFunctionalTest): ...@@ -130,16 +130,6 @@ class StorageTests(NEOFunctionalTest):
self.neo.expectStorageState(process.getUUID(), self.neo.expectStorageState(process.getUUID(),
NodeStates.TEMPORARILY_DOWN) NodeStates.TEMPORARILY_DOWN)
def __expectNotKnown(self, process):
# /!\ Not Known != Unknown
def expected_storage_not_known(last_try):
storage_list = self.neo.getStorageList()
for storage in storage_list:
if storage[2] == process.getUUID():
return False, storage
return True, None
self.neo.expectCondition(expected_storage_not_known)
def testReplicationWithoutBreak(self): def testReplicationWithoutBreak(self):
""" Start a cluster with two storage, one replicas, the two databasqes """ Start a cluster with two storage, one replicas, the two databasqes
must have the same content """ must have the same content """
...@@ -355,7 +345,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -355,7 +345,7 @@ class StorageTests(NEOFunctionalTest):
# ask neoctl to drop it # ask neoctl to drop it
self.neo.neoctl.dropNode(started[0].getUUID()) self.neo.neoctl.dropNode(started[0].getUUID())
self.__expectNotKnown(started[0]) self.neo.expectStorageNotKnown(started[0])
self.neo.expectAssignedCells(started[0], 0) self.neo.expectAssignedCells(started[0], 0)
self.neo.expectAssignedCells(started[1], 10) self.neo.expectAssignedCells(started[1], 10)
...@@ -367,7 +357,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -367,7 +357,7 @@ class StorageTests(NEOFunctionalTest):
(started, stopped) = self.__setup(storage_number=2, replicas=1, (started, stopped) = self.__setup(storage_number=2, replicas=1,
pending_number=1, partitions=10) pending_number=1, partitions=10)
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.__expectNotKnown(stopped[0]) self.neo.expectStorageNotKnown(stopped[0])
self.neo.expectOudatedCells(number=0) self.neo.expectOudatedCells(number=0)
# populate the cluster with some data # populate the cluster with some data
...@@ -402,7 +392,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -402,7 +392,7 @@ class StorageTests(NEOFunctionalTest):
# drop it from partition table # drop it from partition table
self.neo.neoctl.dropNode(started[0].getUUID()) self.neo.neoctl.dropNode(started[0].getUUID())
self.__expectNotKnown(started[0]) self.neo.expectStorageNotKnown(started[0])
self.__expectRunning(stopped[0]) self.__expectRunning(stopped[0])
self.neo.expectAssignedCells(started[0], 0) self.neo.expectAssignedCells(started[0], 0)
self.neo.expectAssignedCells(stopped[0], 10) self.neo.expectAssignedCells(stopped[0], 10)
...@@ -429,7 +419,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -429,7 +419,7 @@ class StorageTests(NEOFunctionalTest):
# drop one # drop one
self.neo.neoctl.dropNode(started[0].getUUID()) self.neo.neoctl.dropNode(started[0].getUUID())
self.__expectNotKnown(started[0]) self.neo.expectStorageNotKnown(started[0])
self.__expectRunning(started[1]) self.__expectRunning(started[1])
# wait for running storage to store new partition table # wait for running storage to store new partition table
...@@ -438,7 +428,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -438,7 +428,7 @@ class StorageTests(NEOFunctionalTest):
# restart all nodes except the dropped, it must not be known # restart all nodes except the dropped, it must not be known
self.neo.stop() self.neo.stop()
self.neo.start(except_storages=[started[0]]) self.neo.start(except_storages=[started[0]])
self.__expectNotKnown(started[0]) self.neo.expectStorageNotKnown(started[0])
self.__expectRunning(started[1]) self.__expectRunning(started[1])
# then restart it, it must be in pending state # then restart it, it must be in pending state
...@@ -453,7 +443,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -453,7 +443,7 @@ class StorageTests(NEOFunctionalTest):
pending_number=1, partitions=10) pending_number=1, partitions=10)
# start without storage # start without storage
self.neo.expectClusterRecovering() self.neo.expectClusterRecovering()
self.__expectNotKnown(stopped[0]) self.neo.expectStorageNotKnown(stopped[0])
# start the empty storage, it must be accepted # start the empty storage, it must be accepted
stopped[0].start(with_uuid=False) stopped[0].start(with_uuid=False)
self.neo.expectClusterRunning() self.neo.expectClusterRunning()
...@@ -466,7 +456,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -466,7 +456,7 @@ class StorageTests(NEOFunctionalTest):
(started, stopped) = self.__setup(storage_number=2, replicas=1, (started, stopped) = self.__setup(storage_number=2, replicas=1,
pending_number=1, partitions=10) pending_number=1, partitions=10)
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.__expectNotKnown(stopped[0]) self.neo.expectStorageNotKnown(stopped[0])
self.neo.expectOudatedCells(number=0) self.neo.expectOudatedCells(number=0)
self.neo.expectClusterRunning() self.neo.expectClusterRunning()
...@@ -474,7 +464,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -474,7 +464,7 @@ class StorageTests(NEOFunctionalTest):
stopped[0].start() stopped[0].start()
self.__expectPending(stopped[0]) self.__expectPending(stopped[0])
self.neo.neoctl.dropNode(started[0].getUUID()) self.neo.neoctl.dropNode(started[0].getUUID())
self.__expectNotKnown(started[0]) self.neo.expectStorageNotKnown(started[0])
self.__expectPending(stopped[0]) self.__expectPending(stopped[0])
def testRestartWithMissingStorage(self): def testRestartWithMissingStorage(self):
......
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