diff options
Diffstat (limited to 'jstests/noPassthroughWithMongod')
25 files changed, 36 insertions, 36 deletions
diff --git a/jstests/noPassthroughWithMongod/apply_ops_errors.js b/jstests/noPassthroughWithMongod/apply_ops_errors.js index 2e2fb2d6069..0cf4a789718 100644 --- a/jstests/noPassthroughWithMongod/apply_ops_errors.js +++ b/jstests/noPassthroughWithMongod/apply_ops_errors.js @@ -19,7 +19,7 @@ coll.drop(); // Scenario 1: only one operation assert.eq(0, coll.find().count(), "test collection not empty"); -coll.createIndex({x: 1}, {unique: true}); +coll.ensureIndex({x: 1}, {unique: true}); coll.insert({_id: 1, x: "init"}); var res = db.runCommand({ @@ -38,7 +38,7 @@ coll.drop(); // Scenario 2: Three operations, first two should run, second should fail. assert.eq(0, coll.find().count(), "test collection not empty"); -coll.createIndex({x: 1}, {unique: true}); +coll.ensureIndex({x: 1}, {unique: true}); coll.insert({_id: 1, x: "init"}); var res = db.runCommand({ diff --git a/jstests/noPassthroughWithMongod/background.js b/jstests/noPassthroughWithMongod/background.js index a6fe673a376..ef591fa5114 100644 --- a/jstests/noPassthroughWithMongod/background.js +++ b/jstests/noPassthroughWithMongod/background.js @@ -18,7 +18,7 @@ for (var i = 0; i < 100000; i++) { } // start bg indexing -a.bg1.createIndex({i: 1}, {name: "i_1", background: true}); +a.bg1.ensureIndex({i: 1}, {name: "i_1", background: true}); // add more data bulk = t.initializeUnorderedBulkOp(); diff --git a/jstests/noPassthroughWithMongod/bulk_api_limits.js b/jstests/noPassthroughWithMongod/bulk_api_limits.js index 91b56f80951..3dada22c519 100644 --- a/jstests/noPassthroughWithMongod/bulk_api_limits.js +++ b/jstests/noPassthroughWithMongod/bulk_api_limits.js @@ -17,7 +17,7 @@ var executeTestsUnordered = function() { // Create unique index coll.dropIndexes(); coll.remove({}); - coll.createIndex({a: 1}, {unique: true}); + coll.ensureIndex({a: 1}, {unique: true}); /** * Fail during batch construction due to single document > maxBSONSize diff --git a/jstests/noPassthroughWithMongod/capped4.js b/jstests/noPassthroughWithMongod/capped4.js index c659ff65935..bfa92cef26d 100644 --- a/jstests/noPassthroughWithMongod/capped4.js +++ b/jstests/noPassthroughWithMongod/capped4.js @@ -3,7 +3,7 @@ t = db.jstests_capped4; t.drop(); db.createCollection("jstests_capped4", {size: 1000, capped: true}); -t.createIndex({i: 1}); +t.ensureIndex({i: 1}); for (i = 0; i < 20; ++i) { t.save({i: i}); } diff --git a/jstests/noPassthroughWithMongod/dup_bgindex.js b/jstests/noPassthroughWithMongod/dup_bgindex.js index dd62117cf9f..02ac4bf7870 100644 --- a/jstests/noPassthroughWithMongod/dup_bgindex.js +++ b/jstests/noPassthroughWithMongod/dup_bgindex.js @@ -7,10 +7,10 @@ for (var i = 0; i < 10000; i++) { docs.push({name: "foo", z: {a: 17, b: 4}, i: i}); } assert.commandWorked(t.insert(docs)); -var cmd = "assert.commandWorked(db.duplIndexTest.createIndex( { i : 1 }, {background:true} ));"; +var cmd = "assert.commandWorked(db.duplIndexTest.ensureIndex( { i : 1 }, {background:true} ));"; var join1 = startParallelShell(cmd); var join2 = startParallelShell(cmd); -assert.commandWorked(t.createIndex({i: 1}, {background: true})); +assert.commandWorked(t.ensureIndex({i: 1}, {background: true})); assert.eq(1, t.find({i: 1}).count(), "Should find only one doc"); assert.commandWorked(t.dropIndex({i: 1})); assert.eq(1, t.find({i: 1}).count(), "Should find only one doc"); diff --git a/jstests/noPassthroughWithMongod/explain1.js b/jstests/noPassthroughWithMongod/explain1.js index 1156a5b86ed..7b37ade1ece 100644 --- a/jstests/noPassthroughWithMongod/explain1.js +++ b/jstests/noPassthroughWithMongod/explain1.js @@ -8,7 +8,7 @@ s1 = startParallelShell(function() { t = db.jstests_slowNightly_explain1; for (var i = 0; i < 80; ++i) { t.drop(); - t.createIndex({x: 1}); + t.ensureIndex({x: 1}); for (var j = 0; j < 1000; ++j) { t.save({x: j, y: 1}); } diff --git a/jstests/noPassthroughWithMongod/explain2.js b/jstests/noPassthroughWithMongod/explain2.js index 0720091e4a4..3766c3a0e93 100644 --- a/jstests/noPassthroughWithMongod/explain2.js +++ b/jstests/noPassthroughWithMongod/explain2.js @@ -8,7 +8,7 @@ t.drop(); db.createCollection(collName, {capped: true, size: 100000}); t = db[collName]; -t.createIndex({x: 1}); +t.ensureIndex({x: 1}); a = startParallelShell('for( i = 0; i < 50000; ++i ) { db.' + collName + '.insert( {x:i,y:1} ); }'); diff --git a/jstests/noPassthroughWithMongod/explain3.js b/jstests/noPassthroughWithMongod/explain3.js index 6d35949d273..d402b610d96 100644 --- a/jstests/noPassthroughWithMongod/explain3.js +++ b/jstests/noPassthroughWithMongod/explain3.js @@ -8,7 +8,7 @@ s1 = startParallelShell(function() { t = db.jstests_slowNightly_explain3; for (var i = 0; i < 80; ++i) { t.drop(); - t.createIndex({x: 1}); + t.ensureIndex({x: 1}); for (var j = 0; j < 1000; ++j) { t.save({x: j, y: 1}); } diff --git a/jstests/noPassthroughWithMongod/external_sort_text_agg.js b/jstests/noPassthroughWithMongod/external_sort_text_agg.js index 583aff8601b..089432b88d0 100644 --- a/jstests/noPassthroughWithMongod/external_sort_text_agg.js +++ b/jstests/noPassthroughWithMongod/external_sort_text_agg.js @@ -1,7 +1,7 @@ // Ensure text search metadata is not lost in an external sort var t = db.external_sort_text_agg; t.drop(); -t.createIndex({text: "text"}); +t.ensureIndex({text: "text"}); for (i = 0; i < 100; i++) { t.insert({_id: i, text: Array(210000).join("asdf ")}); // string over 1MB to hit the 100MB threshold for external sort diff --git a/jstests/noPassthroughWithMongod/geo_axis_aligned.js b/jstests/noPassthroughWithMongod/geo_axis_aligned.js index 877954b0f2a..0849b6b7acc 100644 --- a/jstests/noPassthroughWithMongod/geo_axis_aligned.js +++ b/jstests/noPassthroughWithMongod/geo_axis_aligned.js @@ -62,9 +62,9 @@ for (var b = 0; b < bits.length; b++) { {"_id": 9, "loc": {"x": center[j][0] + radius[i], "y": center[j][1] - radius[i]}}); var res = - t.createIndex({loc: "2d"}, {max: bound[j][1], min: bound[j][0], bits: bits[b]}); + t.ensureIndex({loc: "2d"}, {max: bound[j][1], min: bound[j][0], bits: bits[b]}); - // createIndex fails when this iteration inserted coordinates that are out of bounds. + // ensureIndex fails when this iteration inserted coordinates that are out of bounds. // These are invalid cases, so we skip them. if (!res.ok) continue; diff --git a/jstests/noPassthroughWithMongod/geo_mnypts.js b/jstests/noPassthroughWithMongod/geo_mnypts.js index 7566c479588..d3ae714b69b 100644 --- a/jstests/noPassthroughWithMongod/geo_mnypts.js +++ b/jstests/noPassthroughWithMongod/geo_mnypts.js @@ -13,7 +13,7 @@ for (var i = 0; i < totalPts; i++) { } assert.commandWorked(bulk.execute()); -coll.createIndex({loc: "2d"}); +coll.ensureIndex({loc: "2d"}); // Check that quarter of points in each quadrant for (var i = 0; i < 4; i++) { diff --git a/jstests/noPassthroughWithMongod/geo_polygon.js b/jstests/noPassthroughWithMongod/geo_polygon.js index 28110591d64..d0085fa1f92 100644 --- a/jstests/noPassthroughWithMongod/geo_polygon.js +++ b/jstests/noPassthroughWithMongod/geo_polygon.js @@ -20,7 +20,7 @@ var numTests = 31; var start = (TestData.undoRecorderPath ? 20 : 0); for (var n = start; n < numTests; n++) { t.dropIndexes(); - t.createIndex({loc: "2d"}, {bits: 2 + n}); + t.ensureIndex({loc: "2d"}, {bits: 2 + n}); assert.between(9 - 2, t.find({loc: {"$within": {"$polygon": [[0, 0], [1, 1], [0, 2]]}}}).count(), diff --git a/jstests/noPassthroughWithMongod/huge_multikey_index.js b/jstests/noPassthroughWithMongod/huge_multikey_index.js index 195a85e9b5f..9c19c0d00a1 100644 --- a/jstests/noPassthroughWithMongod/huge_multikey_index.js +++ b/jstests/noPassthroughWithMongod/huge_multikey_index.js @@ -13,9 +13,9 @@ function doit() { t.insert({a: arr}); - // t.createIndex({a:1}, {background:true}) // always worked + // t.ensureIndex({a:1}, {background:true}) // always worked - t.createIndex({a: 1}); // used to fail server with out of fds error + t.ensureIndex({a: 1}); // used to fail server with out of fds error } doit(); diff --git a/jstests/noPassthroughWithMongod/index_check10.js b/jstests/noPassthroughWithMongod/index_check10.js index f355ace6bb8..e0786a4e539 100644 --- a/jstests/noPassthroughWithMongod/index_check10.js +++ b/jstests/noPassthroughWithMongod/index_check10.js @@ -108,7 +108,7 @@ function doIt() { } assert.commandWorked(bulk.execute()); - t.createIndex(idx); + t.ensureIndex(idx); check(); bulk = t.initializeUnorderedBulkOp(); diff --git a/jstests/noPassthroughWithMongod/index_check9.js b/jstests/noPassthroughWithMongod/index_check9.js index 3e082cb1a3f..8a693604bb8 100644 --- a/jstests/noPassthroughWithMongod/index_check9.js +++ b/jstests/noPassthroughWithMongod/index_check9.js @@ -25,7 +25,7 @@ function doIt() { alphas.push(Random.rand() > 0.5); } - t.createIndex(idx); + t.ensureIndex(idx); function obj() { var ret = {}; diff --git a/jstests/noPassthroughWithMongod/indexbg_interrupts.js b/jstests/noPassthroughWithMongod/indexbg_interrupts.js index b468596bd14..19055c16cf5 100644 --- a/jstests/noPassthroughWithMongod/indexbg_interrupts.js +++ b/jstests/noPassthroughWithMongod/indexbg_interrupts.js @@ -78,7 +78,7 @@ for (var idx = 0; idx < dropAction.length; idx++) { assert.commandWorked(bulk.execute()); jsTest.log("Starting background indexing for test of: " + JSON.stringify(dc)); - primaryDB.getCollection(collection).createIndex({i: 1}, {background: true}); + primaryDB.getCollection(collection).ensureIndex({i: 1}, {background: true}); assert.eq(2, primaryDB.getCollection(collection).getIndexes().length); // Wait for the secondary to get the index entry diff --git a/jstests/noPassthroughWithMongod/recstore.js b/jstests/noPassthroughWithMongod/recstore.js index cae767b0637..fdb41af568b 100644 --- a/jstests/noPassthroughWithMongod/recstore.js +++ b/jstests/noPassthroughWithMongod/recstore.js @@ -10,13 +10,13 @@ t.drop(); t.save({z: 3}); t.save({z: 2}); -t.createIndex({z: 1}); -t.createIndex({q: 1}); +t.ensureIndex({z: 1}); +t.ensureIndex({q: 1}); assert(t.find().sort({z: 1})[0].z == 2); t.dropIndexes(); assert(t.find().sort({z: 1})[0].z == 2); -t.createIndex({z: 1}); -t.createIndex({q: 1}); +t.ensureIndex({z: 1}); +t.ensureIndex({q: 1}); diff --git a/jstests/noPassthroughWithMongod/renameWithWCE.js b/jstests/noPassthroughWithMongod/renameWithWCE.js index db932e4621a..0c232ec0b37 100644 --- a/jstests/noPassthroughWithMongod/renameWithWCE.js +++ b/jstests/noPassthroughWithMongod/renameWithWCE.js @@ -23,8 +23,8 @@ b.drop(); a.save({a: 1}); a.save({a: 2}); a.save({a: 3}); -a.createIndex({a: 1}); -a.createIndex({b: 1}); +a.ensureIndex({a: 1}); +a.ensureIndex({b: 1}); assert.commandWorked(admin.runCommand({renameCollection: "db_a.rename7", to: "db_b.rename7"})); diff --git a/jstests/noPassthroughWithMongod/temp_namespace.js b/jstests/noPassthroughWithMongod/temp_namespace.js index 1f4438d5b96..257874d5966 100644 --- a/jstests/noPassthroughWithMongod/temp_namespace.js +++ b/jstests/noPassthroughWithMongod/temp_namespace.js @@ -10,10 +10,10 @@ d = conn.getDB('test'); assert.commandWorked(d.runCommand({ applyOps: [{op: "c", ns: d.getName() + ".$cmd", o: {create: testname + 'temp1', temp: true}}] })); -d[testname + 'temp1'].createIndex({x: 1}); +d[testname + 'temp1'].ensureIndex({x: 1}); assert.commandWorked(d.runCommand( {applyOps: [{op: "c", ns: d.getName() + ".$cmd", o: {create: testname + 'temp2', temp: 1}}]})); -d[testname + 'temp2'].createIndex({x: 1}); +d[testname + 'temp2'].ensureIndex({x: 1}); assert.commandWorked(d.runCommand({ applyOps: [{op: "c", ns: d.getName() + ".$cmd", o: {create: testname + 'keep1', temp: false}}] })); diff --git a/jstests/noPassthroughWithMongod/ttl1.js b/jstests/noPassthroughWithMongod/ttl1.js index 94738104d73..2c1b0d65cbf 100644 --- a/jstests/noPassthroughWithMongod/ttl1.js +++ b/jstests/noPassthroughWithMongod/ttl1.js @@ -33,7 +33,7 @@ sleep(70 * 1000); assert.eq(t.count(), 30); // Part 2 -t.createIndex({x: 1}, {expireAfterSeconds: 20000}); +t.ensureIndex({x: 1}, {expireAfterSeconds: 20000}); assert.soon(function() { return t.count() < 30; @@ -49,7 +49,7 @@ assert.lte(18, db.serverStatus().metrics.ttl.deletedDocuments); assert.lte(1, db.serverStatus().metrics.ttl.passes); // Part 3 -t.createIndex({y: 1}, {expireAfterSeconds: 10000}); +t.ensureIndex({y: 1}, {expireAfterSeconds: 10000}); assert.soon(function() { return t.count() < 12; diff --git a/jstests/noPassthroughWithMongod/ttl_repl.js b/jstests/noPassthroughWithMongod/ttl_repl.js index 14061ede6d1..ff15887b93b 100644 --- a/jstests/noPassthroughWithMongod/ttl_repl.js +++ b/jstests/noPassthroughWithMongod/ttl_repl.js @@ -50,7 +50,7 @@ printjson(secondary1col.stats()); // the correct number of docs age out var initialExpireAfterSeconds = 20000; assert.commandWorked( - primarycol.createIndex({x: 1}, {expireAfterSeconds: initialExpireAfterSeconds})); + primarycol.ensureIndex({x: 1}, {expireAfterSeconds: initialExpireAfterSeconds})); rt.awaitReplication(); sleep(70 * 1000); // TTL monitor runs every 60 seconds, so wait 70 diff --git a/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js b/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js index 23bb9367452..0cdec8e1845 100644 --- a/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js +++ b/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js @@ -16,7 +16,7 @@ var primeSystemReplset = function() { print("create a TTL collection"); var testDB = conn.getDB("test"); - assert.commandWorked(testDB.foo.createIndex({x: 1}, {expireAfterSeconds: 2})); + assert.commandWorked(testDB.foo.ensureIndex({x: 1}, {expireAfterSeconds: 2})); }; var restartWithConfig = function() { diff --git a/jstests/noPassthroughWithMongod/ttl_repl_secondary_disabled.js b/jstests/noPassthroughWithMongod/ttl_repl_secondary_disabled.js index 160933c4ed8..84718bfb914 100644 --- a/jstests/noPassthroughWithMongod/ttl_repl_secondary_disabled.js +++ b/jstests/noPassthroughWithMongod/ttl_repl_secondary_disabled.js @@ -33,7 +33,7 @@ let primarycol = primarydb['c']; let secondary1col = secondary1db['c']; // create TTL index, wait for TTL monitor to kick in, then check things -primarycol.createIndex({x: 1}, {expireAfterSeconds: 10}); +primarycol.ensureIndex({x: 1}, {expireAfterSeconds: 10}); rt.awaitReplication(); diff --git a/jstests/noPassthroughWithMongod/ttl_sharded.js b/jstests/noPassthroughWithMongod/ttl_sharded.js index 61a97a8ce00..8ab74f35be9 100644 --- a/jstests/noPassthroughWithMongod/ttl_sharded.js +++ b/jstests/noPassthroughWithMongod/ttl_sharded.js @@ -32,7 +32,7 @@ assert.commandWorked(bulk.execute()); assert.eq(t.count(), 24, "initial docs not inserted"); // create the TTL index which delete anything older than ~5.5 hours -t.createIndex({x: 1}, {expireAfterSeconds: 20000}); +t.ensureIndex({x: 1}, {expireAfterSeconds: 20000}); // split chunk in half by _id, and move one chunk to the other shard s.adminCommand({split: ns, middle: {_id: 12}}); diff --git a/jstests/noPassthroughWithMongod/validate_command.js b/jstests/noPassthroughWithMongod/validate_command.js index 3ef6a1d79e4..5db827f0e2a 100644 --- a/jstests/noPassthroughWithMongod/validate_command.js +++ b/jstests/noPassthroughWithMongod/validate_command.js @@ -27,8 +27,8 @@ for (var i = 0; i < count; i++) { t.insert({x: i}); } -t.createIndex({x: 1}, {name: "forward"}); -t.createIndex({x: -1}, {name: "reverse"}); +t.ensureIndex({x: 1}, {name: "forward"}); +t.ensureIndex({x: -1}, {name: "reverse"}); // TEST NORMAL VALIDATE var output = t.validate(); |