summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorMisha Tyulenev <misha.tyulenev@mongodb.com>2020-07-14 20:31:51 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-13 00:17:26 +0000
commitc6e27045ebf953bb899eba2a3c6d96d3a6e642d8 (patch)
tree962da9d187c6bf223408138d656d1237f4e8d410 /jstests
parent14bd9654e676f82677d5d669f1d1ac09a8c1ac54 (diff)
downloadmongo-c6e27045ebf953bb899eba2a3c6d96d3a6e642d8.tar.gz
SERVER-49092 fail with MovePrimaryInProgress in createIndexes command
(cherry picked from commit f5396269916adaf6b3539fb804ee20ae54950df7)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/move_primary_with_writes.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/jstests/sharding/move_primary_with_writes.js b/jstests/sharding/move_primary_with_writes.js
index b9827b7e672..42fb2763ea6 100644
--- a/jstests/sharding/move_primary_with_writes.js
+++ b/jstests/sharding/move_primary_with_writes.js
@@ -22,19 +22,18 @@ function createCollections() {
assert.commandWorked(st.getDB(dbName).runCommand({dropDatabase: 1}));
let db = st.getDB(dbName);
- const unshardedFooIndexes = [{key: {a: 1}, name: 'fooIndex'}];
- const shardedBarIndexes = [{key: {a: 1}, name: 'barIndex'}];
+ const unshardedFooIndexes = [{key: {a: 1}, name: 'fooIndex_a'}];
+ const shardedBarIndexes = [{key: {a: 1}, name: 'barIndex_a'}];
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
assert.commandWorked(st.s.adminCommand({movePrimary: dbName, to: st.shard0.shardName}));
assert.commandWorked(db.createCollection('unshardedFoo'));
- assert.commandWorked(db.createView('viewOnFoo', 'unshardedFoo', [{$match: {}}]));
assert.commandWorked(db.createCollection('shardedBar'));
for (let i = 0; i < 3; i++) {
- assert.commandWorked(db.unshardedFoo.insert({_id: i, a: i}));
- assert.commandWorked(db.shardedBar.insert({_id: i, a: i}));
+ assert.commandWorked(db.unshardedFoo.insert({_id: i, a: i, b: i}));
+ assert.commandWorked(db.shardedBar.insert({_id: i, a: i, b: i}));
}
assert.commandWorked(
@@ -43,6 +42,9 @@ function createCollections() {
assert.commandWorked(db.adminCommand({enableSharding: dbName}));
assert.commandWorked(db.adminCommand({shardCollection: dbName + '.shardedBar', key: {_id: 1}}));
+
+ assert.commandWorked(db.createView('unshardedFooView', 'unshardedFoo', [{$match: {}}]));
+ assert.commandWorked(db.createView('shardedBarView', 'shardedBar', [{$match: {}}]));
}
function mapFunc() {
@@ -98,16 +100,16 @@ function buildCommands(collName) {
},
{command: {create: "testCollection"}, alwaysFail: true},
{
- command: {collMod: "viewOnFoo", viewOn: "unshardedFoo", pipeline: [{$match: {_id: 1}}]},
- alwaysFail: true
+ command: {createIndexes: collName, indexes: [{key: {b: 1}, name: collName + "Idx_b"}]},
+ alwaysFail: false
},
];
return commands;
}
-function buildDDLCommands() {
+function buildDDLCommands(collName) {
const commands = [{
- command: {renameCollection: "testdb.unshardedFoo", to: "testdb.testCollection"},
+ command: {renameCollection: dbName + "." + collName, to: dbName + ".testCollection"},
alwaysFail: true
}];
return commands;
@@ -152,7 +154,7 @@ function testMovePrimary(failpoint, fromShard, toShard, db, shouldFail, sharded)
awaitShell();
}
-function testMovePrimaryDDL(failpoint, fromShard, toShard, db, shouldFail) {
+function testMovePrimaryDDL(failpoint, fromShard, toShard, db, shouldFail, sharded) {
let codeToRunInParallelShell = '{ db.getSiblingDB("admin").runCommand({movePrimary: "' +
dbName + '", to: "' + toShard.name + '"}); }';
@@ -164,7 +166,14 @@ function testMovePrimaryDDL(failpoint, fromShard, toShard, db, shouldFail) {
waitForFailpoint("Hit " + failpoint, 1);
clearRawMongoProgramOutput();
- buildDDLCommands().forEach(commandObj => {
+ let collName;
+ if (sharded) {
+ collName = "shardedBar";
+ } else {
+ collName = "unshardedFoo";
+ }
+
+ buildDDLCommands(collName).forEach(commandObj => {
if (shouldFail) {
jsTestLog("running command: " + tojson(commandObj.command) +
",\nshoudFail: " + shouldFail);
@@ -201,7 +210,7 @@ verifyDocuments(fromShard.getDB(dbName), 0);
createCollections();
fromShard = st.getPrimaryShard(dbName);
toShard = st.getOther(fromShard);
-testMovePrimaryDDL('hangInCloneStage', fromShard, toShard, st.s.getDB("admin"), true);
+testMovePrimaryDDL('hangInCloneStage', fromShard, toShard, st.s.getDB("admin"), false, true);
createCollections();
fromShard = st.getPrimaryShard(dbName);