summaryrefslogtreecommitdiff
path: root/jstests/slow1
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-12-16 17:44:20 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-16 23:27:18 +0000
commitc5816ddeb9048661fbe3296c67267e51c073d20a (patch)
tree5ea96083f74b98ea6a18823dddf252eb47eb9686 /jstests/slow1
parentfa202b3594be0389f1fcd7e93e8f6d11ccb6e933 (diff)
downloadmongo-c5816ddeb9048661fbe3296c67267e51c073d20a.tar.gz
SERVER-62092 move geo_array1.js to slow1
Diffstat (limited to 'jstests/slow1')
-rw-r--r--jstests/slow1/geo_array1.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/jstests/slow1/geo_array1.js b/jstests/slow1/geo_array1.js
new file mode 100644
index 00000000000..5382126dfa2
--- /dev/null
+++ b/jstests/slow1/geo_array1.js
@@ -0,0 +1,66 @@
+// Make sure many locations in one doc works, in the form of an array
+// @tags: [
+// does_not_support_stepdowns,
+// resource_intensive,
+// ]
+
+(function() {
+'use strict';
+
+const numLocations = 300;
+let locObj = [];
+// Add locations everywhere
+for (let i = 0; i < 10; i++) {
+ for (let j = 0; j < 10; j++) {
+ if (j % 2 == 0)
+ locObj.push([i, j]);
+ else
+ locObj.push({x: i, y: j});
+ }
+}
+
+// Add docs with all these locations
+let docs = [];
+for (let i = 0; i < numLocations; i++) {
+ docs.push({_id: i, loc: locObj});
+}
+
+const collNamePrefix = 'geo_array1_';
+let collCount = 0;
+
+function test(conn, index) {
+ const testDB = conn.getDB('test');
+ let t = testDB.getCollection(collNamePrefix + collCount++);
+ t.drop();
+
+ if (index) {
+ assert.commandWorked(t.createIndex({loc: "2d"}));
+ }
+
+ assert.commandWorked(t.insert(docs));
+
+ // Pull them back
+ 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));
+ }
+ }
+}
+
+const rst = ReplSetTest({nodes: 1});
+rst.startSet();
+rst.initiate();
+
+const primary = rst.getPrimary();
+
+test(primary, /*index=*/true);
+test(primary, /*index=*/false);
+
+rst.stopSet();
+})();