diff options
author | Mindaugas Malinauskas <mindaugas.malinauskas@mongodb.com> | 2022-10-20 17:01:54 +0100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-21 16:25:40 +0000 |
commit | 1b03349f96d92d877a69269043bed85b26383ef3 (patch) | |
tree | 2660840324a47543f74fca6cc2d019a59cada762 | |
parent | 4cebccde5e2af5ac2e518ababc785505ecd299db (diff) | |
download | mongo-1b03349f96d92d877a69269043bed85b26383ef3.tar.gz |
SERVER-70722 Made view_resolution_namespace_collision.js to use uniquely named test database
-rw-r--r-- | jstests/aggregation/view_resolution_namespace_collision.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/jstests/aggregation/view_resolution_namespace_collision.js b/jstests/aggregation/view_resolution_namespace_collision.js index 5075336aae0..497ac7d0a6e 100644 --- a/jstests/aggregation/view_resolution_namespace_collision.js +++ b/jstests/aggregation/view_resolution_namespace_collision.js @@ -7,24 +7,24 @@ (function() { "use strict"; -const dbName = "test"; -const testDB = db.getSiblingDB(dbName); -const siblingDBName = "otherDB"; +const testDBName = jsTestName(); +const testDB = db.getSiblingDB(testDBName); +const siblingDBName = jsTestName() + "_otherDB"; const siblingDB = testDB.getSiblingDB(siblingDBName); // Since cross-db $out only works against existing databases in a sharded environment, we create a // dummy collection on 'siblingDB' to allow this test to run in a sharded environment. assert.commandWorked(siblingDB.foo.insert({})); -const sourceName = jsTestName(); -const otherCollName = jsTestName() + "_other_coll"; -const collidingName = "collision_collection"; -const sourceColl = testDB[sourceName]; +const sourceCollName = "source"; +const otherCollName = "other_coll"; +const collidingCollName = "collision_collection"; +const sourceColl = testDB[sourceCollName]; const otherColl = testDB[otherCollName]; sourceColl.drop(); otherColl.drop(); -testDB[collidingName].drop(); +testDB[collidingCollName].drop(); assert.commandWorked(sourceColl.insert({_id: 0})); assert.commandWorked(otherColl.insert({_id: 0, notsecret: 1, secret: "really secret"})); @@ -32,28 +32,28 @@ assert.commandWorked(otherColl.insert({_id: 0, notsecret: 1, secret: "really sec // Create a view on 'testDB' that will have the same name as the collection that $merge/$out // will create. assert.commandWorked(testDB.runCommand( - {create: collidingName, viewOn: otherCollName, pipeline: [{$project: {secret: 0}}]})); + {create: collidingCollName, viewOn: otherCollName, pipeline: [{$project: {secret: 0}}]})); // Verify that the view gets resolved correctly when performing a cross database aggregation where // the $lookup references a view on the source database and the $merge/$out references a collection // on the target database with the same name as the view. const lookupStage = { - $lookup: {from: collidingName, localField: "_id", foreignField: "_id", as: "matches"} + $lookup: {from: collidingCollName, localField: "_id", foreignField: "_id", as: "matches"} }; const withoutWrite = sourceColl.aggregate([lookupStage]).toArray(); const mergeStage = { - $merge: {into: {db: siblingDBName, coll: collidingName}} + $merge: {into: {db: siblingDBName, coll: collidingCollName}} }; const outStage = { - $out: {db: siblingDBName, coll: collidingName} + $out: {db: siblingDBName, coll: collidingCollName} }; // The aggregate should always use the view on 'testDB', not an empty collection on 'siblingDB'. for (const writeStage of [mergeStage, outStage]) { sourceColl.aggregate([lookupStage, writeStage]).toArray(); - const withWrite = siblingDB[collidingName].find().toArray(); + const withWrite = siblingDB[collidingCollName].find().toArray(); assert.eq(withoutWrite, withWrite); - siblingDB[collidingName].drop(); + siblingDB[collidingCollName].drop(); } siblingDB.dropDatabase(); |