Commit 88fd3dd4 authored by Grégory Wisniewski's avatar Grégory Wisniewski

More checks on functionals tests for storage and cluster part. Cluster tests

reuse methods defined in NEOFunctionalTest class.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1267 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent aa8c2628
...@@ -21,46 +21,47 @@ from neo import protocol ...@@ -21,46 +21,47 @@ from neo import protocol
class ClusterTests(NEOFunctionalTest): class ClusterTests(NEOFunctionalTest):
def setUp(self):
self.neo = None
def tearDown(self):
if self.neo is not None:
self.neo.stop()
def testClusterBreaks(self): def testClusterBreaks(self):
neo = NEOCluster(['test_neo1'], port_base=20000, master_node_count=1, self.neo = NEOCluster(['test_neo1'], port_base=20000,
temp_dir=self.getTempDirectory()) master_node_count=1, temp_dir=self.getTempDirectory())
neoctl = neo.getNEOCTL() neoctl = self.neo.getNEOCTL()
neo.setupDB() self.neo.setupDB()
neo.start() self.neo.start()
try: self.neo.expectClusterRunning()
self.assertEqual(neoctl.getClusterState(), protocol.RUNNING_CLUSTER_STATE) self.neo.expectOudatedCells(number=0)
neo.killStorage() self.neo.killStorage()
neo.expectClusterState(protocol.VERIFYING_CLUSTER_STATE) self.neo.expectClusterVeryfing()
finally:
neo.stop()
def testClusterBreaksWithTwoNodes(self): def testClusterBreaksWithTwoNodes(self):
neo = NEOCluster(['test_neo1', 'test_neo2'], port_base=20000, self.neo = NEOCluster(['test_neo1', 'test_neo2'], port_base=20000,
partitions=2, master_node_count=1, partitions=2, master_node_count=1, replicas=0,
temp_dir=self.getTempDirectory()) temp_dir=self.getTempDirectory())
neoctl = neo.getNEOCTL() neoctl = self.neo.getNEOCTL()
neo.setupDB() self.neo.setupDB()
neo.start() self.neo.start()
try: self.neo.expectClusterRunning()
self.assertEqual(neoctl.getClusterState(), protocol.RUNNING_CLUSTER_STATE) self.neo.expectOudatedCells(number=0)
neo.killStorage() self.neo.killStorage()
neo.expectClusterState(protocol.VERIFYING_CLUSTER_STATE) self.neo.expectClusterVeryfing()
finally:
neo.stop()
def testClusterDoesntBreakWithTwoNodesOneReplica(self): def testClusterDoesntBreakWithTwoNodesOneReplica(self):
neo = NEOCluster(['test_neo1', 'test_neo2'], port_base=20000, self.neo = NEOCluster(['test_neo1', 'test_neo2'], port_base=20000,
partitions=2, replicas=1, master_node_count=1, partitions=2, replicas=1, master_node_count=1,
temp_dir=self.getTempDirectory()) temp_dir=self.getTempDirectory())
neoctl = neo.getNEOCTL() neoctl = self.neo.getNEOCTL()
neo.setupDB() self.neo.setupDB()
neo.start() self.neo.start()
try: self.neo.expectClusterRunning()
self.assertEqual(neoctl.getClusterState(), protocol.RUNNING_CLUSTER_STATE) self.neo.expectOudatedCells(number=0)
neo.killStorage() self.neo.killStorage()
neo.expectClusterState(protocol.RUNNING_CLUSTER_STATE) self.neo.expectClusterRunning()
finally:
neo.stop()
def test_suite(): def test_suite():
return unittest.makeSuite(ClusterTests) return unittest.makeSuite(ClusterTests)
......
...@@ -132,6 +132,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -132,6 +132,7 @@ class StorageTests(NEOFunctionalTest):
# populate the cluster then check the databases # populate the cluster then check the databases
self.__setup(storage_number=2, replicas=1) self.__setup(storage_number=2, replicas=1)
self.neo.expectOudatedCells(number=0)
self.__populate() self.__populate()
self.__checkReplicationDone() self.__checkReplicationDone()
...@@ -162,6 +163,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -162,6 +163,7 @@ class StorageTests(NEOFunctionalTest):
processes = self.__setup(storage_number=2, replicas=1, pending_number=1, processes = self.__setup(storage_number=2, replicas=1, pending_number=1,
partitions=10) partitions=10)
started, stopped = processes started, stopped = processes
self.neo.expectOudatedCells(number=0)
self.__populate() self.__populate()
self.neo.expectClusterRunning() self.neo.expectClusterRunning()
self.neo.expectAssignedCells(started[0].getUUID(), number=10) self.neo.expectAssignedCells(started[0].getUUID(), number=10)
...@@ -187,6 +189,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -187,6 +189,7 @@ class StorageTests(NEOFunctionalTest):
# populate the two storages # populate the two storages
(started, _) = self.__setup(storage_number=2, replicas=1) (started, _) = self.__setup(storage_number=2, replicas=1)
self.neo.expectOudatedCells(number=0)
self.__populate() self.__populate()
self.__checkReplicationDone() self.__checkReplicationDone()
self.neo.expectClusterRunning() self.neo.expectClusterRunning()
...@@ -204,6 +207,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -204,6 +207,7 @@ class StorageTests(NEOFunctionalTest):
# start neo with one storages # start neo with one storages
(started, _) = self.__setup(replicas=0, storage_number=1) (started, _) = self.__setup(replicas=0, storage_number=1)
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.neo.expectOudatedCells(number=0)
# stop it, the cluster must switch to verification # stop it, the cluster must switch to verification
started[0].stop() started[0].stop()
...@@ -259,10 +263,12 @@ class StorageTests(NEOFunctionalTest): ...@@ -259,10 +263,12 @@ class StorageTests(NEOFunctionalTest):
(started, stopped) = self.__setup(storage_number=2, pending_number=1) (started, stopped) = self.__setup(storage_number=2, pending_number=1)
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.neo.expectClusterRunning() self.neo.expectClusterRunning()
self.neo.expectOudatedCells(number=0)
# start the second with the same UUID as the first # start the second with the same UUID as the first
stopped[0].setUUID(started[0].getUUID()) stopped[0].setUUID(started[0].getUUID())
stopped[0].start() stopped[0].start()
self.neo.expectOudatedCells(number=0)
# check the first and the cluster are still running # check the first and the cluster are still running
self.__expectRunning(started[0]) self.__expectRunning(started[0])
...@@ -284,6 +290,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -284,6 +290,7 @@ class StorageTests(NEOFunctionalTest):
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.neo.expectClusterRunning() self.neo.expectClusterRunning()
self.neo.expectAssignedCells(started[0].getUUID(), 10) self.neo.expectAssignedCells(started[0].getUUID(), 10)
self.neo.expectOudatedCells(number=0)
# start the second and add it to the partition table # start the second and add it to the partition table
stopped[0].start() stopped[0].start()
...@@ -291,6 +298,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -291,6 +298,7 @@ class StorageTests(NEOFunctionalTest):
self.neo.neoctl.enableStorageList([stopped[0].getUUID()]) self.neo.neoctl.enableStorageList([stopped[0].getUUID()])
self.__expectRunning(stopped[0]) self.__expectRunning(stopped[0])
self.neo.expectClusterRunning() self.neo.expectClusterRunning()
self.neo.expectOudatedCells(number=0)
# the partition table must change, each node should be assigned to # the partition table must change, each node should be assigned to
# five partitions # five partitions
...@@ -306,6 +314,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -306,6 +314,7 @@ class StorageTests(NEOFunctionalTest):
partitions=10, pending_number=0) partitions=10, pending_number=0)
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.__expectRunning(started[1]) self.__expectRunning(started[1])
self.neo.expectOudatedCells(number=0)
self.neo.expectAssignedCells(started[0].getUUID(), 10) self.neo.expectAssignedCells(started[0].getUUID(), 10)
self.neo.expectAssignedCells(started[1].getUUID(), 10) self.neo.expectAssignedCells(started[1].getUUID(), 10)
...@@ -332,6 +341,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -332,6 +341,7 @@ class StorageTests(NEOFunctionalTest):
pending_number=1, partitions=10) pending_number=1, partitions=10)
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.__expectNotKnown(stopped[0]) self.__expectNotKnown(stopped[0])
self.neo.expectOudatedCells(number=0)
# populate the cluster with some data # populate the cluster with some data
self.__populate() self.__populate()
...@@ -386,7 +396,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -386,7 +396,7 @@ class StorageTests(NEOFunctionalTest):
# start with two storage / one replica # start with two storage / one replica
(started, stopped) = self.__setup(storage_number=2, replicas=1, (started, stopped) = self.__setup(storage_number=2, replicas=1,
master_node_count=1) master_node_count=1, partitions=10)
self.__expectRunning(started[0]) self.__expectRunning(started[0])
self.__expectRunning(started[1]) self.__expectRunning(started[1])
...@@ -407,7 +417,5 @@ class StorageTests(NEOFunctionalTest): ...@@ -407,7 +417,5 @@ class StorageTests(NEOFunctionalTest):
self.__expectRunning(started[1]) self.__expectRunning(started[1])
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