mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 16:46:00 +01:00
2cee0f7b89
GitOrigin-RevId: b31fcb7c93ff15df5f84a5b13eac886a10bb8c1c
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
/**
|
|
* Test cloneCollectionAsCapped
|
|
*
|
|
* @tags: [
|
|
* # The test runs commands that are not allowed with security token: cloneCollectionAsCapped,
|
|
* # convertToCapped.
|
|
* not_allowed_with_signed_security_token,
|
|
* requires_non_retryable_commands,
|
|
* requires_fastcount,
|
|
* requires_capped,
|
|
* # capped collections connot be sharded
|
|
* assumes_unsharded_collection,
|
|
* # cloneCollectionAsCapped command is not supported on mongos
|
|
* # TODO: SERVER-85773 Remove assumes_against_mongod_not_mongos tag
|
|
* assumes_against_mongod_not_mongos,
|
|
* ]
|
|
*/
|
|
|
|
let source = db.capped_convertToCapped1;
|
|
let dest = db.capped_convertToCapped1_clone;
|
|
|
|
source.drop();
|
|
dest.drop();
|
|
|
|
const numInitialDocs = 1000;
|
|
for (let i = 0; i < numInitialDocs; ++i) {
|
|
source.save({i: i});
|
|
}
|
|
assert.eq(numInitialDocs, source.count());
|
|
assert(!source.isCapped());
|
|
assert(!dest.isCapped());
|
|
|
|
// should all fit
|
|
assert.commandWorked(db.runCommand(
|
|
{cloneCollectionAsCapped: source.getName(), toCollection: dest.getName(), size: 100000}));
|
|
assert(!source.isCapped());
|
|
assert(dest.isCapped());
|
|
assert.eq(numInitialDocs, dest.count());
|
|
assert.eq(numInitialDocs, source.count());
|
|
|
|
dest.drop();
|
|
|
|
// should NOT all fit
|
|
assert(!dest.isCapped());
|
|
assert.commandWorked(db.runCommand(
|
|
{cloneCollectionAsCapped: source.getName(), toCollection: dest.getName(), size: 1000}));
|
|
assert(!source.isCapped());
|
|
assert(dest.isCapped());
|
|
|
|
assert.eq(numInitialDocs, source.count());
|
|
assert.gt(numInitialDocs, dest.count());
|