@@ -432,6 +432,7 @@ def __init__(self, test_class):
432
432
self ._listeners : Dict [str , EventListenerUtil ] = {}
433
433
self ._session_lsids : Dict [str , Mapping [str , Any ]] = {}
434
434
self .test : UnifiedSpecTestMixinV1 = test_class
435
+ self ._cluster_time : Mapping [str , Any ] = {}
435
436
436
437
def __contains__ (self , item ):
437
438
return item in self ._entities
@@ -624,6 +625,14 @@ def get_lsid_for_session(self, session_name):
624
625
# session has been closed.
625
626
return self ._session_lsids [session_name ]
626
627
628
+ def advance_cluster_times (self ) -> None :
629
+ """Manually synchronize entities when desired"""
630
+ if not self ._cluster_time :
631
+ self ._cluster_time = self .test .client .admin .command ("ping" ).get ("$clusterTime" )
632
+ for entity in self ._entities .values ():
633
+ if isinstance (entity , ClientSession ) and self ._cluster_time :
634
+ entity .advance_cluster_time (self ._cluster_time )
635
+
627
636
628
637
binary_types = (Binary , bytes )
629
638
long_types = (Int64 ,)
@@ -1050,14 +1059,6 @@ def maybe_skip_test(self, spec):
1050
1059
self .skipTest ("Implement PYTHON-1894" )
1051
1060
if "timeoutMS applied to entire download" in spec ["description" ]:
1052
1061
self .skipTest ("PyMongo's open_download_stream does not cap the stream's lifetime" )
1053
-
1054
- if "unpin after TransientTransactionError error on" in spec ["description" ]:
1055
- self .skipTest ("Skipping TransientTransactionError pending PYTHON-4227" )
1056
- if "withTransaction commits after callback returns" in spec ["description" ]:
1057
- self .skipTest ("Skipping TransientTransactionError pending PYTHON-4303" )
1058
- if "unpin on successful abort" in spec ["description" ]:
1059
- self .skipTest ("Skipping TransientTransactionError pending PYTHON-4227" )
1060
-
1061
1062
if "unpin after non-transient error on abort" in spec ["description" ]:
1062
1063
if client_context .version [0 ] == 8 :
1063
1064
self .skipTest ("Skipping TransientTransactionError pending PYTHON-4182" )
@@ -1519,6 +1520,7 @@ def _testOperation_targetedFailPoint(self, spec):
1519
1520
1520
1521
def _testOperation_createEntities (self , spec ):
1521
1522
self .entity_map .create_entities_from_spec (spec ["entities" ], uri = self ._uri )
1523
+ self .entity_map .advance_cluster_times ()
1522
1524
1523
1525
def _testOperation_assertSessionTransactionState (self , spec ):
1524
1526
session = self .entity_map [spec ["session" ]]
@@ -1880,7 +1882,10 @@ def _run_scenario(self, spec, uri=None):
1880
1882
self .entity_map = EntityMapUtil (self )
1881
1883
self .entity_map .create_entities_from_spec (self .TEST_SPEC .get ("createEntities" , []), uri = uri )
1882
1884
# process initialData
1883
- self .insert_initial_data (self .TEST_SPEC .get ("initialData" , []))
1885
+ if "initialData" in self .TEST_SPEC :
1886
+ self .insert_initial_data (self .TEST_SPEC ["initialData" ])
1887
+ self ._cluster_time = self .client .admin .command ("ping" ).get ("$clusterTime" )
1888
+ self .entity_map .advance_cluster_times ()
1884
1889
1885
1890
if "expectLogMessages" in spec :
1886
1891
expect_log_messages = spec ["expectLogMessages" ]
0 commit comments