Commit 8ff0bc01 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Update tests according to master's transaction manager.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1454 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 523675ad
......@@ -36,7 +36,6 @@ class MasterClientHandlerTests(NeoTestBase):
self.app.em = Mock({"getConnectionList" : []})
self.app.loid = '\0' * 8
self.app.ltid = '\0' * 8
self.app.finishing_transaction_dict = {}
for address in self.app.master_node_list:
self.app.nm.createMaster(address=address)
self.service = ClientServiceHandler(self.app)
......@@ -152,8 +151,8 @@ class MasterClientHandlerTests(NeoTestBase):
conn = self.getFakeConnection(client_uuid, self.client_address)
service.askBeginTransaction(conn, packet, None)
self.failUnless(ltid < self.app.ltid)
self.assertEquals(len(self.app.finishing_transaction_dict), 1)
tid = self.app.finishing_transaction_dict.keys()[0]
self.assertEqual(len(self.app.tm.getPendingList()), 1)
tid = self.app.tm.getPendingList()[0]
self.assertEquals(tid, self.app.ltid)
def test_08_askNewOIDs(self):
......@@ -197,10 +196,10 @@ class MasterClientHandlerTests(NeoTestBase):
self.app.em = Mock({"getConnectionList" : [conn, storage_conn]})
service.finishTransaction(conn, packet, oid_list, tid)
self.checkLockInformation(storage_conn)
self.assertEquals(len(self.app.finishing_transaction_dict), 1)
apptid = self.app.finishing_transaction_dict.keys()[0]
self.assertEquals(len(self.app.tm.getPendingList()), 1)
apptid = self.app.tm.getPendingList()[0]
self.assertEquals(tid, apptid)
txn = self.app.finishing_transaction_dict.values()[0]
txn = self.app.tm[tapptid]
self.assertEquals(len(txn.getOIDList()), 0)
self.assertEquals(len(txn.getUUIDSet()), 1)
self.assertEquals(txn.getMessageId(), 9)
......@@ -213,16 +212,17 @@ class MasterClientHandlerTests(NeoTestBase):
# give a bad tid, must not failed, just ignored it
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 0)
self.assertFalse(self.app.tm.hasPending())
service.abortTransaction(conn, packet, None)
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 0)
self.assertFalse(self.app.tm.hasPending())
# give a known tid
conn = self.getFakeConnection(client_uuid, self.client_address)
tid = self.app.ltid
self.app.finishing_transaction_dict[tid] = None
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 1)
self.app.tm.remove(tid)
self.app.tm.begin(Mock({'__hash__': 1}), tid)
self.assertTrue(self.app.tm.hasPending())
service.abortTransaction(conn, packet, tid)
self.assertEqual(len(self.app.finishing_transaction_dict.keys()), 0)
self.assertFalse(self.app.tm.hasPending())
def __testWithMethod(self, method, state):
# give a client uuid which have unfinished transactions
......@@ -237,12 +237,12 @@ class MasterClientHandlerTests(NeoTestBase):
self.service.askBeginTransaction(conn, packet, None)
self.assertEquals(self.app.nm.getByUUID(client_uuid).getState(),
NodeStates.RUNNING)
self.assertEquals(len(self.app.finishing_transaction_dict.keys()), 3)
self.assertEquals(len(self.app.tm.getPendingList()), 3)
method(conn)
# 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(len(self.app.finishing_transaction_dict.keys()), 0)
self.assertFalse(self.app.tm.hasPending())
def test_15_peerBroken(self):
self.__testWithMethod(self.service.peerBroken, NodeStates.BROKEN)
......
......@@ -37,7 +37,6 @@ class MasterStorageHandlerTests(NeoTestBase):
self.app.pt.clear()
self.app.pt.setID(pack('!Q', 1))
self.app.em = Mock({"getConnectionList" : []})
self.app.finishing_transaction_dict = {}
for address in self.app.master_node_list:
self.app.nm.createMaster(address=address)
self.service = StorageServiceHandler(self.app)
......@@ -178,11 +177,11 @@ class MasterStorageHandlerTests(NeoTestBase):
def test_12_askLastIDs(self):
service = self.service
uuid = self.identifyToMasterNode()
node, conn = self.identifyToMasterNode()
packet = Packets.AskLastIDs()
packet.setId(0)
# give a uuid
conn = self.getFakeConnection(uuid, self.storage_address)
conn = self.getFakeConnection(node.getUUID(), self.storage_address)
ptid = self.app.pt.getID()
oid = self.app.loid = '\1' * 8
tid = self.app.ltid = '\1' * 8
......@@ -206,9 +205,9 @@ class MasterStorageHandlerTests(NeoTestBase):
tid_list, = packet.decode()
self.assertEqual(tid_list, [])
# create some transaction
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT,
node, conn = self.identifyToMasterNode(node_type=NodeTypes.CLIENT,
port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
client_uuid = node.getUUID()
self.client_handler.askBeginTransaction(conn, packet, None)
self.client_handler.askBeginTransaction(conn, packet, None)
self.client_handler.askBeginTransaction(conn, packet, None)
......
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