summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2020-03-19 09:46:20 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-19 14:51:44 +0000
commit904bae6fe79f6da9565316b253252e7925e89f2e (patch)
tree3b7da8cbe0f7652d4b6bcc61b576684b7150d206 /jstests/noPassthroughWithMongod
parent304101880b6a4abc1cd1229aaa0d69a81d364ae8 (diff)
downloadmongo-904bae6fe79f6da9565316b253252e7925e89f2e.tar.gz
SERVER-46945: Correct FCV-aware error messages for overlong collection names.
Remove test coverage that exercises cases where namespace length approaches the bson document size limit. (cherry picked from commit cab9719304212aa0de423816f03c1f9e0cd1fb6b)
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js119
1 files changed, 0 insertions, 119 deletions
diff --git a/jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js b/jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js
deleted file mode 100644
index cdfd1bcfc29..00000000000
--- a/jstests/noPassthroughWithMongod/modify_metadata_when_durable_catalog_entry_full.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Tests that basic operations can be performed while the metadata document in the catalog is at the
- * size of the BSON document limit.
- */
-(function() {
-'use strict';
-
-const dbName = 'modify_metadata_when_full';
-const testDB = db.getSiblingDB(dbName);
-
-/**
- * Returns the largest size of a collection name length possible where creating a collection with
- * one more character would fail.
- */
-function createUntilFails(db, startingSize, increment) {
- if (increment == 1) {
- let newSize = startingSize;
- let collName = 'a'.repeat(newSize);
-
- while (db.createCollection(collName).ok) {
- assert.eq(true, db.getCollection(collName).drop());
-
- newSize++;
- collName = 'a'.repeat(newSize);
- }
-
- // Subtract one to get the largest possible collection name length.
- newSize -= 1;
- return newSize;
- }
-
- let newSize = startingSize + increment;
- let collName = 'a'.repeat(newSize);
-
- let res = db.createCollection(collName);
- if (res.ok) {
- assert.eq(true, db.getCollection(collName).drop());
- return createUntilFails(db, newSize, increment);
- } else {
- assert.eq("BSONObjectTooLarge", res.codeName);
- return createUntilFails(db, startingSize, Math.floor(increment / 2));
- }
-}
-
-/*
- * Creates the largest possible collection in terms of name length and returns it.
- */
-function createLargeCollection(db) {
- // Divide by two because 'ns' field is stored twice in the catalog.
- const maxBsonObjectSize = db.isMaster().maxBsonObjectSize / 2;
- let maxCollNameSize = maxBsonObjectSize;
- let maxCollName = 'a'.repeat(maxCollNameSize);
-
- assert.commandWorked(testDB.createCollection(maxCollName));
- assert.eq(true, testDB.getCollection(maxCollName).drop());
-
- maxCollNameSize = createUntilFails(db, maxCollNameSize, 1000);
-
- // Take away a few characters and ensure the collection creation works.
- maxCollName = 'b'.repeat(maxCollNameSize - 10);
-
- // Add a couple extra characters and ensure the collection creation fails.
- let nameTooBig = 'c'.repeat(maxCollNameSize + 10);
- assert.commandFailedWithCode(testDB.createCollection(nameTooBig),
- ErrorCodes.BSONObjectTooLarge);
-
- assert.commandWorked(testDB.createCollection(maxCollName));
- return testDB.getCollection(maxCollName);
-}
-
-let largeColl = createLargeCollection(testDB);
-
-// Ensure creating another collection works.
-let smallCollName = 'd'.repeat(10000);
-assert.commandWorked(testDB.createCollection(smallCollName));
-let smallColl = testDB.getCollection(smallCollName);
-
-// The 'top' command should succeed even with a long collection name.
-assert.commandWorked(largeColl.getDB().adminCommand('top'));
-
-// We should be able to add another collection with a long name successfully. After doing so, then
-// the amount of data which Top needs to return will exceed the maximum BSON size, causing the
-// command to fail.
-const secondLargeCollName = 'e'.repeat(largeColl.getName().length);
-assert.commandWorked(testDB.createCollection(secondLargeCollName));
-const secondLargeColl = testDB.getCollection(secondLargeCollName);
-assert.commandFailedWithCode(testDB.adminCommand('top'), [13548, ErrorCodes.BSONObjectTooLarge]);
-
-// Adding indexes to the large collection should fail but not crash the server.
-assert.commandFailedWithCode(largeColl.createIndex({x: 1}), ErrorCodes.BSONObjectTooLarge);
-assert.commandWorked(smallColl.createIndex({x: 1}));
-
-// Inserting documents should work because it doesn't interact with the metadata document in the
-// catalog.
-assert.commandWorked(largeColl.insertMany([{x: 1}, {y: 2}, {z: 3}]));
-assert.commandWorked(smallColl.insertMany([{x: 1}, {y: 2}, {z: 3}]));
-
-// Renaming the collection should work to get ourselves out of situations where the collection name
-// is too long for operations.
-let largeCollName = largeColl.getFullName();
-let adminDB = db.getSiblingDB('admin');
-assert.commandWorked(adminDB.runCommand(
- {renameCollection: largeCollName, to: 'modify_metadata_when_full.smallName'}));
-assert.commandWorked(adminDB.runCommand(
- {renameCollection: 'modify_metadata_when_full.smallName', to: largeCollName}));
-
-// Renaming the small collection should fail because it has one more index than the large
-// collection.
-let otherLargeCollName = 'modify_metadata_when_full.' +
- 'f'.repeat(largeColl.getName().length);
-assert.commandFailedWithCode(
- adminDB.runCommand({renameCollection: smallColl.getFullName(), to: otherLargeCollName}),
- ErrorCodes.BSONObjectTooLarge);
-
-// Dropping both collections should work.
-assert.eq(true, largeColl.drop());
-assert.eq(true, smallColl.drop());
-assert.eq(true, secondLargeColl.drop());
-}());