diff options
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/views/views_creation.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/jstests/core/views/views_creation.js b/jstests/core/views/views_creation.js index 2b5316ad400..9af06a3bc4e 100644 --- a/jstests/core/views/views_creation.js +++ b/jstests/core/views/views_creation.js @@ -13,6 +13,8 @@ (function() { "use strict"; +load('jstests/multiVersion/libs/verify_versions.js'); // for getBinVersion() + // For arrayEq. load("jstests/aggregation/extras/utils.js"); @@ -27,7 +29,7 @@ assert.eq(0, collNames.length, tojson(collNames)); // You cannot create a view that starts with 'system.'. assert.commandFailedWithCode(viewsDB.runCommand({create: "system.special", viewOn: "collection"}), ErrorCodes.InvalidNamespace, - "Created an illegal view named 'system.views'"); + "Created an illegal view named 'system.special'"); // Collections that start with 'system.' that are not special to MongoDB fail with a different // error code. @@ -35,6 +37,19 @@ assert.commandFailedWithCode(viewsDB.runCommand({create: "system.foo", viewOn: " ErrorCodes.InvalidNamespace, "Created an illegal view named 'system.foo'"); +const mongodBinVersion = viewsDB.getMongo().getBinVersion(); +if (MongoRunner.areBinVersionsTheSame(mongodBinVersion, "latest")) { + // Attempting to create a view on a database's views collection namespace is specially handled + // because it can deadlock. Only running on v5.0 b/c v4.4 doesn't fail user creation of the + // system.views namespace. + const errRes = assert.commandFailedWithCode( + viewsDB.runCommand({create: "system.views", viewOn: "collection"}), + ErrorCodes.InvalidNamespace, + "Created an illegal view named <db>.system.views"); + assert((errRes.errmsg.indexOf("Cannot create a view called") > -1), + "Unexpected errmsg: " + tojson(errRes)); +} + // Create a collection for test purposes. assert.commandWorked(viewsDB.runCommand({create: "collection"})); |