diff options
| author | William Schultz <william.schultz@mongodb.com> | 2020-01-13 23:50:13 +0000 |
|---|---|---|
| committer | evergreen <evergreen@mongodb.com> | 2020-01-13 23:50:13 +0000 |
| commit | ffe43eabfb262487b1ccc0403138744e361d8c93 (patch) | |
| tree | 7e1b9c7987520fcb4d1a1ed289bc9d612a3d64ef /jstests | |
| parent | 0460c5964375a50df62811e36a40fc5abf8c7a5a (diff) | |
| download | mongo-ffe43eabfb262487b1ccc0403138744e361d8c93.tar.gz | |
SERVER-42484 Add test to ensure we are inside a WriteUnitOfWork when writing index keys during initial sync collection cloning
(cherry picked from commit c41af3e315a115b04a53706837d36a729d174fc3)
Diffstat (limited to 'jstests')
| -rw-r--r-- | jstests/replsets/initial_sync_clone_multikey.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/replsets/initial_sync_clone_multikey.js b/jstests/replsets/initial_sync_clone_multikey.js new file mode 100644 index 00000000000..8353780ccba --- /dev/null +++ b/jstests/replsets/initial_sync_clone_multikey.js @@ -0,0 +1,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(); +})(); |
