PYTHON-4087 Fix test_validate_collection_background by flushing writes via fsync (#1464)

This commit is contained in:
Shane Harvey 2024-01-05 13:30:05 -08:00 committed by GitHub
parent 99c7338163
commit 3dea7ccf31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.