diff options
author | Arun Banala <arun.banala@mongodb.com> | 2020-11-12 17:48:52 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-12 18:15:38 +0000 |
commit | 7c196029e8529d8d217a4c9314d8a4e6069a91d2 (patch) | |
tree | dcac2d4dda9015804fbf538cffd4a15d9c02cd39 /jstests/aggregation | |
parent | ccd024d9fb5c0587e33a3a3321e7f9a0430d0190 (diff) | |
download | mongo-7c196029e8529d8d217a4c9314d8a4e6069a91d2.tar.gz |
Revert "SERVER-50442 Remove ensureIndex shell function This commit also replaces all the usages of ensureIndex() with createIndex() in JS tests and JS shell"
This reverts commit e69c967ff8b53634770438dfe9a5c7d13548351b.
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 bae114f2417..2027b6d9ff5 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.createIndex(indexSpec)); + assert.commandWorked(coll.ensureIndex(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 f099480f935..27482cc1c46 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.createIndex({name: 1}); +t.ensureIndex({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 15fd423f44a..0da44f18c6d 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.createIndex({a: 1})); +assert.commandWorked(coll.ensureIndex({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 b63cfd7aabb..e3a3268c048 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.createIndex({foo: 1}); +coll.ensureIndex({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 e3c9b4847c1..ac7ed42eed0 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.createIndex({a: 1}); +output.ensureIndex({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.createIndex({b: "2d"}); +output.ensureIndex({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.createIndex({c: "text"}); +output.ensureIndex({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 82b38ab3604..b2c59ccd244 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.createIndex({b: 1}, {name: "s3832_b"}); +db.s3832.ensureIndex({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.createIndex({a: 1}, {name: "s3832_a"}); +db.s3832.ensureIndex({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 46f09a0f379..cd2faae0eb7 100644 --- a/jstests/aggregation/bugs/server6531.js +++ b/jstests/aggregation/bugs/server6531.js @@ -23,9 +23,9 @@ function test(variant) { test("no index"); -c.createIndex({loc: "2d"}); +c.ensureIndex({loc: "2d"}); test("2d index"); c.dropIndex({loc: "2d"}); -c.createIndex({loc: "2dsphere"}); +c.ensureIndex({loc: "2dsphere"}); test("2dsphere index"); diff --git a/jstests/aggregation/bugs/server7781.js b/jstests/aggregation/bugs/server7781.js index 77f8bbc6866..586099df79f 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].createIndex({loc: indexType}); + db[coll].ensureIndex({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 488b0300381..a82837dfb70 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.createIndex({a: 1})); +assert.commandWorked(coll.ensureIndex({a: 1})); assert.eq(coll.aggregate([{$sort: {a: 1, _id: 1}}]).toArray(), expectedOrder); assert.eq(coll.find().sort({a: 1, _id: 1}).toArray(), expectedOrder); }()); |