@@ -448,7 +448,7 @@ async def set_fail_point(self, command_args):
448448 await self .configure_fail_point (client , command_args )
449449
450450 @async_client_context .require_transactions
451- async def test_callback_raises_custom_error (self ):
451+ async def test_1_callback_raises_custom_error (self ):
452452 class _MyException (Exception ):
453453 pass
454454
@@ -460,7 +460,7 @@ async def raise_error(_):
460460 await s .with_transaction (raise_error )
461461
462462 @async_client_context .require_transactions
463- async def test_callback_returns_value (self ):
463+ async def test_2_callback_returns_value (self ):
464464 async def callback (_ ):
465465 return "Foo"
466466
@@ -488,7 +488,7 @@ def callback(_):
488488 self .assertEqual (await s .with_transaction (callback ), "Foo" )
489489
490490 @async_client_context .require_transactions
491- async def test_callback_not_retried_after_timeout (self ):
491+ async def test_3_1_callback_not_retried_after_timeout (self ):
492492 listener = OvertCommandListener ()
493493 client = await self .async_rs_client (event_listeners = [listener ])
494494 coll = client [self .db .name ].test
@@ -516,7 +516,7 @@ async def callback(session):
516516
517517 @async_client_context .require_test_commands
518518 @async_client_context .require_transactions
519- async def test_callback_not_retried_after_commit_timeout (self ):
519+ async def test_3_2_callback_not_retried_after_commit_timeout (self ):
520520 listener = OvertCommandListener ()
521521 client = await self .async_rs_client (event_listeners = [listener ])
522522 coll = client [self .db .name ].test
@@ -550,7 +550,7 @@ async def callback(session):
550550
551551 @async_client_context .require_test_commands
552552 @async_client_context .require_transactions
553- async def test_commit_not_retried_after_timeout (self ):
553+ async def test_3_3_commit_not_retried_after_timeout (self ):
554554 listener = OvertCommandListener ()
555555 client = await self .async_rs_client (event_listeners = [listener ])
556556 coll = client [self .db .name ].test
@@ -622,10 +622,12 @@ async def callback(session):
622622
623623 @async_client_context .require_test_commands
624624 @async_client_context .require_transactions
625- async def test_transaction_backoff (self ):
625+ async def test_4_retry_backoff_is_enforced (self ):
626626 client = async_client_context .client
627627 coll = client [self .db .name ].test
628- # patch random to make it deterministic
628+ # patch random to make it deterministic -- once to effectively have
629+ # no backoff and the second time with "max" backoff (always waiting the longest
630+ # possible time)
629631 _original_random_random = random .random
630632
631633 def always_one ():
@@ -639,12 +641,10 @@ def always_zero():
639641 await self .set_fail_point (
640642 {
641643 "configureFailPoint" : "failCommand" ,
642- "mode" : {
643- "times" : 13
644- }, # sufficiently high enough such that the time effect of backoff is noticeable
644+ "mode" : {"times" : 13 },
645645 "data" : {
646646 "failCommands" : ["commitTransaction" ],
647- "errorCode" : 24 ,
647+ "errorCode" : 251 ,
648648 },
649649 }
650650 )
@@ -671,7 +671,7 @@ async def callback(session):
671671 }, # sufficiently high enough such that the time effect of backoff is noticeable
672672 "data" : {
673673 "failCommands" : ["commitTransaction" ],
674- "errorCode" : 24 ,
674+ "errorCode" : 251 ,
675675 },
676676 }
677677 )
0 commit comments