Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/neo4j/test_session_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tests.neo4j.shared import (
cluster_unsafe_test,
get_driver,
get_server_info,
)
from tests.shared import (
get_driver_name,
Expand Down Expand Up @@ -156,7 +157,9 @@ def test_autocommit_transactions_should_support_timeout(self):
# requires explicit termination of transactions
tx1.rollback()
# TODO REMOVE THIS BLOCK ONCE ALL IMPLEMENT RETRYABLE EXCEPTIONS
if get_driver_name() in ["javascript", "ruby", "python"]:
is_server_affected_with_bug = get_server_info().version <= "4.4"
if is_server_affected_with_bug and get_driver_name() in [
"ruby", "python", "javascript"]:
self.assertEqual(
e.exception.code,
"Neo.TransientError.Transaction.LockClientStopped")
Expand Down
45 changes: 33 additions & 12 deletions tests/neo4j/test_tx_func_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,25 @@ def update2(tx):
with self.assertRaises(types.DriverError) as e:
tx.run("MATCH (a:Node) SET a.property = 2").consume()
exc = e.exception
if (exc.code
!= "Neo.TransientError.Transaction.LockClientStopped"):
# This is not the error we are looking for. Maybe there was a
# TODO REMOVE THIS BLOCK ONCE ALL IMPLEMENT RETRYABLE EXCEPTIONS
server_is_affect_by_bug = get_server_info().version <= "4.4"
driver_has_fixed_bug = not get_driver_name() in [
"javascript", "ruby", "python"]
if (server_is_affect_by_bug
and not driver_has_fixed_bug
and exc.code
== "Neo.TransientError.Transaction.LockClientStopped"):
# This is the error we are looking for. Maybe there was a
# leader election or so. Give the driver the chance to retry.
raise ApplicationCodeError("Stop, hammer time!")
elif ((not server_is_affect_by_bug or driver_has_fixed_bug)
and exc.code
== "Neo.ClientError.Transaction.LockClientStopped"):
# This is the error we are looking for. Maybe there was a
# leader election or so. Give the driver the chance to retry.
raise exc
else:
# The error we are looking for. Raise ApplicationError instead
# to make the driver stop retrying.
raise ApplicationCodeError("Stop, hammer time!")
else:
raise exc

exc = None

Expand All @@ -221,8 +231,19 @@ def update2(tx):
)
self._session1.write_transaction(update1)
self.assertIsInstance(exc, types.DriverError)
self.assertEqual(exc.code,
"Neo.TransientError.Transaction.LockClientStopped")
if get_driver_name() in ["python"]:
self.assertEqual(exc.errorType,
"<class 'neo4j.exceptions.TransientError'>")
# TODO REMOVE THIS BLOCK ONCE ALL IMPLEMENT RETRYABLE EXCEPTIONS
server_is_affect_by_bug = get_server_info().version <= "4.4"
if server_is_affect_by_bug and get_driver_name() in [
"javascript", "ruby", "python"]:
self.assertEqual(
exc.code,
"Neo.TransientError.Transaction.LockClientStopped")
if get_driver_name() in ["python"]:
self.assertEqual(exc.errorType,
"<class 'neo4j.exceptions.TransientError'>")
else:
self.assertEqual(exc.code,
"Neo.ClientError.Transaction.LockClientStopped")
if get_driver_name() in ["python"]:
self.assertEqual(exc.errorType,
"<class 'neo4j.exceptions.ClientError'>")
4 changes: 3 additions & 1 deletion tests/neo4j/test_tx_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ def test_tx_timeout(self):
result = tx2.run("MATCH (a:Node) SET a.property = 2")
result.consume()
# TODO REMOVE THIS BLOCK ONCE ALL IMPLEMENT RETRYABLE EXCEPTIONS
if get_driver_name() in ["javascript", "ruby", "python"]:
is_server_affected_with_bug = get_server_info().version <= "4.4"
if is_server_affected_with_bug and get_driver_name() in [
"javascript", "ruby", "python"]:
self.assertEqual(
e.exception.code,
"Neo.TransientError.Transaction.LockClientStopped")
Expand Down