summaryrefslogtreecommitdiff
path: root/jstests/core/removea.js
blob: 082833b503a672a840f4f10e87ae8f20392d1229 (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
// @tags: [requires_non_retryable_writes, requires_fastcount]

// Test removal of a substantial proportion of inserted documents.
(function() {
    "use strict";

    const t = db.jstests_removea;

    Random.setRandomSeed();

    for (let v = 0; v < 2; ++v) {  // Try each index version.
        t.drop();
        t.ensureIndex({a: 1}, {v: v});
        const S = 100;
        const B = 100;
        for (let x = 0; x < S; x++) {
            let batch = [];
            for (let y = 0; y < B; y++) {
                let i = y + (B * x);
                batch.push({a: i});
            }
            assert.writeOK(t.insert(batch));
        }
        assert.eq(t.count(), S * B);

        let toDrop = [];
        for (let i = 0; i < S * B; ++i) {
            toDrop.push(Random.randInt(10000));  // Dups in the query will be ignored.
        }
        assert.writeOK(t.remove({a: {$in: toDrop}}));
    }
})();