Skip to content

Commit 04c3a48

Browse files
committed
PYTHON-2153 Skip failing createIndexes wtimeout test on 4.3+
PYTHON-2154 Skip failing transactions test on 4.5+
1 parent bb272b1 commit 04c3a48

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

test/test_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ def setUpClass(cls):
850850
super(TestTransactionExamples, cls).setUpClass()
851851
cls.client = rs_or_single_client(w="majority")
852852

853+
@client_context.require_version_max(4, 4, 99) # PYTHON-2154 skip on 4.5+
853854
@client_context.require_transactions
854855
def test_transactions(self):
855856
# Transaction examples

test/test_read_write_concern_spec.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)