summaryrefslogtreecommitdiff
path: root/jstests/core/capped_empty.js
blob: c9be3386006f9481418309643db03dc553ffeccf (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
/**
 * @tags: [
 *   requires_capped,
 *   requires_fastcount,
 *   requires_non_retryable_commands,
 *   uses_testing_only_commands,
 *   requires_emptycapped,
 *   # capped collections connot be sharded
 *   assumes_unsharded_collection,
 *   # emptycapped command is not supported on mongos
 *   assumes_against_mongod_not_mongos,
 *   no_selinux,
 * ]
 */

t = db.capped_empty;
t.drop();

db.createCollection(t.getName(), {capped: true, size: 100});

t.insert({x: 1});
t.insert({x: 2});
t.insert({x: 3});
t.createIndex({x: 1});

assert.eq(3, t.count());

t.runCommand("emptycapped");

assert.eq(0, t.count());

t.insert({x: 1});
t.insert({x: 2});
t.insert({x: 3});

assert.eq(3, t.count());