@@ -97,7 +97,10 @@ def insert_command_default_write_concern():
9797 name , event .command_name ))
9898
9999 def assertWriteOpsRaise (self , write_concern , expected_exception ):
100- client = rs_or_single_client (** write_concern .document )
100+ wc = write_concern .document
101+ # Set socket timeout to avoid indefinite stalls
102+ client = rs_or_single_client (
103+ w = wc ['w' ], wTimeoutMS = wc ['wtimeout' ], socketTimeoutMS = 30000 )
101104 db = client .get_database ('pymongo_test' )
102105 coll = db .test
103106
@@ -119,18 +122,25 @@ def insert_command():
119122 ]
120123 ops_require_34 = [
121124 ('aggregate' , lambda : coll .aggregate ([{'$out' : 'out' }])),
122- ('create_index' , lambda : coll .create_index ([('a' , DESCENDING )])),
123- ('create_indexes' , lambda : coll .create_indexes ([IndexModel ('b' )])),
124- ('drop_index' , lambda : coll .drop_index ([('a' , DESCENDING )])),
125125 ('create' , lambda : db .create_collection ('new' )),
126126 ('rename' , lambda : coll .rename ('new' )),
127127 ('drop' , lambda : db .new .drop ()),
128128 ]
129129 if client_context .version > (3 , 4 ):
130130 ops .extend (ops_require_34 )
131- # SERVER-34776: Drop database does not respect wtimeout in 4.0 .
132- if client_context .version < = (3 , 6 ):
131+ # SERVER-34776: dropDatabase does not respect wtimeout in 3.6 .
132+ if client_context .version [: 2 ] ! = (3 , 6 ):
133133 ops .append (('drop_database' , lambda : client .drop_database (db )))
134+ # SERVER-46668: createIndexes does not respect wtimeout in 4.4+.
135+ if client_context .version <= (4 , 3 ):
136+ ops .extend ([
137+ ('create_index' ,
138+ lambda : coll .create_index ([('a' , DESCENDING )])),
139+ ('create_indexes' ,
140+ lambda : coll .create_indexes ([IndexModel ('b' )])),
141+ ('drop_index' ,
142+ lambda : coll .drop_index ([('a' , DESCENDING )])),
143+ ])
134144
135145 for name , f in ops :
136146 # Ensure insert_many and bulk_write still raise BulkWriteError.
0 commit comments