diff options
author | Rishab Joshi <rishab.joshi@mongodb.com> | 2020-11-17 13:45:05 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-17 14:23:10 +0000 |
commit | 4329ffafa3ef2f9ea40b7ff17a6af8604720de12 (patch) | |
tree | 44cad61cfcdb57abccc910e49fa20f4c6fcc81f2 /jstests/aggregation | |
parent | 519bc2b24ecc6c29f2483c8b82786e16f61c2cba (diff) | |
download | mongo-4329ffafa3ef2f9ea40b7ff17a6af8604720de12.tar.gz |
SERVER-50442 Remove ensureIndex shell function
This commit replaces all the usages of ensureIndex() with createIndex() in JS tests and JS shell""
Diffstat (limited to 'jstests/aggregation')
-rw-r--r-- | jstests/aggregation/bugs/server12015.js | 2 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server13715.js | 2 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server14969.js | 2 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server22093.js | 2 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server3253.js | 6 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server3832.js | 4 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server6531.js | 4 | ||||
-rw-r--r-- | jstests/aggregation/bugs/server7781.js | 2 | ||||
-rw-r--r-- | jstests/aggregation/bugs/sort_arrays.js | 2 |
9 files changed, 13 insertions, 13 deletions
diff --git a/jstests/aggregation/bugs/server12015.js b/jstests/aggregation/bugs/server12015.js index 2027b6d9ff5..bae114f2417 100644 --- a/jstests/aggregation/bugs/server12015.js +++ b/jstests/aggregation/bugs/server12015.js @@ -36,7 +36,7 @@ function assertResultsMatch(pipeline, ignoreSortOrder) { pipeline = [{$match: {a: {$gte: 0}}}].concat(pipeline); // Once with an index. - assert.commandWorked(coll.ensureIndex(indexSpec)); + assert.commandWorked(coll.createIndex(indexSpec)); var resultsWithIndex = coll.aggregate(pipeline).toArray(); // Again without an index. diff --git a/jstests/aggregation/bugs/server13715.js b/jstests/aggregation/bugs/server13715.js index 27482cc1c46..f099480f935 100644 --- a/jstests/aggregation/bugs/server13715.js +++ b/jstests/aggregation/bugs/server13715.js @@ -12,7 +12,7 @@ assert.eq(1, cursor.next()["_id"]); assert.eq(0, cursor.next()["_id"]); // Repeat the test with an index. -t.ensureIndex({name: 1}); +t.createIndex({name: 1}); cursor = t.aggregate([{$match: {$or: [{name: "red"}, {name: "blue"}]}}, {$sort: {value: 1}}]); assert.eq(1, cursor.next()["_id"]); diff --git a/jstests/aggregation/bugs/server14969.js b/jstests/aggregation/bugs/server14969.js index 0da44f18c6d..15fd423f44a 100644 --- a/jstests/aggregation/bugs/server14969.js +++ b/jstests/aggregation/bugs/server14969.js @@ -11,7 +11,7 @@ var longString = new Array(1024 * 1024).join('x'); for (var i = 0; i < 100; ++i) { assert.commandWorked(coll.insert({a: 1, bigField: longString})); } -assert.commandWorked(coll.ensureIndex({a: 1})); +assert.commandWorked(coll.createIndex({a: 1})); // Create pipeline that uses index "a", with a small initial batch size. var cursor = coll.aggregate([{$match: {a: 1}}], {cursor: {batchSize: docsPerBatch}}); diff --git a/jstests/aggregation/bugs/server22093.js b/jstests/aggregation/bugs/server22093.js index e3a3268c048..b63cfd7aabb 100644 --- a/jstests/aggregation/bugs/server22093.js +++ b/jstests/aggregation/bugs/server22093.js @@ -26,7 +26,7 @@ for (var i = 0; i < 3; i++) { } } -coll.ensureIndex({foo: 1}); +coll.createIndex({foo: 1}); var simpleGroup = coll.aggregate([{$group: {_id: null, count: {$sum: 1}}}]).toArray(); diff --git a/jstests/aggregation/bugs/server3253.js b/jstests/aggregation/bugs/server3253.js index ac7ed42eed0..e3c9b4847c1 100644 --- a/jstests/aggregation/bugs/server3253.js +++ b/jstests/aggregation/bugs/server3253.js @@ -66,7 +66,7 @@ test(input, // test with indexes assert.eq(output.getIndexes().length, 1); -output.ensureIndex({a: 1}); +output.createIndex({a: 1}); assert.eq(output.getIndexes().length, 2); test(input, [{$project: {a: {$multiply: ['$_id', '$_id']}}}], @@ -77,12 +77,12 @@ test(input, [{$match: {_id: 11}}], []); assert.eq(output.getIndexes().length, 2); // test with geo index -output.ensureIndex({b: "2d"}); +output.createIndex({b: "2d"}); assert.eq(output.getIndexes().length, 3); test(input, [{$project: {b: "$_id"}}], [{_id: 1, b: 1}, {_id: 2, b: 2}, {_id: 3, b: 3}]); // test with full text index -output.ensureIndex({c: "text"}); +output.createIndex({c: "text"}); assert.eq(output.getIndexes().length, 4); test(input, [{$project: {c: {$concat: ["hello there ", "_id"]}}}], [ {_id: 1, c: "hello there _id"}, diff --git a/jstests/aggregation/bugs/server3832.js b/jstests/aggregation/bugs/server3832.js index b2c59ccd244..82b38ab3604 100644 --- a/jstests/aggregation/bugs/server3832.js +++ b/jstests/aggregation/bugs/server3832.js @@ -25,7 +25,7 @@ var a3 = s3832.aggregate({$match: {b: "baz"}}, {$sort: {a: 1}}); assert.eq(a3.toArray(), a1result, 's3832.a3 failed'); -db.s3832.ensureIndex({b: 1}, {name: "s3832_b"}); +db.s3832.createIndex({b: 1}, {name: "s3832_b"}); var a4 = s3832.aggregate({$match: {b: "baz"}}); @@ -41,7 +41,7 @@ assert.eq(a6.toArray(), a1result, 's3832.a6 failed'); var dropb = db.s3832.dropIndex("s3832_b"); -db.s3832.ensureIndex({a: 1}, {name: "s3832_a"}); +db.s3832.createIndex({a: 1}, {name: "s3832_a"}); var a7 = s3832.aggregate({$match: {b: "baz"}}); diff --git a/jstests/aggregation/bugs/server6531.js b/jstests/aggregation/bugs/server6531.js index cd2faae0eb7..46f09a0f379 100644 --- a/jstests/aggregation/bugs/server6531.js +++ b/jstests/aggregation/bugs/server6531.js @@ -23,9 +23,9 @@ function test(variant) { test("no index"); -c.ensureIndex({loc: "2d"}); +c.createIndex({loc: "2d"}); test("2d index"); c.dropIndex({loc: "2d"}); -c.ensureIndex({loc: "2dsphere"}); +c.createIndex({loc: "2dsphere"}); test("2dsphere index"); diff --git a/jstests/aggregation/bugs/server7781.js b/jstests/aggregation/bugs/server7781.js index 586099df79f..77f8bbc6866 100644 --- a/jstests/aggregation/bugs/server7781.js +++ b/jstests/aggregation/bugs/server7781.js @@ -67,7 +67,7 @@ function test(db, indexType) { assert.eq(db[coll].count(), numPts); - db[coll].ensureIndex({loc: indexType}); + db[coll].createIndex({loc: indexType}); // Test $geoNear with spherical coordinates. testGeoNearStageOutput({ diff --git a/jstests/aggregation/bugs/sort_arrays.js b/jstests/aggregation/bugs/sort_arrays.js index a82837dfb70..488b0300381 100644 --- a/jstests/aggregation/bugs/sort_arrays.js +++ b/jstests/aggregation/bugs/sort_arrays.js @@ -11,7 +11,7 @@ const expectedOrder = [{_id: 4, a: [2, 1]}, {_id: 2, a: [2, 3]}, {_id: 3, a: [2, assert.eq(coll.aggregate([{$sort: {a: 1, _id: 1}}]).toArray(), expectedOrder); assert.eq(coll.find().sort({a: 1, _id: 1}).toArray(), expectedOrder); -assert.commandWorked(coll.ensureIndex({a: 1})); +assert.commandWorked(coll.createIndex({a: 1})); assert.eq(coll.aggregate([{$sort: {a: 1, _id: 1}}]).toArray(), expectedOrder); assert.eq(coll.find().sort({a: 1, _id: 1}).toArray(), expectedOrder); }()); |