summaryrefslogtreecommitdiff
path: root/jstests/replsets/initial_sync_document_validation.js
blob: 79d06f751406ceb9af2eeeac1412f225093f5629 (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
/**
 * Tests that initial sync does not fail if it inserts documents which don't validate.
 */

(function() {
var name = 'initial_sync_document_validation';
var replSet = new ReplSetTest({
    name: name,
    nodes: 2,
});

replSet.startSet();
replSet.initiate();
var primary = replSet.getPrimary();
var secondary = replSet.getSecondary();

var coll = primary.getDB('test').getCollection(name);
assert.writeOK(coll.insert({_id: 0, x: 1}));
assert.commandWorked(coll.runCommand("collMod", {"validator": {a: {$exists: true}}}));

secondary = replSet.restart(secondary, {startClean: true});
replSet.awaitReplication();
replSet.awaitSecondaryNodes();

assert.eq(1, secondary.getDB("test")[name].count());
assert.docEq({_id: 0, x: 1}, secondary.getDB("test")[name].findOne());

replSet.stopSet();
})();