Commit 474507ef authored by Grégory Wisniewski's avatar Grégory Wisniewski

Fix master's storage handler peerBroken, timeoutExpired, connectionClosed methods

- Don't test the case where no UUID is available, this is ensured by identification handler
- When cluster leave operational state, the PTID *must* not change,fix the assertion.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1435 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 92d9405d
...@@ -307,39 +307,28 @@ class MasterStorageHandlerTests(NeoTestBase): ...@@ -307,39 +307,28 @@ class MasterStorageHandlerTests(NeoTestBase):
def _testWithMethod(self, method, state): def _testWithMethod(self, method, state):
service = self.service service = self.service
uuid = self.identifyToMasterNode() # define two nodes
# do nothing if no uuid node1, conn1 = self.identifyToMasterNode()
conn = self.getFakeConnection(None, self.storage_address) node2, conn2 = self.identifyToMasterNode()
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), NodeStates.RUNNING) node1.setRunning()
method(conn) node2.setRunning()
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), NodeStates.RUNNING) self.assertEquals(node1.getState(), NodeStates.RUNNING)
# add a second storage node and then declare it as broken self.assertEquals(node2.getState(), NodeStates.RUNNING)
self.identifyToMasterNode(port = self.storage_port+2)
storage_uuid = self.identifyToMasterNode(port = self.storage_port+1)
# filled the pt # filled the pt
self.app.pt.make(self.app.nm.getStorageList()) self.app.pt.make(self.app.nm.getStorageList())
self.assertTrue(self.app.pt.filled()) self.assertTrue(self.app.pt.filled())
self.assertTrue(self.app.pt.operational()) self.assertTrue(self.app.pt.operational())
conn = self.getFakeConnection(storage_uuid, ('127.0.0.1', self.storage_port+1)) # drop one node
lptid = self.app.pt.getID() lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), method(conn1)
NodeStates.RUNNING) self.assertEquals(node1.getState(), state)
method(conn)
self.assertEquals(self.app.nm.getByUUID(storage_uuid).getState(), state)
self.failUnless(lptid < self.app.pt.getID()) self.failUnless(lptid < self.app.pt.getID())
# give an uuid, must raise as no other storage node available # drop the second, no storage node left
conn = self.getFakeConnection(uuid, self.storage_address)
lptid = self.app.pt.getID() lptid = self.app.pt.getID()
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), self.assertEquals(node2.getState(), NodeStates.RUNNING)
NodeStates.UNKNOWN) self.assertRaises(OperationFailure, method, conn2)
self.assertRaises(OperationFailure, method, conn) self.assertEquals(node2.getState(), state)
self.assertEquals(self.app.nm.getByUUID(uuid).getState(), state)
self.failUnless(lptid < self.app.pt.getID())
# node must be have been remove, and no more transaction must remains
self.assertEquals(self.app.nm.getByUUID(client_uuid), None)
self.assertEquals(lptid, self.app.pt.getID()) self.assertEquals(lptid, self.app.pt.getID())
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 0)
def test_15_peerBroken(self): def test_15_peerBroken(self):
self._testWithMethod(self.service.peerBroken, NodeStates.BROKEN) self._testWithMethod(self.service.peerBroken, NodeStates.BROKEN)
......
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