summaryrefslogtreecommitdiff
path: root/jstests/repl/repl17.js
blob: cd62e6c7ac6af4f861df71d4d2a4593f9bb13c51 (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
// Test collection rename during initial sync.
// SERVER-4941

if (0) {  // SERVER-4941

    rt = new ReplTest("repl17tests");

    master = rt.start(true);
    md = master.getDB('d');

    for (i = 0; i < 1000; ++i) {
        md['' + i].save({});
    }

    slave = rt.start(false);
    sd = slave.getDB('d');

    function checkSlaveCount(collection, expectedCount) {
        var count = sd[collection].count();
        var debug = false;
        if (debug) {
            print(collection + ': ' + count);
        }
        return count == expectedCount;
    }

    // Wait for the slave to start cloning
    assert.soon(function() {
        return checkSlaveCount('0', 1);
    });

    assert.commandWorked(md['999'].renameCollection('renamed'));

    // Check for renamed collection on slave.
    assert.soon(function() {
        return checkSlaveCount('999', 0) && checkSlaveCount('renamed', 1);
    });

    rt.stop();
}