diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/noPassthrough/aggregation_zero_batchsize.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/noPassthrough/aggregation_zero_batchsize.js')
-rw-r--r-- | jstests/noPassthrough/aggregation_zero_batchsize.js | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/jstests/noPassthrough/aggregation_zero_batchsize.js b/jstests/noPassthrough/aggregation_zero_batchsize.js index 3360c6d0856..d143c75ede6 100644 --- a/jstests/noPassthrough/aggregation_zero_batchsize.js +++ b/jstests/noPassthrough/aggregation_zero_batchsize.js @@ -3,86 +3,86 @@ * retrieved via getMores. */ (function() { - "use strict"; +"use strict"; - const mongodOptions = {}; - const conn = MongoRunner.runMongod(mongodOptions); - assert.neq(null, conn, "mongod failed to start with options " + tojson(mongodOptions)); +const mongodOptions = {}; +const conn = MongoRunner.runMongod(mongodOptions); +assert.neq(null, conn, "mongod failed to start with options " + tojson(mongodOptions)); - const testDB = conn.getDB("test"); - const coll = testDB[jsTest.name]; - coll.drop(); +const testDB = conn.getDB("test"); +const coll = testDB[jsTest.name]; +coll.drop(); - // Test that an aggregate is successful on a non-existent collection. - assert.eq(0, - coll.aggregate([]).toArray().length, - "expected no results from an aggregation on an empty collection"); +// Test that an aggregate is successful on a non-existent collection. +assert.eq(0, + coll.aggregate([]).toArray().length, + "expected no results from an aggregation on an empty collection"); - // Test that an aggregate is successful on a non-existent collection with a batchSize of 0, and - // that a getMore will succeed with an empty result set. - let res = assert.commandWorked( - testDB.runCommand({aggregate: coll.getName(), pipeline: [], cursor: {batchSize: 0}})); +// Test that an aggregate is successful on a non-existent collection with a batchSize of 0, and +// that a getMore will succeed with an empty result set. +let res = assert.commandWorked( + testDB.runCommand({aggregate: coll.getName(), pipeline: [], cursor: {batchSize: 0}})); - let cursor = new DBCommandCursor(testDB, res); - assert.eq( - 0, cursor.itcount(), "expected no results from getMore of aggregation on empty collection"); +let cursor = new DBCommandCursor(testDB, res); +assert.eq( + 0, cursor.itcount(), "expected no results from getMore of aggregation on empty collection"); - // Test that an aggregation can return *all* matching data via getMores if the initial aggregate - // used a batchSize of 0. - const nDocs = 1000; - const bulk = coll.initializeUnorderedBulkOp(); - for (let i = 0; i < nDocs; i++) { - bulk.insert({_id: i, stringField: "string"}); - } - assert.writeOK(bulk.execute()); +// Test that an aggregation can return *all* matching data via getMores if the initial aggregate +// used a batchSize of 0. +const nDocs = 1000; +const bulk = coll.initializeUnorderedBulkOp(); +for (let i = 0; i < nDocs; i++) { + bulk.insert({_id: i, stringField: "string"}); +} +assert.writeOK(bulk.execute()); - res = assert.commandWorked( - testDB.runCommand({aggregate: coll.getName(), pipeline: [], cursor: {batchSize: 0}})); - cursor = new DBCommandCursor(testDB, res); - assert.eq(nDocs, cursor.itcount(), "expected all results to be returned via getMores"); +res = assert.commandWorked( + testDB.runCommand({aggregate: coll.getName(), pipeline: [], cursor: {batchSize: 0}})); +cursor = new DBCommandCursor(testDB, res); +assert.eq(nDocs, cursor.itcount(), "expected all results to be returned via getMores"); - // Test that an error in a getMore will destroy the cursor. - function assertNumOpenCursors(nExpectedOpen) { - let serverStatus = assert.commandWorked(testDB.adminCommand({serverStatus: 1})); - assert.eq(nExpectedOpen, - serverStatus.metrics.cursor.open.total, - "expected to find " + nExpectedOpen + " open cursor(s): " + - tojson(serverStatus.metrics.cursor)); - } +// Test that an error in a getMore will destroy the cursor. +function assertNumOpenCursors(nExpectedOpen) { + let serverStatus = assert.commandWorked(testDB.adminCommand({serverStatus: 1})); + assert.eq(nExpectedOpen, + serverStatus.metrics.cursor.open.total, + "expected to find " + nExpectedOpen + + " open cursor(s): " + tojson(serverStatus.metrics.cursor)); +} - // Issue an aggregate command that will fail *at runtime*, so the error will happen in a - // getMore. - assertNumOpenCursors(0); - res = assert.commandWorked(testDB.runCommand({ - aggregate: coll.getName(), - pipeline: [{$project: {invalidComputation: {$add: [1, "$stringField"]}}}], - cursor: {batchSize: 0} - })); - cursor = new DBCommandCursor(testDB, res); - assertNumOpenCursors(1); +// Issue an aggregate command that will fail *at runtime*, so the error will happen in a +// getMore. +assertNumOpenCursors(0); +res = assert.commandWorked(testDB.runCommand({ + aggregate: coll.getName(), + pipeline: [{$project: {invalidComputation: {$add: [1, "$stringField"]}}}], + cursor: {batchSize: 0} +})); +cursor = new DBCommandCursor(testDB, res); +assertNumOpenCursors(1); - assert.throws(() => cursor.itcount(), [], "expected getMore to fail"); - assertNumOpenCursors(0); +assert.throws(() => cursor.itcount(), [], "expected getMore to fail"); +assertNumOpenCursors(0); - // Test that an error in a getMore using a $out stage will destroy the cursor. This test is - // intended to reproduce SERVER-26608. +// Test that an error in a getMore using a $out stage will destroy the cursor. This test is +// intended to reproduce SERVER-26608. - // Issue an aggregate command that will fail *at runtime*, so the error will happen in a - // getMore. - res = assert.commandWorked(testDB.runCommand({ - aggregate: coll.getName(), - pipeline: [{$out: "validated_collection"}], - cursor: {batchSize: 0} - })); - cursor = new DBCommandCursor(testDB, res); - assertNumOpenCursors(1); +// Issue an aggregate command that will fail *at runtime*, so the error will happen in a +// getMore. +res = assert.commandWorked(testDB.runCommand({ + aggregate: coll.getName(), + pipeline: [{$out: "validated_collection"}], + cursor: {batchSize: 0} +})); +cursor = new DBCommandCursor(testDB, res); +assertNumOpenCursors(1); - // Add a document validation rule to the $out collection so that insertion will fail. - assert.commandWorked(testDB.runCommand( - {create: "validated_collection", validator: {stringField: {$type: "int"}}})); +// Add a document validation rule to the $out collection so that insertion will fail. +assert.commandWorked( + testDB.runCommand({create: "validated_collection", validator: {stringField: {$type: "int"}}})); - assert.throws(() => cursor.itcount(), [], "expected getMore to fail"); - assertNumOpenCursors(0); +assert.throws(() => cursor.itcount(), [], "expected getMore to fail"); +assertNumOpenCursors(0); - MongoRunner.stopMongod(conn); +MongoRunner.stopMongod(conn); }()); |