summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuoxin Xu <ruoxin.xu@mongodb.com>2020-05-20 13:56:22 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-21 22:07:46 +0000
commit78f639cd7d7c4698d2691f75ad58acd7687a7f1c (patch)
treeea4a107e1de120af5c09db5e2d60d4c795a59db1
parent8e858d55fca372bd220fde42a3458f78bb5271e5 (diff)
downloadmongo-78f639cd7d7c4698d2691f75ad58acd7687a7f1c.tar.gz
SERVER-48317 Modify profile_hide_index.js to use its own database
(cherry picked from commit 4fae9dc08e0a2da70f7a80f68e7352c7d6a5ceb0)
-rw-r--r--jstests/core/profile_hide_index.js37
-rw-r--r--jstests/libs/parallelTester.js1
2 files changed, 22 insertions, 16 deletions
diff --git a/jstests/core/profile_hide_index.js b/jstests/core/profile_hide_index.js
index 2e700bfa2e3..f01267716ea 100644
--- a/jstests/core/profile_hide_index.js
+++ b/jstests/core/profile_hide_index.js
@@ -16,11 +16,14 @@
load("jstests/libs/collection_drop_recreate.js"); // For assert[Drop|Create]Collection.
load("jstests/libs/profiler.js"); // For profilerHasSingleMatchingEntryOrThrow.
+// Should use a special db in this test so that it can be run in parallel tests.
+const testDb = db.getSiblingDB("profile_hide_index");
+
const collName = "profile_hide_index";
-const coll = assertDropAndRecreateCollection(db, collName);
+const coll = assertDropAndRecreateCollection(testDb, collName);
function setPostCommandFailpoint({mode, options}) {
- assert.commandWorked(db.adminCommand(
+ assert.commandWorked(testDb.adminCommand(
{configureFailPoint: "waitAfterCommandFinishesExecution", mode: mode, data: options}));
}
@@ -40,10 +43,12 @@ function testHiddenFlagInCurrentOp({runCmd, isCommandExpected, cmdName}) {
assert.soon(
function() {
- const inprogs =
- db.getSiblingDB("admin")
- .aggregate([{$currentOp: {}}, {$match: {"ns": "test.profile_hide_index"}}])
- .toArray();
+ const inprogs = testDb.getSiblingDB("admin")
+ .aggregate([
+ {$currentOp: {}},
+ {$match: {"ns": "profile_hide_index.profile_hide_index"}}
+ ])
+ .toArray();
return inprogs.length > 0 && isCommandExpected(inprogs);
},
function() {
@@ -61,7 +66,7 @@ function testHiddenFlagInCurrentOp({runCmd, isCommandExpected, cmdName}) {
// Tests that "hidden_index" collMod command showed up in currentOp.
testHiddenFlagInCurrentOp({
- runCmd: `assert.commandWorked(db.runCommand({
+ runCmd: `assert.commandWorked(db.getSiblingDB("profile_hide_index").runCommand({
"collMod": "profile_hide_index",
"index": {"name": "b_1", "hidden": true}}));`,
isCommandExpected: function(inprogs) {
@@ -75,7 +80,7 @@ testHiddenFlagInCurrentOp({
// Tests that createIndex command with 'hidden' set to true showed up in currentOp.
testHiddenFlagInCurrentOp({
- runCmd: `assert.commandWorked(db.runCommand({
+ runCmd: `assert.commandWorked(db.getSiblingDB("profile_hide_index").runCommand({
"createIndexes": "profile_hide_index",
"indexes": [{"key" : {c: 1}, "name": "c_1", "hidden": true}]}))`,
isCommandExpected: function(inprogs) {
@@ -92,26 +97,26 @@ testHiddenFlagInCurrentOp({
// Tests that 'hidden_index' commands can be found in the profiler;
//
// Should turn off profiling before dropping system.profile collection.
-db.setProfilingLevel(0);
-db.system.profile.drop();
-db.setProfilingLevel(2);
+testDb.setProfilingLevel(0);
+testDb.system.profile.drop();
+testDb.setProfilingLevel(2);
assert.commandWorked(coll.createIndex({b: 1}, {hidden: true}));
profilerHasSingleMatchingEntryOrThrow({
- profileDB: db,
+ profileDB: testDb,
filter: {
- "ns": "test.profile_hide_index",
+ "ns": "profile_hide_index.profile_hide_index",
"command.createIndexes": "profile_hide_index",
"command.indexes.hidden": true
}
});
assert.commandWorked(
- db.runCommand({"collMod": coll.getName(), "index": {"name": "b_1", "hidden": false}}));
+ testDb.runCommand({"collMod": coll.getName(), "index": {"name": "b_1", "hidden": false}}));
profilerHasSingleMatchingEntryOrThrow({
- profileDB: db,
+ profileDB: testDb,
filter: {
- "ns": "test.profile_hide_index",
+ "ns": "profile_hide_index.profile_hide_index",
"command.collMod": "profile_hide_index",
"command.index.hidden": false,
}
diff --git a/jstests/libs/parallelTester.js b/jstests/libs/parallelTester.js
index 0b257e935ef..2a8f2ba5863 100644
--- a/jstests/libs/parallelTester.js
+++ b/jstests/libs/parallelTester.js
@@ -276,6 +276,7 @@ if (typeof _threadInject != "undefined") {
parallelFilesDir + "/profile_find.js",
parallelFilesDir + "/profile_findandmodify.js",
parallelFilesDir + "/profile_getmore.js",
+ parallelFilesDir + "/profile_hide_index.js",
parallelFilesDir + "/profile_insert.js",
parallelFilesDir + "/profile_list_collections.js",
parallelFilesDir + "/profile_list_indexes.js",