diff options
author | Benety Goh <benety@mongodb.com> | 2020-02-22 05:51:48 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-22 11:22:22 +0000 |
commit | 9b7b179d83d4515f87e425c32a33b3a78f087278 (patch) | |
tree | 04dab9c8ef887c32251ef8a713096a929de9ab3a | |
parent | 9916fbb11fee1c251d0a0cd19acb9d766302e9c8 (diff) | |
download | mongo-9b7b179d83d4515f87e425c32a33b3a78f087278.tar.gz |
SERVER-46229 add mutlikey index to multi-document transaction test for index creation
-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); }; |