summaryrefslogtreecommitdiff
path: root/jstests/replsets/initial_sync_clone_multikey.js
blob: 8c4416beeaae4d68fbb3102b695f099386155a8c (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
/**
 * Test initial sync cloning of a collection that contains a multikey index.
 */
(function() {
"use strict";

const replTest = new ReplSetTest({nodes: 1});
replTest.startSet();
replTest.initiate();

const dbName = jsTest.name();
const collName = "test";

const primary = replTest.getPrimary();
const primaryDB = primary.getDB(dbName);

jsTestLog("Creating the collection and an index.");
assert.commandWorked(primaryDB.createCollection(collName));
assert.commandWorked(primaryDB[collName].createIndex({"x": 1}, {background: true}));

// Make the index multikey.
primaryDB[collName].insert({x: [1, 2]});

jsTestLog("Adding a secondary node to do the initial sync.");
replTest.add();

jsTestLog("Re-initiating replica set with the new secondary.");
replTest.reInitiate();

// Wait until initial sync completes.
jsTestLog("Waiting until initial sync completes.");
replTest.awaitSecondaryNodes();
replTest.awaitReplication();
replTest.stopSet();
})();