Files
mongo/jstests/core/capped/capped_large_docs.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

34 lines
1.1 KiB
JavaScript

/**
* Tests inserting large documents into a capped collection.
*
* @tags: [
* # Suites with stepdowns will result in replication rollback, and we do not update tracked
* # collection size for replication rollback. Thus if this occurs during the inserts, we can
* # end up with fewer documents in the capped collection than we would otherwise expect.
* does_not_support_stepdowns,
* requires_capped,
* requires_collstats,
* requires_fastcount,
* # Capped collections cannot be sharded
* assumes_unsharded_collection,
* ]
*/
const coll = db[jsTestName()];
coll.drop();
const maxSize = 25 * 1024 * 1024; // 25MB.
assert.commandWorked(db.createCollection(coll.getName(), {capped: true, size: maxSize}));
// Insert ~50MB of data.
const doc = {
key: "a".repeat(10 * 1024 * 1024),
};
for (let i = 0; i < 5; i++) {
assert.commandWorked(coll.insert(doc));
}
// With a capped collection capacity of 25MB, we should have 2 documents.
const stats = assert.commandWorked(coll.stats());
assert.eq(2, stats.count);
assert(stats.size <= maxSize);