diff --git a/test/test_client.py b/test/test_client.py index d5688c018b..c82f9df4c0 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -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) diff --git a/test/test_transactions.py b/test/test_transactions.py index d78010db26..9e06f3a365 100644 --- a/test/test_transactions.py +++ b/test/test_transactions.py @@ -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 @@ -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"]) @@ -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):