diff options
Diffstat (limited to 'jstests/aggregation/bugs/server9444.js')
-rw-r--r-- | jstests/aggregation/bugs/server9444.js | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/jstests/aggregation/bugs/server9444.js b/jstests/aggregation/bugs/server9444.js index f3c6a449fad..6bb554c8e62 100644 --- a/jstests/aggregation/bugs/server9444.js +++ b/jstests/aggregation/bugs/server9444.js @@ -1,64 +1,64 @@ // server-9444 support disk storage of intermediate results in aggregation (function() { - 'use strict'; +'use strict'; - load('jstests/libs/fixture_helpers.js'); // For 'FixtureHelpers' +load('jstests/libs/fixture_helpers.js'); // For 'FixtureHelpers' - const t = db.server9444; - t.drop(); +const t = db.server9444; +t.drop(); - const sharded = FixtureHelpers.isSharded(t); +const sharded = FixtureHelpers.isSharded(t); - var memoryLimitMB = sharded ? 200 : 100; +var memoryLimitMB = sharded ? 200 : 100; - function loadData() { - var bigStr = Array(1024 * 1024 + 1).toString(); // 1MB of ',' - for (var i = 0; i < memoryLimitMB + 1; i++) - t.insert({_id: i, bigStr: i + bigStr, random: Math.random()}); +function loadData() { + var bigStr = Array(1024 * 1024 + 1).toString(); // 1MB of ',' + for (var i = 0; i < memoryLimitMB + 1; i++) + t.insert({_id: i, bigStr: i + bigStr, random: Math.random()}); - assert.gt(t.stats().size, memoryLimitMB * 1024 * 1024); - } - loadData(); + assert.gt(t.stats().size, memoryLimitMB * 1024 * 1024); +} +loadData(); - function test(pipeline, outOfMemoryCode) { - // ensure by default we error out if exceeding memory limit - var res = t.runCommand('aggregate', {pipeline: pipeline, cursor: {}}); - assert.commandFailed(res); - assert.eq(res.code, outOfMemoryCode); +function test(pipeline, outOfMemoryCode) { + // ensure by default we error out if exceeding memory limit + var res = t.runCommand('aggregate', {pipeline: pipeline, cursor: {}}); + assert.commandFailed(res); + assert.eq(res.code, outOfMemoryCode); - // ensure allowDiskUse: false does what it says - res = t.runCommand('aggregate', {pipeline: pipeline, cursor: {}, allowDiskUse: false}); - assert.commandFailed(res); - assert.eq(res.code, outOfMemoryCode); + // ensure allowDiskUse: false does what it says + res = t.runCommand('aggregate', {pipeline: pipeline, cursor: {}, allowDiskUse: false}); + assert.commandFailed(res); + assert.eq(res.code, outOfMemoryCode); - // allowDiskUse only supports bool. In particular, numbers aren't allowed. - res = t.runCommand('aggregate', {pipeline: pipeline, cursor: {}, allowDiskUse: 1}); - assert.commandFailed(res); + // allowDiskUse only supports bool. In particular, numbers aren't allowed. + res = t.runCommand('aggregate', {pipeline: pipeline, cursor: {}, allowDiskUse: 1}); + assert.commandFailed(res); - // ensure we work when allowDiskUse === true - res = t.aggregate(pipeline, {allowDiskUse: true}); - assert.eq(res.itcount(), t.count()); // all tests output one doc per input doc - } + // ensure we work when allowDiskUse === true + res = t.aggregate(pipeline, {allowDiskUse: true}); + assert.eq(res.itcount(), t.count()); // all tests output one doc per input doc +} - var groupCode = 16945; - var sortCode = 16819; - var sortLimitCode = 16820; +var groupCode = 16945; +var sortCode = 16819; +var sortLimitCode = 16820; - test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}], groupCode); +test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}], groupCode); - // sorting with _id would use index which doesn't require extsort - test([{$sort: {random: 1}}], sortCode); - test([{$sort: {bigStr: 1}}], sortCode); // big key and value +// sorting with _id would use index which doesn't require extsort +test([{$sort: {random: 1}}], sortCode); +test([{$sort: {bigStr: 1}}], sortCode); // big key and value - // make sure sort + large limit won't crash the server (SERVER-10136) - test([{$sort: {bigStr: 1}}, {$limit: 1000 * 1000 * 1000}], sortLimitCode); +// make sure sort + large limit won't crash the server (SERVER-10136) +test([{$sort: {bigStr: 1}}, {$limit: 1000 * 1000 * 1000}], sortLimitCode); - // test combining two extSorts in both same and different orders - test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}, {$sort: {_id: 1}}], groupCode); - test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}, {$sort: {_id: -1}}], groupCode); - test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}, {$sort: {random: 1}}], groupCode); - test([{$sort: {random: 1}}, {$group: {_id: '$_id', bigStr: {$first: '$bigStr'}}}], sortCode); +// test combining two extSorts in both same and different orders +test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}, {$sort: {_id: 1}}], groupCode); +test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}, {$sort: {_id: -1}}], groupCode); +test([{$group: {_id: '$_id', bigStr: {$min: '$bigStr'}}}, {$sort: {random: 1}}], groupCode); +test([{$sort: {random: 1}}, {$group: {_id: '$_id', bigStr: {$first: '$bigStr'}}}], sortCode); - // don't leave large collection laying around - t.drop(); +// don't leave large collection laying around +t.drop(); })(); |