Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ def server_description_count():
gc.collect()
with client_knobs(min_heartbeat_interval=0.003):
client = MongoClient(
"invalid:27017", heartbeatFrequencyMS=3, serverSelectionTimeoutMS=100
"invalid:27017", heartbeatFrequencyMS=3, serverSelectionTimeoutMS=150
)
initial_count = server_description_count()
self.addCleanup(client.close)
Expand Down
11 changes: 7 additions & 4 deletions test/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
from test.utils_spec_runner import SpecRunner

from bson.py3compat import StringIO
from bson import encode
from bson.raw_bson import RawBSONDocument

from gridfs import GridFS, GridFSBucket
from pymongo import WriteConcern, client_session
from pymongo.client_session import TransactionOptions
Expand Down Expand Up @@ -332,14 +335,14 @@ def test_transaction_starts_with_batched_write(self):
listener.reset()
self.addCleanup(client.close)
self.addCleanup(coll.drop)
large_str = "\0" * (10 * 1024 * 1024)
ops = [InsertOne({"a": large_str}) for _ in range(10)]
large_str = "\0" * (1 * 1024 * 1024)
ops = [InsertOne(RawBSONDocument(encode({"a": large_str}))) for _ in range(48)]
with client.start_session() as session:
with session.start_transaction():
coll.bulk_write(ops, session=session)
# Assert commands were constructed properly.
self.assertEqual(
["insert", "insert", "insert", "commitTransaction"], listener.started_command_names()
["insert", "insert", "commitTransaction"], listener.started_command_names()
)
first_cmd = listener.results["started"][0].command
self.assertTrue(first_cmd["startTransaction"])
Expand All @@ -349,7 +352,7 @@ def test_transaction_starts_with_batched_write(self):
self.assertNotIn("startTransaction", event.command)
self.assertEqual(lsid, event.command["lsid"])
self.assertEqual(txn_number, event.command["txnNumber"])
self.assertEqual(10, coll.count_documents({}))
self.assertEqual(48, coll.count_documents({}))


class PatchSessionTimeout(object):
Expand Down