@@ -195,7 +195,15 @@ def assert_scram_sha_authentication(
195
195
except OperationFailure as e :
196
196
if i == 0 :
197
197
fail (f"unable to authenticate after { attempts } attempts with error: { e } " )
198
- time .sleep (5 )
198
+
199
+ # Use adaptive retry delays for better password propagation handling
200
+ remaining_attempts = i
201
+ if remaining_attempts >= attempts * 0.7 : # First ~30% of attempts
202
+ delay = 10 # Longer delay for initial propagation
203
+ else :
204
+ delay = 5 # Standard delay for normal retries
205
+
206
+ time .sleep (delay )
199
207
200
208
def assert_scram_sha_authentication_fails (
201
209
self ,
@@ -239,7 +247,7 @@ def _authenticate_with_scram(
239
247
# authentication doesn't actually happen until we interact with a database
240
248
self .client ["admin" ]["myCol" ].insert_one ({})
241
249
242
- def assert_x509_authentication (self , cert_file_name : str , attempts : int = 20 , ** kwargs ):
250
+ def assert_x509_authentication (self , cert_file_name : str , attempts : int = 30 , ** kwargs ):
243
251
assert attempts > 0
244
252
245
253
options = self ._merge_options (
@@ -258,7 +266,15 @@ def assert_x509_authentication(self, cert_file_name: str, attempts: int = 20, **
258
266
except OperationFailure :
259
267
if attempts == 0 :
260
268
fail (f"unable to authenticate after { total_attempts } attempts" )
261
- time .sleep (5 )
269
+
270
+ # Use adaptive retry delays for better credential propagation handling
271
+ remaining_attempts = attempts
272
+ if remaining_attempts >= total_attempts * 0.7 : # First ~30% of attempts
273
+ delay = 10 # Longer delay for initial propagation
274
+ else :
275
+ delay = 5 # Standard delay for normal retries
276
+
277
+ time .sleep (delay )
262
278
263
279
def assert_ldap_authentication (
264
280
self ,
@@ -290,7 +306,15 @@ def assert_ldap_authentication(
290
306
except OperationFailure :
291
307
if attempts <= 0 :
292
308
fail (f"unable to authenticate after { total_attempts } attempts" )
293
- time .sleep (5 )
309
+
310
+ # Use adaptive retry delays for better credential propagation handling
311
+ remaining_attempts = attempts
312
+ if remaining_attempts >= total_attempts * 0.7 : # First ~30% of attempts
313
+ delay = 10 # Longer delay for initial propagation
314
+ else :
315
+ delay = 5 # Standard delay for normal retries
316
+
317
+ time .sleep (delay )
294
318
295
319
def assert_oidc_authentication (
296
320
self ,
@@ -317,7 +341,15 @@ def assert_oidc_authentication(
317
341
except OperationFailure as e :
318
342
if attempts == 0 :
319
343
raise RuntimeError (f"Unable to authenticate after { total_attempts } attempts: { e } " )
320
- time .sleep (5 )
344
+
345
+ # Use adaptive retry delays for better credential propagation handling
346
+ remaining_attempts = attempts
347
+ if remaining_attempts >= total_attempts * 0.7 : # First ~30% of attempts
348
+ delay = 10 # Longer delay for initial propagation
349
+ else :
350
+ delay = 5 # Standard delay for normal retries
351
+
352
+ time .sleep (delay )
321
353
322
354
def assert_oidc_authentication_fails (self , db : str = "admin" , collection : str = "myCol" , attempts : int = 10 ):
323
355
assert attempts > 0
0 commit comments