diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-11-13 22:19:37 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-19 01:26:57 +0000 |
commit | 73d1a6f368b04161dce7c0afbcea23efb52e2070 (patch) | |
tree | 122e4b1f12cf13cd48e7b1e5bc0da29a06030c96 /jstests | |
parent | dff0aa11f53e6fdf104167f36cc0ab89cdd8f6d2 (diff) | |
download | mongo-73d1a6f368b04161dce7c0afbcea23efb52e2070.tar.gz |
SERVER-52543 Define listCollections in IDL
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/list_collections1.js | 36 | ||||
-rw-r--r-- | jstests/core/list_namespaces_invalidation.js | 4 |
2 files changed, 38 insertions, 2 deletions
diff --git a/jstests/core/list_collections1.js b/jstests/core/list_collections1.js index 39445a3ff91..700407c0843 100644 --- a/jstests/core/list_collections1.js +++ b/jstests/core/list_collections1.js @@ -243,6 +243,42 @@ assert(cursor.hasNext()); assert.eq(1, cursor.objsLeftInBatch()); // +// Test that batches are limited to ~16 MB +// + +assert.commandWorked(mydb.dropDatabase()); +const validator = { + $jsonSchema: { + bsonType: "object", + properties: { + stringWith4mbDescription: + {bsonType: "string", description: "x".repeat(3 * 1024 * 1024)}, + + } + } +}; + +// Each collection's info is about 3 MB; 4 collections fit in the first batch and 2 in the second. +const nCollections = 6; +jsTestLog(`Creating ${nCollections} collections with huge validator objects....`); +for (let i = 0; i < nCollections; i++) { + assert.commandWorked(mydb.createCollection("collection_" + i, {validator: validator})); +} +jsTestLog(`Done creating ${nCollections} collections`); +cursor = getListCollectionsCursor(); +assert(cursor.hasNext()); +const firstBatchSize = cursor.objsLeftInBatch(); +assert.gt(firstBatchSize, 0); +assert.lt(firstBatchSize, nCollections); +// Exhaust the first batch.. +while (cursor.objsLeftInBatch()) { + cursor.next(); +} +assert(cursor.hasNext()); +cursor.next(); +assert.eq(firstBatchSize + cursor.objsLeftInBatch() + 1, nCollections); + +// // Test on non-existent database. // diff --git a/jstests/core/list_namespaces_invalidation.js b/jstests/core/list_namespaces_invalidation.js index 4bfbdffd4e6..8e94c1e6ded 100644 --- a/jstests/core/list_namespaces_invalidation.js +++ b/jstests/core/list_namespaces_invalidation.js @@ -1,4 +1,4 @@ -// @tags: [requires_non_retryable_commands, requires_fastcount] +// @tags: [requires_non_retryable_commands, requires_fastcount, requires_getmore] (function() { 'use strict'; let dbInvalidName = 'system_namespaces_invalidations'; @@ -17,7 +17,7 @@ function testNamespaceInvalidation(namespaceAction, batchSize) { // Get the first two namespaces using listCollections. let cmd = {listCollections: dbInvalidName}; - Object.extend(cmd, {batchSize: batchSize}); + Object.extend(cmd, {cursor: {batchSize: batchSize}}); let res = dbInvalid.runCommand(cmd); assert.commandWorked(res, 'could not run ' + tojson(cmd)); printjson(res); |