summaryrefslogtreecommitdiff
path: root/jstests/sharding/conf_server_write_concern_metadata.js
blob: dd15c5cb179b33934e9fe31d9c4ed1ff711d6356 (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
/**
 * Test write concern with w parameter will not cause an error when writes to mongos would trigger
 * writes to config servers (in this test, autosplit is used).
 */
(function() {
    'use strict';

    var st = new ShardingTest({shards: 1, rs: true, other: {chunkSize: 1, enableAutoSplit: true}});

    var mongos = st.s;
    var testDB = mongos.getDB('test');
    var coll = testDB.user;

    assert.commandWorked(st.s0.adminCommand({enableSharding: testDB.getName()}));
    assert.commandWorked(st.s0.adminCommand({shardCollection: coll.getFullName(), key: {x: 1}}));

    var chunkCount = function() {
        return mongos.getDB('config').chunks.find().count();
    };

    var initChunks = chunkCount();
    var currChunks = initChunks;
    var gleObj = null;
    var x = 0;
    var largeStr = new Array(1024 * 128).toString();

    assert.soon(
        function() {
            var bulk = coll.initializeUnorderedBulkOp();
            for (var i = 0; i < 100; i++) {
                bulk.insert({x: x++, largeStr: largeStr});
            }
            assert.writeOK(bulk.execute({w: 'majority', wtimeout: 60 * 1000}));
            currChunks = chunkCount();
            return currChunks > initChunks;
        },
        function() {
            return "currChunks: " + currChunks + ", initChunks: " + initChunks;
        });

    st.stop();
})();