@@ -97,7 +97,10 @@ def insert_command_default_write_concern():
97
97
name , event .command_name ))
98
98
99
99
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 )
101
104
db = client .get_database ('pymongo_test' )
102
105
coll = db .test
103
106
@@ -119,18 +122,25 @@ def insert_command():
119
122
]
120
123
ops_require_34 = [
121
124
('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 )])),
125
125
('create' , lambda : db .create_collection ('new' )),
126
126
('rename' , lambda : coll .rename ('new' )),
127
127
('drop' , lambda : db .new .drop ()),
128
128
]
129
129
if client_context .version > (3 , 4 ):
130
130
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 ):
133
133
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
+ ])
134
144
135
145
for name , f in ops :
136
146
# Ensure insert_many and bulk_write still raise BulkWriteError.
0 commit comments