summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-07-22 15:43:24 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-07-22 22:13:35 +0000
commite71541fd86486ba4adb3cf822189fc00a568a560 (patch)
treece551122e1f0d11d174bbc0a3c0d74fddbe05dd6
parent9f8022c18615e333ae7acb529f2cf79c5e18d9e8 (diff)
downloadmongo-e71541fd86486ba4adb3cf822189fc00a568a560.tar.gz
SERVER-58768 clean up geo_s2sparse.js to use different collection name for each test case
-rw-r--r--jstests/core/geo_s2sparse.js31
1 files changed, 21 insertions, 10 deletions
diff --git a/jstests/core/geo_s2sparse.js b/jstests/core/geo_s2sparse.js
index 1a9a3b67b9b..28ee27da351 100644
--- a/jstests/core/geo_s2sparse.js
+++ b/jstests/core/geo_s2sparse.js
@@ -4,10 +4,19 @@
(function() {
"use strict";
-var coll = db.geo_s2sparse;
-var point = {type: "Point", coordinates: [5, 5]};
-var indexSpec = {geo: "2dsphere", nonGeo: 1};
-var indexName = 'geo_2dsphere_nonGeo_1';
+const collNamePrefix = 'geo_s2sparse_';
+let collCount = 0;
+let coll = db.getCollection(collNamePrefix + collCount++);
+
+const point = {
+ type: "Point",
+ coordinates: [5, 5],
+};
+const indexSpec = {
+ geo: "2dsphere",
+ nonGeo: 1,
+};
+const indexName = 'geo_2dsphere_nonGeo_1';
//
// V2 indices are "geo sparse" always.
@@ -17,7 +26,7 @@ var indexName = 'geo_2dsphere_nonGeo_1';
coll.drop();
coll.createIndex(indexSpec);
-var bulkInsertDocs = function(coll, numDocs, makeDocFn) {
+const bulkInsertDocs = function(coll, numDocs, makeDocFn) {
print("Bulk inserting " + numDocs + " documents");
var bulk = coll.initializeUnorderedBulkOp();
@@ -31,7 +40,7 @@ var bulkInsertDocs = function(coll, numDocs, makeDocFn) {
};
// Insert N documents with the geo field.
-var N = 1000;
+const N = 1000;
bulkInsertDocs(coll, N, function(i) {
return {geo: point, nonGeo: "point_" + i};
});
@@ -76,6 +85,7 @@ assert.eq(N + N, coll.validate().keysPerIndex[indexName]);
// V1 indices are never sparse
//
+coll = db.getCollection(collNamePrefix + collCount++);
coll.drop();
coll.createIndex(indexSpec, {"2dsphereIndexVersion": 1});
@@ -100,10 +110,11 @@ assert.eq(N + N, coll.validate().keysPerIndex[indexName]);
//
// Clean up.
+coll = db.getCollection(collNamePrefix + collCount++);
coll.drop();
coll.createIndex({geo: "2dsphere", otherGeo: "2dsphere"});
-indexName = 'geo_2dsphere_otherGeo_2dsphere';
+const indexNameOther = 'geo_2dsphere_otherGeo_2dsphere';
// Insert N documents with the first geo field.
bulkInsertDocs(coll, N, function(i) {
@@ -111,7 +122,7 @@ bulkInsertDocs(coll, N, function(i) {
});
// Expect N keys.
-assert.eq(N, coll.validate().keysPerIndex[indexName]);
+assert.eq(N, coll.validate().keysPerIndex[indexNameOther]);
// Insert N documents with the second geo field.
bulkInsertDocs(coll, N, function(i) {
@@ -119,7 +130,7 @@ bulkInsertDocs(coll, N, function(i) {
});
// They get inserted too.
-assert.eq(N + N, coll.validate().keysPerIndex[indexName]);
+assert.eq(N + N, coll.validate().keysPerIndex[indexNameOther]);
// Insert N documents with neither geo field.
bulkInsertDocs(coll, N, function(i) {
@@ -127,5 +138,5 @@ bulkInsertDocs(coll, N, function(i) {
});
// Still expect 2N keys as the neither geo docs were omitted from the index.
-assert.eq(N + N, coll.validate().keysPerIndex[indexName]);
+assert.eq(N + N, coll.validate().keysPerIndex[indexNameOther]);
})();