0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 20:49:10 +01:00
mongodb/jstests/replsets/initial_sync_clone_multikey.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

33 lines
954 B
JavaScript

/**
* Test initial sync cloning of a collection that contains a multikey index.
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
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}));
// 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();