summaryrefslogtreecommitdiff
path: root/jstests/core/capped_convertToCapped1.js
blob: b15b018fe621eac67eda1c8e91efef730705af2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
 * Test cloneCollectionAsCapped
 *
 * @tags: [
 *  requires_non_retryable_commands,
 *  requires_fastcount,
 *  requires_capped,
 *  # capped collections connot be sharded
 *  assumes_unsharded_collection,
 *  # cloneCollectionAsCapped command is not supported on mongos
 *  assumes_against_mongod_not_mongos,
 *  # TODO (SERVER-52727): Synchronize cloneCollectionAsCapped with tenant migrations.
 *  tenant_migration_incompatible,
 * ]
 */

source = db.capped_convertToCapped1;
dest = db.capped_convertToCapped1_clone;

source.drop();
dest.drop();

N = 1000;

for (i = 0; i < N; ++i) {
    source.save({i: i});
}
assert.eq(N, source.count());

// should all fit
res = db.runCommand(
    {cloneCollectionAsCapped: source.getName(), toCollection: dest.getName(), size: 100000});
assert.commandWorked(res);
assert.eq(source.count(), dest.count());
assert.eq(N, source.count());  // didn't delete source

dest.drop();
// should NOT all fit
assert.commandWorked(db.runCommand(
    {cloneCollectionAsCapped: source.getName(), toCollection: dest.getName(), size: 1000}));

assert.eq(N, source.count());  // didn't delete source
assert.gt(source.count(), dest.count());