diff options
-rw-r--r-- | jstests/core/txns/create_indexes.js | 7 | ||||
-rw-r--r-- | jstests/libs/create_index_txn_helpers.js | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/jstests/core/txns/create_indexes.js b/jstests/core/txns/create_indexes.js index 02fe8a00b89..67dbb0aa297 100644 --- a/jstests/core/txns/create_indexes.js +++ b/jstests/core/txns/create_indexes.js @@ -28,7 +28,14 @@ let doCreateIndexesTest = function(explicitCollectionCreate) { session.commitTransaction(); assert.eq(sessionColl.find({}).itcount(), 1); assert.eq(sessionColl.getIndexes().length, 2); + sessionColl.drop({writeConcern: {w: "majority"}}); + jsTest.log("Testing multikey createIndexes in a transaction"); + session.startTransaction({writeConcern: {w: "majority"}}); + createIndexAndCRUDInTxn(sessionDB, collName, explicitCollectionCreate, true); + session.commitTransaction(); + assert.eq(sessionColl.find({}).itcount(), 1); + assert.eq(sessionColl.getIndexes().length, 2); sessionColl.drop({writeConcern: {w: "majority"}}); jsTest.log("Testing multiple createIndexess in a transaction"); diff --git a/jstests/libs/create_index_txn_helpers.js b/jstests/libs/create_index_txn_helpers.js index c9b239fa80b..33b98a5f069 100644 --- a/jstests/libs/create_index_txn_helpers.js +++ b/jstests/libs/create_index_txn_helpers.js @@ -11,13 +11,17 @@ const conflictingIndexSpecs = { name: "a_1" }; -const createIndexAndCRUDInTxn = function(sessionDB, collName, explicitCollCreate) { +const createIndexAndCRUDInTxn = function(sessionDB, collName, explicitCollCreate, multikeyIndex) { if (explicitCollCreate) { assert.commandWorked(sessionDB.runCommand({create: collName})); } let sessionColl = sessionDB[collName]; assert.commandWorked(sessionColl.runCommand({createIndexes: collName, indexes: [indexSpecs]})); - assert.commandWorked(sessionColl.insert({a: 1})); + if (multikeyIndex) { + assert.commandWorked(sessionColl.insert({a: [1, 2, 3]})); + } else { + assert.commandWorked(sessionColl.insert({a: 1})); + } assert.eq(sessionColl.find({a: 1}).itcount(), 1); assert.eq(sessionColl.find({}).itcount(), 1); }; |