Commit 98b996b4 authored by Vincent Pelletier's avatar Vincent Pelletier

Duplicate tpc_begin calls should raise.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2246 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 2e1e980c
...@@ -556,7 +556,7 @@ class Application(object): ...@@ -556,7 +556,7 @@ class Application(object):
# First get a transaction, only one is allowed at a time # First get a transaction, only one is allowed at a time
if self.local_var.txn is transaction: if self.local_var.txn is transaction:
# We already begin the same transaction # We already begin the same transaction
return raise StorageTransactionError('Duplicate tpc_begin calls')
if self.local_var.txn is not None: if self.local_var.txn is not None:
raise NeoException, 'local_var is not clean in tpc_begin' raise NeoException, 'local_var is not clean in tpc_begin'
# use the given TID or request a new one to the master # use the given TID or request a new one to the master
......
...@@ -384,7 +384,8 @@ class ClientApplicationTests(NeoTestBase): ...@@ -384,7 +384,8 @@ class ClientApplicationTests(NeoTestBase):
self.assertTrue(app.local_var.txn is txn) self.assertTrue(app.local_var.txn is txn)
self.assertEquals(app.local_var.tid, tid) self.assertEquals(app.local_var.tid, tid)
# next, the transaction already begin -> do nothing # next, the transaction already begin -> do nothing
app.tpc_begin(transaction=txn, tid=None) self.assertRaises(StorageTransactionError, app.tpc_begin,
transaction=txn, tid=None)
self.assertTrue(app.local_var.txn is txn) self.assertTrue(app.local_var.txn is txn)
self.assertEquals(app.local_var.tid, tid) self.assertEquals(app.local_var.tid, tid)
# cancel and start a transaction without tid # cancel and start a transaction without tid
...@@ -534,7 +535,6 @@ class ClientApplicationTests(NeoTestBase): ...@@ -534,7 +535,6 @@ class ClientApplicationTests(NeoTestBase):
app.pt = Mock({ 'getCellListForTID': (cell, cell, ) }) app.pt = Mock({ 'getCellListForTID': (cell, cell, ) })
app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), }) app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), })
app.dispatcher = Mock() app.dispatcher = Mock()
app.tpc_begin(txn, tid)
self.assertRaises(NEOStorageError, app.tpc_vote, txn, self.assertRaises(NEOStorageError, app.tpc_vote, txn,
resolving_tryToResolveConflict) resolving_tryToResolveConflict)
self.checkAskPacket(conn, Packets.AskStoreTransaction) self.checkAskPacket(conn, Packets.AskStoreTransaction)
...@@ -559,7 +559,6 @@ class ClientApplicationTests(NeoTestBase): ...@@ -559,7 +559,6 @@ class ClientApplicationTests(NeoTestBase):
app.pt = Mock({ 'getCellListForTID': (cell, cell, ) }) app.pt = Mock({ 'getCellListForTID': (cell, cell, ) })
app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), }) app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), })
app.dispatcher = Mock() app.dispatcher = Mock()
app.tpc_begin(txn, tid)
app.tpc_vote(txn, resolving_tryToResolveConflict) app.tpc_vote(txn, resolving_tryToResolveConflict)
self.checkAskStoreTransaction(conn) self.checkAskStoreTransaction(conn)
self.checkDispatcherRegisterCalled(app, conn) self.checkDispatcherRegisterCalled(app, conn)
...@@ -656,8 +655,6 @@ class ClientApplicationTests(NeoTestBase): ...@@ -656,8 +655,6 @@ class ClientApplicationTests(NeoTestBase):
def pending(self, queue): def pending(self, queue):
return not queue.empty() return not queue.empty()
app.dispatcher = Dispatcher() app.dispatcher = Dispatcher()
# begin a transaction
app.tpc_begin(txn, tid)
# conflict occurs on storage 2 # conflict occurs on storage 2
app.store(oid1, tid, 'DATA', None, txn) app.store(oid1, tid, 'DATA', None, txn)
app.store(oid2, tid, 'DATA', None, txn) app.store(oid2, tid, 'DATA', None, txn)
......
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