Skip to content

Commit

Permalink
Expect exception raised when committing or aborting a txn that finished
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannguyen4 committed Jan 3, 2025
1 parent 0b879e6 commit 5d4c635
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/main/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ struct exception_def exception_defs[] = {
AEROSPIKE_ERR_ASYNC_CONNECTION, NULL),
EXCEPTION_DEF("ClientAbortError", CLIENT_ERR_EXCEPTION_NAME,
AEROSPIKE_ERR_CLIENT_ABORT, NULL),
EXCEPTION_DEF("TranactionFailed", CLIENT_ERR_EXCEPTION_NAME,
EXCEPTION_DEF("TransactionFailed", CLIENT_ERR_EXCEPTION_NAME,
AEROSPIKE_TXN_FAILED, NULL),
EXCEPTION_DEF("TransactionAlreadyCommitted", CLIENT_ERR_EXCEPTION_NAME,
AEROSPIKE_TXN_ALREADY_COMMITTED, NULL),
EXCEPTION_DEF("TransactionAlreadyAborted", CLIENT_ERR_EXCEPTION_NAME,
AEROSPIKE_TXN_ALREADY_ABORTED, NULL),

// Server errors
EXCEPTION_DEF("InvalidRequest", SERVER_ERR_EXCEPTION_NAME,
AEROSPIKE_ERR_REQUEST_INVALID, NULL),
Expand Down
8 changes: 4 additions & 4 deletions test/new_tests/test_mrt_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def test_commit_fail(self):
}
self.as_connection.put(self.keys[0], {self.bin_name: 1}, policy=policy)
self.as_connection.abort(mrt)
status = self.as_connection.commit(mrt)
assert status == aerospike.MRT_COMMIT_ALREADY_ABORTED
with pytest.raises(e.TransactionAlreadyAborted):
self.as_connection.commit(mrt)

# Test case 10: Issue abort after issung commit. (P1)
def test_abort_fail(self):
Expand All @@ -100,5 +100,5 @@ def test_abort_fail(self):
}
self.as_connection.put(self.keys[0], {self.bin_name: 1}, policy=policy)
self.as_connection.commit(mrt)
status = self.as_connection.abort(mrt)
assert status == aerospike.MRT_ABORT_ALREADY_COMMITTED
with pytest.raises(e.TransactionAlreadyCommitted):
self.as_connection.abort(mrt)

0 comments on commit 5d4c635

Please sign in to comment.