0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-54751: Create disallow jstest for reshard and drop collection commands

This commit is contained in:
Jordi Serra Torrens 2021-03-24 16:26:41 +00:00 committed by Evergreen Agent
parent 5a14b1d645
commit a3cd9c28cc

View File

@ -0,0 +1,60 @@
/**
* Tests that a drop can't happen while resharding is in progress.
*
* @tags: [
* requires_fcv_49,
* ]
*/
(function() {
"use strict";
load("jstests/libs/fail_point_util.js");
load('jstests/libs/parallel_shell_helpers.js');
function awaitReshardingStarted() {
assert.soon(() => {
const op = st.admin
.aggregate([
{$currentOp: {allUsers: true, localOps: true}},
{$match: {"command.reshardCollection": ns}},
])
.toArray()[0];
return op !== undefined;
}, "failed to find reshardCollection in $currentOp output");
}
var st = new ShardingTest({
shards: 1,
config: 1,
mongos: 1,
mongosOptions: {setParameter: {featureFlagResharding: true}},
configOptions: {setParameter: {featureFlagResharding: true}}
});
const dbName = "test";
const collName = "foo";
const ns = dbName + "." + collName;
const db = st.s.getDB(dbName);
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}}));
const pauseCoordinatorBeforeDecisionPersistedFailpoint = configureFailPoint(
st.configRS.getPrimary(), "reshardingPauseCoordinatorBeforeDecisionPersisted");
const awaitReshardResult = startParallelShell(
funWithArgs(function(ns) {
assert.commandWorked(db.adminCommand({reshardCollection: ns, key: {newKey: 1}}));
}, ns), st.s.port);
awaitReshardingStarted();
assert.commandFailedWithCode(db.runCommand({drop: collName, maxTimeMS: 5000}),
ErrorCodes.MaxTimeMSExpired);
pauseCoordinatorBeforeDecisionPersistedFailpoint.off();
awaitReshardResult();
st.stop();
})();