diff options
author | Benety Goh <benety@mongodb.com> | 2021-09-18 18:17:42 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-18 18:50:43 +0000 |
commit | ea47f4801e5210aa3c99237d465ad19fb7bdc98b (patch) | |
tree | b71b3d4d81b257e66749005b288aa54d3efda1b9 | |
parent | 8553b426cbac441d2df292e3389afa07a04aa10e (diff) | |
download | mongo-ea47f4801e5210aa3c99237d465ad19fb7bdc98b.tar.gz |
SERVER-59962 clean up geo_array1.js to use different collection name for each test case
-rw-r--r-- | jstests/core/geo_array1.js | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/jstests/core/geo_array1.js b/jstests/core/geo_array1.js index 6066ed1dc6f..2eba2c047c4 100644 --- a/jstests/core/geo_array1.js +++ b/jstests/core/geo_array1.js @@ -1,13 +1,23 @@ // Make sure many locations in one doc works, in the form of an array +// @tags: [ +// does_not_support_stepdowns, +// ] + +(function() { +'use strict'; + +const collNamePrefix = 'geo_array1_'; +let collCount = 0; -t = db.geoarray1; function test(index) { + let t = db.getCollection(collNamePrefix + collCount++); t.drop(); - var locObj = []; + const numLocations = 300; + let locObj = []; // Add locations everywhere - for (var i = 0; i < 10; i++) { - for (var j = 0; j < 10; j++) { + for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) { if (j % 2 == 0) locObj.push([i, j]); else @@ -16,23 +26,28 @@ function test(index) { } // Add docs with all these locations - for (var i = 0; i < 300; i++) { - t.insert({loc: locObj}); + for (let i = 0; i < numLocations; i++) { + assert.commandWorked(t.insert({loc: locObj})); } if (index) { - t.createIndex({loc: "2d"}); + assert.commandWorked(t.createIndex({loc: "2d"})); } // Pull them back - for (var i = 0; i < 10; i++) { - for (var j = 0; j < 10; j++) { - assert.eq( - 300, - t.find({loc: {$within: {$box: [[i - 0.5, j - 0.5], [i + 0.5, j + 0.5]]}}}).count()); + for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) { + const locations = t.find({ + loc: {$within: {$box: [[i - 0.5, j - 0.5], [i + 0.5, j + 0.5]]}} + }).toArray(); + assert.eq(numLocations, + locations.length, + 'index: ' + index + '; i: ' + i + '; j: ' + j + + '; locations: ' + tojson(locations)); } } } test(true); test(false); +})(); |