From 3dea7ccf3186aa1d3101fce8729e8beb2bd35e89 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 5 Jan 2024 13:30:05 -0800 Subject: [PATCH] PYTHON-4087 Fix test_validate_collection_background by flushing writes via fsync (#1464) --- test/test_database.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_database.py b/test/test_database.py index 8fc8bff61..87391312f 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -377,12 +377,14 @@ class TestDatabase(IntegrationTest): @client_context.require_version_min(4, 3, 3) @client_context.require_no_standalone def test_validate_collection_background(self): - db = self.client.pymongo_test + db = self.client.pymongo_test.with_options(write_concern=WriteConcern(w="majority")) db.test.insert_one({"dummy": "object"}) coll = db.test self.assertTrue(db.validate_collection(coll, background=False)) # The inMemory storage engine does not support background=True. if client_context.storage_engine != "inMemory": + # background=True requires the collection exist in a checkpoint. + self.client.admin.command("fsync") self.assertTrue(db.validate_collection(coll, background=True)) self.assertTrue(db.validate_collection(coll, scandata=True, background=True)) # The server does not support background=True with full=True.