summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-07-29 20:54:43 -0400
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-07-29 21:05:17 -0400
commitccf8a4f2deb3e566c11efb36159c04a0a02e8775 (patch)
tree8375904590aff56885e2a1c89e9db80cabf74ffd
parent7d9d65338f22220d59f57b09c1936ae6da41ac8c (diff)
downloadmongo-ccf8a4f2deb3e566c11efb36159c04a0a02e8775.tar.gz
SERVER-41696 Modify tests depending on the 'ns' field from index specs to no longer have a dependency on it
-rw-r--r--jstests/auth/lib/commands_lib.js3
-rw-r--r--jstests/core/commands_with_uuid.js6
-rw-r--r--jstests/core/index_create_with_nul_in_name.js11
-rw-r--r--jstests/core/list_indexes.js2
-rw-r--r--jstests/libs/sessions_collection.js1
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/do_upgrade_downgrade.js29
-rw-r--r--jstests/multiVersion/libs/sharded_txn_upgrade_downgrade_cluster_shared.js28
-rw-r--r--jstests/noPassthrough/characterize_index_builds_on_restart.js12
-rw-r--r--jstests/noPassthrough/disabled_test_parameters.js2
-rw-r--r--jstests/replsets/index_delete.js1
-rw-r--r--jstests/replsets/mr_nonrepl_coll_in_local_db.js11
11 files changed, 54 insertions, 52 deletions
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js
index 2baac2d2f79..907ea046dd3 100644
--- a/jstests/auth/lib/commands_lib.js
+++ b/jstests/auth/lib/commands_lib.js
@@ -3068,8 +3068,7 @@ var authCommandsLib = {
},
{
testname: "createIndexes",
- command:
- {createIndexes: "x", indexes: [{ns: firstDbName + ".x", key: {a: 1}, name: "a_1"}]},
+ command: {createIndexes: "x", indexes: [{key: {a: 1}, name: "a_1"}]},
teardown: function(db) {
db.x.drop();
},
diff --git a/jstests/core/commands_with_uuid.js b/jstests/core/commands_with_uuid.js
index c64384675c9..ef960448c6b 100644
--- a/jstests/core/commands_with_uuid.js
+++ b/jstests/core/commands_with_uuid.js
@@ -75,9 +75,9 @@ cmd = {
res = db.runCommand(cmd);
assert.commandWorked(res, 'could not run ' + tojson(cmd));
cursor = new DBCommandCursor(db, res);
-cursor.forEach(function(doc) {
- assert.eq(doc.ns, 'test.' + mainCollName);
-});
+assert.eq(1, cursor.toArray().length);
+assert.eq("_id_", cursor.toArray()[0].name);
+assert.eq(bsonWoCompare({"_id": 1}, cursor.toArray()[0].key), 0);
// Ensure passing a UUID to count retrieves results from the correct collection.
cmd = {
diff --git a/jstests/core/index_create_with_nul_in_name.js b/jstests/core/index_create_with_nul_in_name.js
index c4894830fc8..8c8fe14f0fa 100644
--- a/jstests/core/index_create_with_nul_in_name.js
+++ b/jstests/core/index_create_with_nul_in_name.js
@@ -6,9 +6,10 @@
var coll = db.create_index_with_nul_in_name;
coll.drop();
-var idx = {key: {'a': 1}, name: 'foo\0bar', ns: coll.getFullName()};
-
-var res = coll.runCommand('createIndexes', {indexes: [idx]});
-assert.commandFailed(res, tojson(res));
-assert.eq(res.code, 67); // CannotCreateIndex
+const idx = {
+ key: {'a': 1},
+ name: 'foo\0bar'
+};
+assert.commandFailedWithCode(coll.runCommand('createIndexes', {indexes: [idx]}),
+ ErrorCodes.CannotCreateIndex);
}());
diff --git a/jstests/core/list_indexes.js b/jstests/core/list_indexes.js
index b5c3ab4f8b9..040d30e6290 100644
--- a/jstests/core/list_indexes.js
+++ b/jstests/core/list_indexes.js
@@ -63,11 +63,9 @@ assert.commandWorked(coll.ensureIndex({a: 1}, {unique: true}));
specs = cursorGetIndexSpecs(getListIndexesCursor(coll));
assert.eq(2, specs.length);
assert.eq("_id_", specs[0].name);
-assert.eq(coll.getFullName(), specs[0].ns);
assert.eq({_id: 1}, specs[0].key);
assert(!specs[0].hasOwnProperty("unique"));
assert.eq("a_1", specs[1].name);
-assert.eq(coll.getFullName(), specs[1].ns);
assert.eq({a: 1}, specs[1].key);
assert.eq(true, specs[1].unique);
diff --git a/jstests/libs/sessions_collection.js b/jstests/libs/sessions_collection.js
index a7495016d1c..cd8f4a02721 100644
--- a/jstests/libs/sessions_collection.js
+++ b/jstests/libs/sessions_collection.js
@@ -18,7 +18,6 @@ function validateSessionsCollection(conn, collectionExists, indexExists, timeout
if (entry["name"] == "lsidTTLIndex") {
found = true;
- assert.eq(entry["ns"], "config.system.sessions");
assert.eq(entry["key"], {"lastUse": 1});
assert(entry.hasOwnProperty("expireAfterSeconds"));
if (timeout) {
diff --git a/jstests/multiVersion/genericSetFCVUsage/do_upgrade_downgrade.js b/jstests/multiVersion/genericSetFCVUsage/do_upgrade_downgrade.js
index e280a82451e..2551f0b38a7 100644
--- a/jstests/multiVersion/genericSetFCVUsage/do_upgrade_downgrade.js
+++ b/jstests/multiVersion/genericSetFCVUsage/do_upgrade_downgrade.js
@@ -63,21 +63,26 @@ let recreateUniqueIndexes = function(db, secondary) {
let mdb = db.getSiblingDB(d.name);
mdb.getCollectionInfos().forEach(function(c) {
let currentCollection = mdb.getCollection(c.name);
- currentCollection.getIndexes().forEach(function(i) {
- if (i.unique) {
- if (i.v === 1) {
- unique_idx_v1.push(i);
- return;
- }
- unique_idx.push(i);
+ currentCollection.getIndexes().forEach(function(spec) {
+ if (!spec.unique) {
+ return;
+ }
+
+ const ns = d.name + "." + c.name;
+ if (spec.v === 1) {
+ unique_idx_v1.push({ns: ns, spec: spec});
+ } else {
+ unique_idx.push({ns: ns, spec: spec});
}
});
});
});
// Drop and create all v:2 indexes
- for (let idx of unique_idx) {
- let [dbName, collName] = idx.ns.split(".");
+ for (let pair of unique_idx) {
+ const ns = pair.ns;
+ const idx = pair.spec;
+ let [dbName, collName] = ns.split(".");
let res = db.getSiblingDB(dbName).runCommand({dropIndexes: collName, index: idx.name});
assert.commandWorked(res);
res = db.getSiblingDB(dbName).runCommand({
@@ -88,8 +93,10 @@ let recreateUniqueIndexes = function(db, secondary) {
}
// Drop and create all v:1 indexes
- for (let idx of unique_idx_v1) {
- let [dbName, collName] = idx.ns.split(".");
+ for (let pair of unique_idx_v1) {
+ const ns = pair.ns;
+ const idx = pair.spec;
+ let [dbName, collName] = ns.split(".");
let res = db.getSiblingDB(dbName).runCommand({dropIndexes: collName, index: idx.name});
assert.commandWorked(res);
res = db.getSiblingDB(dbName).runCommand({
diff --git a/jstests/multiVersion/libs/sharded_txn_upgrade_downgrade_cluster_shared.js b/jstests/multiVersion/libs/sharded_txn_upgrade_downgrade_cluster_shared.js
index 2c74d3c632e..751175a2689 100644
--- a/jstests/multiVersion/libs/sharded_txn_upgrade_downgrade_cluster_shared.js
+++ b/jstests/multiVersion/libs/sharded_txn_upgrade_downgrade_cluster_shared.js
@@ -116,22 +116,26 @@ function downgradeUniqueIndexesScript(db) {
let mdb = db.getSiblingDB(d.name);
mdb.getCollectionInfos().forEach(function(c) {
let currentCollection = mdb.getCollection(c.name);
- currentCollection.getIndexes().forEach(function(i) {
- if (i.unique) {
- if (i.v === 1) {
- unique_idx_v1.push(i);
- } else {
- unique_idx_v2.push(i);
- }
+ currentCollection.getIndexes().forEach(function(spec) {
+ if (!spec.unique) {
return;
}
+
+ const ns = d.name + "." + c.name;
+ if (spec.v === 1) {
+ unique_idx_v1.push({ns: ns, spec: spec});
+ } else {
+ unique_idx_v2.push({ns: ns, spec: spec});
+ }
});
});
});
// Drop and recreate all v:1 indexes
- for (let idx of unique_idx_v1) {
- let [dbName, collName] = idx.ns.split(".");
+ for (let pair of unique_idx_v1) {
+ const ns = pair.ns;
+ const idx = pair.spec;
+ let [dbName, collName] = ns.split(".");
let res = db.getSiblingDB(dbName).runCommand({dropIndexes: collName, index: idx.name});
assert.commandWorked(res);
res = db.getSiblingDB(dbName).runCommand({
@@ -142,8 +146,10 @@ function downgradeUniqueIndexesScript(db) {
}
// Drop and recreate all v:2 indexes
- for (let idx of unique_idx_v2) {
- let [dbName, collName] = idx.ns.split(".");
+ for (let pair of unique_idx_v2) {
+ const ns = pair.ns;
+ const idx = pair.spec;
+ let [dbName, collName] = ns.split(".");
let res = db.getSiblingDB(dbName).runCommand({dropIndexes: collName, index: idx.name});
assert.commandWorked(res);
res = db.getSiblingDB(dbName).runCommand({
diff --git a/jstests/noPassthrough/characterize_index_builds_on_restart.js b/jstests/noPassthrough/characterize_index_builds_on_restart.js
index 036bd4acbf9..35b0c7c9a7c 100644
--- a/jstests/noPassthrough/characterize_index_builds_on_restart.js
+++ b/jstests/noPassthrough/characterize_index_builds_on_restart.js
@@ -1,9 +1,6 @@
/**
* Characterizes the actions (rebuilds or drops the index) taken upon unfinished indexes when
* restarting mongod from (standalone -> standalone) and (replica set member -> standalone).
- * Additionally, the primary will use the 'disableIndexSpecNamespaceGeneration' server test
- * parameter to prevent index specs from having the 'ns' field to test the absence of the 'ns' field
- * on a replica set with unfinished indexes during restart.
*
* @tags: [requires_replication, requires_persistence, requires_majority_read_concern]
*/
@@ -79,11 +76,6 @@ function startIndexBuildOnSecondaryAndLeaveUnfinished(primaryDB, writeConcern, s
assert.commandWorked(secondaryDB.adminCommand(
{configureFailPoint: "leaveIndexBuildUnfinishedForShutdown", mode: "alwaysOn"}));
- // Do not generate the 'ns' field for index specs on the primary to test the absence of the
- // field on restart.
- assert.commandWorked(
- primaryDB.adminCommand({setParameter: 1, disableIndexSpecNamespaceGeneration: 1}));
-
try {
let res = assert.commandWorked(primaryDB.runCommand(
{createIndexes: collName, indexes: indexesToBuild, writeConcern: {w: writeConcern}}));
@@ -143,7 +135,6 @@ function checkForIndexRebuild(mongod, indexName, shouldExist) {
let foundIndexEntry = false;
for (let index = 0; index < collIndexes.length; index++) {
- assert.eq(true, collIndexes[index].hasOwnProperty('ns'));
if (collIndexes[index].name == indexName) {
foundIndexEntry = true;
break;
@@ -224,9 +215,6 @@ function secondaryToStandaloneTest() {
mongod = restartStandalone(primary);
let specs = mongod.getDB(dbName).getCollection(collName).getIndexes();
assert.eq(specs.length, 5);
- for (let index = 0; index < specs.length; index++) {
- assert.eq(true, specs[index].hasOwnProperty('ns'));
- }
shutdownStandalone(mongod);
}
diff --git a/jstests/noPassthrough/disabled_test_parameters.js b/jstests/noPassthrough/disabled_test_parameters.js
index c34d9ae8a6a..afb9591128d 100644
--- a/jstests/noPassthrough/disabled_test_parameters.js
+++ b/jstests/noPassthrough/disabled_test_parameters.js
@@ -27,7 +27,7 @@ assertFails({
assertStarts({
'setParameter': {
enableTestCommands: v,
- disableIndexSpecNamespaceGeneration: 'false',
+ enableIndexBuildsCoordinatorForCreateIndexesCommand: 'false',
},
});
});
diff --git a/jstests/replsets/index_delete.js b/jstests/replsets/index_delete.js
index 5f64979dbc3..59486bb2932 100644
--- a/jstests/replsets/index_delete.js
+++ b/jstests/replsets/index_delete.js
@@ -105,7 +105,6 @@ master.getCollection('local.oplog.rs').find().forEach(function(entry) {
assert(entry.o2.name);
assert(entry.o2.key);
assert.eq(entry.o2.v, 2);
- assert.eq(entry.o2.ns, dbName + "." + collName);
assert.eq(entry.ns, dbName + ".$cmd");
}
});
diff --git a/jstests/replsets/mr_nonrepl_coll_in_local_db.js b/jstests/replsets/mr_nonrepl_coll_in_local_db.js
index 8348b65e09a..a6d6cad7e7a 100644
--- a/jstests/replsets/mr_nonrepl_coll_in_local_db.js
+++ b/jstests/replsets/mr_nonrepl_coll_in_local_db.js
@@ -61,10 +61,15 @@ createdCollections.forEach(function(createdCollectionName) {
return;
}
+ const periodIndex = createdCollectionName.indexOf(".");
+ const dbName = createdCollectionName.substring(0, periodIndex);
+ const collName = createdCollectionName.substring(periodIndex + 1);
+
// Search for a log entry for the creation of this collection.
- const oplogEntries = primaryDB.getSiblingDB("local")["oplog.rs"]
- .find({op: "c", "o.idIndex.ns": createdCollectionName})
- .toArray();
+ const oplogEntries =
+ primaryDB.getSiblingDB("local")["oplog.rs"]
+ .find({op: "c", ns: dbName + ".$cmd", "o.create": collName, "o.idIndex.name": "_id_"})
+ .toArray();
if (createdCollectionName.startsWith("local.")) {
// We do not want to see any replication of "local" collections.
assert.eq(oplogEntries.length,