summaryrefslogtreecommitdiff
path: root/jstests/gle/create_index_gle.js
blob: 18732fb50fafa8f283a8a38207e656b1c098ae05 (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
44
45
46
47
48
load('jstests/replsets/rslib.js');
(function () {
"use strict";

var st = new ShardingTest({
    shards: {
        rs0: {
            nodes: { n0: {}, n1: { rsConfig: { priority: 0 } } },
            oplogSize: 10,
        }
    },
});
var replTest = st.rs0;

var config = replTest.getReplSetConfig();
// Add a delay long enough so getLastError would actually 'wait' for write concern.
config.members[1].slaveDelay = 3;
config.version = 2;

reconfig(replTest, config, true);

assert.soon(function() {
    var secConn = replTest.getSecondary();
    var config = secConn.getDB('local').system.replset.findOne();
    return config.members[1].slaveDelay == 3;
});

replTest.awaitSecondaryNodes();

var testDB = st.s.getDB('test');
testDB.adminCommand({ connPoolSync: 1 });

var secConn = replTest.getSecondary();
var testDB2 = secConn.getDB('test');

testDB.user.insert({ x: 1 });

testDB.user.ensureIndex({ x: 1 });
assert.gleOK(testDB.runCommand({ getLastError: 1, w: 2 }));

var priIdx = testDB.user.getIndexes();
var secIdx = testDB2.user.getIndexes();

assert.eq(priIdx.length, secIdx.length, 'pri: ' + tojson(priIdx) + ', sec: ' + tojson(secIdx));

st.stop();

}());