summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-07-06 11:22:27 -0400
committerBenety Goh <benety@mongodb.com>2016-07-07 09:56:37 -0400
commit128fdb36721138c94eb2a00bd59d4361839cd0dd (patch)
treeed17c6b0ae48136e54f0d6240eb0f75f7927d99c /jstests
parent56ebd8ce50af94b5beaa8af8f6b2da1d1accd44a (diff)
downloadmongo-128fdb36721138c94eb2a00bd59d4361839cd0dd.tar.gz
SERVER-24901 do not use fast count when checking collection size in replset tests
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/apply_ops_wc.js4
-rw-r--r--jstests/replsets/batch_write_command_wc.js20
-rw-r--r--jstests/replsets/bulk_api_wc.js8
-rw-r--r--jstests/replsets/capped_insert_order.js2
-rw-r--r--jstests/replsets/cloneDb.js12
-rw-r--r--jstests/replsets/commands_that_write_accept_wc.js4
-rw-r--r--jstests/replsets/drain.js4
-rw-r--r--jstests/replsets/find_and_modify_wc.js4
-rw-r--r--jstests/replsets/fsync_lock_read_secondaries.js4
-rw-r--r--jstests/replsets/groupAndMapReduce.js2
-rw-r--r--jstests/replsets/initial_sync1.js2
-rw-r--r--jstests/replsets/initial_sync2.js2
-rw-r--r--jstests/replsets/initial_sync4.js4
-rw-r--r--jstests/replsets/initial_sync_update_missing_doc1.js2
-rw-r--r--jstests/replsets/initial_sync_update_missing_doc2.js2
-rw-r--r--jstests/replsets/oplog_format.js4
-rw-r--r--jstests/replsets/replset5.js6
-rw-r--r--jstests/replsets/replset8.js2
-rw-r--r--jstests/replsets/replsets_killop.js6
-rw-r--r--jstests/replsets/resync_with_write_load.js2
-rw-r--r--jstests/replsets/rollback.js8
-rw-r--r--jstests/replsets/rollback2.js6
-rw-r--r--jstests/replsets/rollback3.js12
-rw-r--r--jstests/replsets/rollback_dropdb.js2
-rw-r--r--jstests/replsets/rollback_index.js4
-rw-r--r--jstests/replsets/toostale.js4
-rw-r--r--jstests/replsets/two_initsync.js2
-rw-r--r--jstests/replsets/user_management_wc.js14
28 files changed, 74 insertions, 74 deletions
diff --git a/jstests/replsets/apply_ops_wc.js b/jstests/replsets/apply_ops_wc.js
index b0c4fed59c4..639a5cda05e 100644
--- a/jstests/replsets/apply_ops_wc.js
+++ b/jstests/replsets/apply_ops_wc.js
@@ -28,7 +28,7 @@
function dropTestCollection() {
coll.drop();
- assert.eq(0, coll.find().count(), "test collection not empty");
+ assert.eq(0, coll.find().itcount(), "test collection not empty");
}
dropTestCollection();
@@ -131,4 +131,4 @@
majorityWriteConcerns.forEach(testMajorityWriteConcerns);
-})(); \ No newline at end of file
+})();
diff --git a/jstests/replsets/batch_write_command_wc.js b/jstests/replsets/batch_write_command_wc.js
index b86fd8c80a8..b9ed7b50118 100644
--- a/jstests/replsets/batch_write_command_wc.js
+++ b/jstests/replsets/batch_write_command_wc.js
@@ -29,7 +29,7 @@ printjson(request = {
printjson(result = coll.runCommand(request));
assert(result.ok);
assert.eq(1, result.n);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Basic insert, majority WC
@@ -42,7 +42,7 @@ printjson(request = {
printjson(result = coll.runCommand(request));
assert(result.ok);
assert.eq(1, result.n);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Basic insert, w:2 WC
@@ -55,7 +55,7 @@ printjson(request = {
printjson(result = coll.runCommand(request));
assert(result.ok);
assert.eq(1, result.n);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Basic insert, immediate nojournal error
@@ -67,7 +67,7 @@ printjson(request = {
});
printjson(result = coll.runCommand(request));
assert(!result.ok);
-assert.eq(0, coll.count());
+assert.eq(0, coll.find().itcount());
//
// Basic insert, timeout wc error
@@ -82,7 +82,7 @@ assert(result.ok);
assert.eq(1, result.n);
assert(result.writeConcernError);
assert.eq(100, result.writeConcernError.code);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Basic insert, wmode wc error
@@ -96,7 +96,7 @@ printjson(result = coll.runCommand(request));
assert(result.ok);
assert.eq(1, result.n);
assert(result.writeConcernError);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Two ordered inserts, write error and wc error both reported
@@ -112,7 +112,7 @@ assert.eq(1, result.n);
assert.eq(result.writeErrors.length, 1);
assert.eq(result.writeErrors[0].index, 1);
assert(result.writeConcernError);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Two unordered inserts, write error and wc error reported
@@ -129,7 +129,7 @@ assert.eq(1, result.n);
assert.eq(result.writeErrors.length, 1);
assert.eq(result.writeErrors[0].index, 1);
assert(result.writeConcernError);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Write error with empty writeConcern object.
@@ -146,7 +146,7 @@ assert.eq(1, result.n);
assert.eq(result.writeErrors.length, 1);
assert.eq(result.writeErrors[0].index, 1);
assert.eq(null, result.writeConcernError);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
//
// Write error with unspecified w.
@@ -163,7 +163,7 @@ assert.eq(1, result.n);
assert.eq(result.writeErrors.length, 1);
assert.eq(result.writeErrors[0].index, 1);
assert.eq(null, result.writeConcernError);
-assert.eq(1, coll.count());
+assert.eq(1, coll.find().itcount());
jsTest.log("DONE no journal/repl tests");
rst.stopSet();
diff --git a/jstests/replsets/bulk_api_wc.js b/jstests/replsets/bulk_api_wc.js
index f08e4df64b9..4b029555ce1 100644
--- a/jstests/replsets/bulk_api_wc.js
+++ b/jstests/replsets/bulk_api_wc.js
@@ -47,7 +47,7 @@ var executeTests = function() {
assert.eq(result.nInserted, 2);
assert.eq(result.getWriteErrors()[0].index, 2);
assert(!result.getWriteConcernError());
- assert.eq(coll.count(), 2);
+ assert.eq(coll.find().itcount(), 2);
//
// Unordered
@@ -66,7 +66,7 @@ var executeTests = function() {
assert.eq(result.nInserted, 2);
assert.eq(result.getWriteErrors()[0].index, 2);
assert(result.getWriteConcernError());
- assert.eq(coll.count(), 2);
+ assert.eq(coll.find().itcount(), 2);
//
// Fail with write error, write concern timeout reported when unordered
@@ -83,7 +83,7 @@ var executeTests = function() {
assert.eq(result.nInserted, 2);
assert.eq(result.getWriteErrors()[0].index, 2);
assert.eq(100, result.getWriteConcernError().code);
- assert.eq(coll.count(), 2);
+ assert.eq(coll.find().itcount(), 2);
//
// Fail with write error and upserted, write concern error reported when unordered
@@ -101,7 +101,7 @@ var executeTests = function() {
assert.eq(result.getUpsertedIds()[0].index, 2);
assert.eq(result.getWriteErrors()[0].index, 3);
assert(result.getWriteConcernError());
- assert.eq(coll.count(), 3);
+ assert.eq(coll.find().itcount(), 3);
};
// Use write commands
diff --git a/jstests/replsets/capped_insert_order.js b/jstests/replsets/capped_insert_order.js
index 0b17f9ff144..037da74c2b6 100644
--- a/jstests/replsets/capped_insert_order.js
+++ b/jstests/replsets/capped_insert_order.js
@@ -32,7 +32,7 @@
replTest.awaitReplication();
function checkCollection(coll) {
- assert.eq(coll.count(), nDocuments);
+ assert.eq(coll.find().itcount(), nDocuments);
var i = 0;
coll.find().forEach(function(doc) {
diff --git a/jstests/replsets/cloneDb.js b/jstests/replsets/cloneDb.js
index f0eb6a2171e..a3a6970ff10 100644
--- a/jstests/replsets/cloneDb.js
+++ b/jstests/replsets/cloneDb.js
@@ -42,14 +42,14 @@
jsTest.log("Clone db from replica set to standalone server");
standaloneDB.cloneDatabase(replTest.getURL());
assert.eq(numDocs,
- standaloneDB[testColName].count(),
+ standaloneDB[testColName].find().itcount(),
'cloneDatabase from replset to standalone failed (document counts do not match)');
jsTest.log("Clone db from replica set PRIMARY to standalone server");
standaloneDB.dropDatabase();
standaloneDB.cloneDatabase(master.host);
assert.eq(numDocs,
- standaloneDB[testColName].count(),
+ standaloneDB[testColName].find().itcount(),
'cloneDatabase from PRIMARY to standalone failed (document counts do not match)');
jsTest.log("Clone db from replica set SECONDARY to standalone server (should not copy)");
@@ -57,7 +57,7 @@
standaloneDB.cloneDatabase(secondary.host);
assert.eq(
0,
- standaloneDB[testColName].count(),
+ standaloneDB[testColName].find().itcount(),
'cloneDatabase from SECONDARY to standalone copied documents without slaveOk: true');
jsTest.log("Clone db from replica set SECONDARY to standalone server using slaveOk");
@@ -65,7 +65,7 @@
standaloneDB.runCommand({clone: secondary.host, slaveOk: true});
assert.eq(
numDocs,
- standaloneDB[testColName].count(),
+ standaloneDB[testColName].find().itcount(),
'cloneDatabase from SECONDARY to standalone failed (document counts do not match)');
jsTest.log("Switch db and insert data into standalone server");
@@ -86,7 +86,7 @@
masterDB.cloneDatabase(standalone.host);
replTest.awaitReplication();
assert.eq(numDocs,
- masterDB[testColName].count(),
+ masterDB[testColName].find().itcount(),
'cloneDatabase from standalone to PRIMARY failed (document counts do not match)');
jsTest.log("Clone db from standalone server to replica set SECONDARY");
@@ -95,7 +95,7 @@
secondaryDB.cloneDatabase(standalone.host);
assert.eq(
0,
- secondaryDB[testColName].count(),
+ secondaryDB[testColName].find().itcount(),
'cloneDatabase from standalone to SECONDARY succeeded and should not accept writes');
jsTest.log("Shut down replica set and standalone server");
diff --git a/jstests/replsets/commands_that_write_accept_wc.js b/jstests/replsets/commands_that_write_accept_wc.js
index 83a341767c2..64e52d4c6c6 100644
--- a/jstests/replsets/commands_that_write_accept_wc.js
+++ b/jstests/replsets/commands_that_write_accept_wc.js
@@ -22,7 +22,7 @@ load('jstests/libs/write_concern_util.js');
function dropTestCollection() {
coll.drop();
- assert.eq(0, coll.find().count(), "test collection not empty");
+ assert.eq(0, coll.find().itcount(), "test collection not empty");
}
dropTestCollection();
@@ -147,4 +147,4 @@ load('jstests/libs/write_concern_util.js');
testInvalidWriteConcern(cmd);
});
-})(); \ No newline at end of file
+})();
diff --git a/jstests/replsets/drain.js b/jstests/replsets/drain.js
index a81d45f1d10..74c5868b821 100644
--- a/jstests/replsets/drain.js
+++ b/jstests/replsets/drain.js
@@ -43,7 +43,7 @@
}
assert.writeOK(bulk.execute());
jsTestLog('Number of documents inserted into collection on primary: ' + numDocuments);
- assert.eq(numDocuments, primary.getDB("foo").foo.count());
+ assert.eq(numDocuments, primary.getDB("foo").foo.find().itcount());
assert.soon(function() {
var serverStatus = secondary.getDB('foo').serverStatus();
@@ -105,5 +105,5 @@
// Check for at least two entries. There was one prior to freezing op application on the
// secondary and we cannot guarantee all writes reached the secondary's op queue prior to
// shutting down the original primary.
- assert.gte(primary.getDB("foo").foo.count(), 2);
+ assert.gte(primary.getDB("foo").foo.find().itcount(), 2);
})();
diff --git a/jstests/replsets/find_and_modify_wc.js b/jstests/replsets/find_and_modify_wc.js
index f6cdb092697..f070b5c8bfa 100644
--- a/jstests/replsets/find_and_modify_wc.js
+++ b/jstests/replsets/find_and_modify_wc.js
@@ -21,7 +21,7 @@
var res =
coll.runCommand({insert: coll.getName(), documents: docs, writeConcern: {w: nodeCount}});
assert(res.ok);
- assert.eq(5, coll.count());
+ assert.eq(5, coll.find().itcount());
// use for updates in subsequent runCommand calls
var reqUpdate = {
@@ -52,7 +52,7 @@
res = coll.runCommand(
{findAndModify: coll.getName(), sort: {i: 1}, remove: true, writeConcern: {w: nodeCount}});
assert.eq(res.value.i, 1);
- assert.eq(coll.count(), 4);
+ assert.eq(coll.find().itcount(), 4);
assert(!res.writeConcernError);
// Verify findAndModify returns writeConcernError
diff --git a/jstests/replsets/fsync_lock_read_secondaries.js b/jstests/replsets/fsync_lock_read_secondaries.js
index 8b9127c8c43..8a4a49b375c 100644
--- a/jstests/replsets/fsync_lock_read_secondaries.js
+++ b/jstests/replsets/fsync_lock_read_secondaries.js
@@ -61,14 +61,14 @@
// Issue a read query on the secondary while holding the fsync lock.
// This is what we are testing. Previously this would block. After the fix
// this should work just fine.
- var slave0count = slaves[0].getDB("foo").bar.count();
+ var slave0count = slaves[0].getDB("foo").bar.find().itcount();
assert.eq(
slave0count, 100, "Doc count in fsync lock wrong. Expected (=100), found " + slave0count);
assert(slaves[0].getDB("admin").fsyncUnlock().ok);
// The secondary should have equal or more documents than what it had before.
assert.soon(function() {
- return slaves[0].getDB("foo").bar.count() > 100;
+ return slaves[0].getDB("foo").bar.find().itcount() > 100;
}, "count of documents stored on the secondary did not increase");
replTest.stopSet();
}());
diff --git a/jstests/replsets/groupAndMapReduce.js b/jstests/replsets/groupAndMapReduce.js
index 15dea43c231..ad2864e08d1 100644
--- a/jstests/replsets/groupAndMapReduce.js
+++ b/jstests/replsets/groupAndMapReduce.js
@@ -38,7 +38,7 @@ doTest = function(signal) {
slaves.forEach(function(slave) {
// try to read from slave
slave.slaveOk = true;
- var count = slave.getDB("foo").foo.count();
+ var count = slave.getDB("foo").foo.find().itcount();
printjson(count);
assert.eq(len, count, "slave count wrong: " + slave);
diff --git a/jstests/replsets/initial_sync1.js b/jstests/replsets/initial_sync1.js
index ceb614b68a6..a7beeb2b9cc 100644
--- a/jstests/replsets/initial_sync1.js
+++ b/jstests/replsets/initial_sync1.js
@@ -40,7 +40,7 @@ for (var i = 0; i < 100; i++) {
bulk.insert({date: new Date(), x: i, str: "all the talk on the market"});
}
assert.writeOK(bulk.execute());
-print("total in foo: " + foo.bar.count());
+print("total in foo: " + foo.bar.find().itcount());
print("4. Make sure synced");
replTest.awaitReplication();
diff --git a/jstests/replsets/initial_sync2.js b/jstests/replsets/initial_sync2.js
index ec6ef445954..bab1063c072 100644
--- a/jstests/replsets/initial_sync2.js
+++ b/jstests/replsets/initial_sync2.js
@@ -39,7 +39,7 @@ var doTest = function() {
for (var i = 0; i < 10000; i++) {
foo.bar.insert({date: new Date(), x: i, str: "all the talk on the market"});
}
- jsTest.log("total in foo: " + foo.bar.count());
+ jsTest.log("total in foo: " + foo.bar.find().itcount());
jsTest.log("4. Make sure synced");
replTest.awaitReplication();
diff --git a/jstests/replsets/initial_sync4.js b/jstests/replsets/initial_sync4.js
index c2fcede9969..71550251b96 100644
--- a/jstests/replsets/initial_sync4.js
+++ b/jstests/replsets/initial_sync4.js
@@ -60,7 +60,7 @@ for (i = N; i < N * 2; i++) {
mc.insert({_id: i, x: i});
}
-assert.eq(N * 2, mc.count());
+assert.eq(N * 2, mc.find().itcount());
print("7. Wait for new node to become SECONDARY");
wait(function() {
@@ -71,7 +71,7 @@ wait(function() {
print("8. Wait for new node to have all the data");
wait(function() {
- return sc.count() == mc.count();
+ return sc.find().itcount() == mc.find().itcount();
});
assert.eq(mc.getIndexKeys().length, sc.getIndexKeys().length);
diff --git a/jstests/replsets/initial_sync_update_missing_doc1.js b/jstests/replsets/initial_sync_update_missing_doc1.js
index f4ef7fe688b..88294ace49c 100644
--- a/jstests/replsets/initial_sync_update_missing_doc1.js
+++ b/jstests/replsets/initial_sync_update_missing_doc1.js
@@ -62,7 +62,7 @@
replSet.awaitSecondaryNodes();
assert.eq(0,
- secondary.getDB('test').getCollection(name).count(),
+ secondary.getDB('test').getCollection(name).find().itcount(),
'collection successfully synced to secondary');
replSet.stopSet();
diff --git a/jstests/replsets/initial_sync_update_missing_doc2.js b/jstests/replsets/initial_sync_update_missing_doc2.js
index 425b94e804b..1c92547ddab 100644
--- a/jstests/replsets/initial_sync_update_missing_doc2.js
+++ b/jstests/replsets/initial_sync_update_missing_doc2.js
@@ -77,7 +77,7 @@
replSet.awaitSecondaryNodes();
var coll = secondary.getDB('test').getCollection(name);
- assert.eq(1, coll.count(), 'collection successfully synced to secondary');
+ assert.eq(1, coll.find().itcount(), 'collection successfully synced to secondary');
assert.eq(doc, coll.findOne(), 'document on secondary matches primary');
replSet.stopSet();
diff --git a/jstests/replsets/oplog_format.js b/jstests/replsets/oplog_format.js
index a2c37d294a5..5604ae1278b 100644
--- a/jstests/replsets/oplog_format.js
+++ b/jstests/replsets/oplog_format.js
@@ -104,7 +104,7 @@ var otherTS = assertLastOplog({$set: {"a.0": 3}}, {_id: 1}, msg); // Nothing
assert.eq(lastTS, otherTS, "new oplog was not expected -- " + msg); // No new oplog entry
coll.remove({});
-assert.eq(coll.count(), 0, "collection not empty");
+assert.eq(coll.find().itcount(), 0, "collection not empty");
var msg = "bad $setOnInsert w/upsert";
res = assert.writeOK(coll.update({}, {$setOnInsert: {a: 200}}, {upsert: true})); // upsert
@@ -114,7 +114,7 @@ assert.docEq({_id: id, a: 200}, coll.findOne({}), msg); // No-op
assertLastOplog({_id: id, a: 200}, null, msg); // No new oplog entry
coll.remove({});
-assert.eq(coll.count(), 0, "collection not empty-2");
+assert.eq(coll.find().itcount(), 0, "collection not empty-2");
/* inconsistent oplog format with old code -- new is okay but less efficient
* enable once we switch the default
diff --git a/jstests/replsets/replset5.js b/jstests/replsets/replset5.js
index 65f2b66212e..43fed659284 100644
--- a/jstests/replsets/replset5.js
+++ b/jstests/replsets/replset5.js
@@ -54,13 +54,13 @@ load("jstests/replsets/rslib.js");
slaves[0].setSlaveOk();
slaves[1].setSlaveOk();
- var slave0count = slaves[0].getDB(testDB).foo.count();
+ var slave0count = slaves[0].getDB(testDB).foo.find().itcount();
assert(slave0count == docNum, "Slave 0 has " + slave0count + " of " + docNum + " documents!");
- var slave1count = slaves[1].getDB(testDB).foo.count();
+ var slave1count = slaves[1].getDB(testDB).foo.find().itcount();
assert(slave1count == docNum, "Slave 1 has " + slave1count + " of " + docNum + " documents!");
- var master1count = master.getDB(testDB).foo.count();
+ var master1count = master.getDB(testDB).foo.find().itcount();
assert(master1count == docNum, "Master has " + master1count + " of " + docNum + " documents!");
print("replset5.js reconfigure with hidden=1");
diff --git a/jstests/replsets/replset8.js b/jstests/replsets/replset8.js
index 69a16daa3a6..77a7c26763f 100644
--- a/jstests/replsets/replset8.js
+++ b/jstests/replsets/replset8.js
@@ -61,4 +61,4 @@ for (i = doccount * 2; i > doccount; --i) {
print("finished");
// Wait for replication to catch up.
rt.awaitSecondaryNodes();
-assert.eq(doccount + 1, slave.getDB('d')['c'].count());
+assert.eq(doccount + 1, slave.getDB('d')['c'].find().itcount());
diff --git a/jstests/replsets/replsets_killop.js b/jstests/replsets/replsets_killop.js
index ea1cd560b91..7d31f313633 100644
--- a/jstests/replsets/replsets_killop.js
+++ b/jstests/replsets/replsets_killop.js
@@ -13,7 +13,7 @@ db = primary.getDB('test');
db.test.save({a: 0});
replTest.awaitReplication();
assert.soon(function() {
- return secondary.getDB('test').test.count() == 1;
+ return secondary.getDB('test').test.find().itcount() == 1;
});
// Start a parallel shell to insert new documents on the primary.
@@ -39,12 +39,12 @@ for (i = 0; i < 1e3; ++i) {
// Wait for the inserter to finish.
inserter();
-assert.eq(numDocs, db.test.count());
+assert.eq(numDocs, db.test.find().itcount());
// Return true when the correct number of documents are present on the secondary. Otherwise print
// which documents are missing and return false.
function allReplicated() {
- count = secondary.getDB('test').test.count();
+ count = secondary.getDB('test').test.find().itcount();
if (count == numDocs) {
// Return true if the count is as expected.
return true;
diff --git a/jstests/replsets/resync_with_write_load.js b/jstests/replsets/resync_with_write_load.js
index 9b8988332ba..1a782ffacbe 100644
--- a/jstests/replsets/resync_with_write_load.js
+++ b/jstests/replsets/resync_with_write_load.js
@@ -66,7 +66,7 @@ var loadGen = startParallelShell(work, replTest.ports[0]);
// wait for document to appear to continue
assert.soon(function() {
try {
- return 1 == master.getDB("test")["timeToStartTrigger"].count();
+ return 1 == master.getDB("test")["timeToStartTrigger"].find().itcount();
} catch (e) {
print(e);
return false;
diff --git a/jstests/replsets/rollback.js b/jstests/replsets/rollback.js
index 9df27ec8e0a..47641a11b3c 100644
--- a/jstests/replsets/rollback.js
+++ b/jstests/replsets/rollback.js
@@ -93,8 +93,8 @@ load("jstests/replsets/rslib.js");
assert.writeOK(a.bar.insert({q: 2, a: "foo", x: 1}));
assert.writeOK(a.bar.insert({q: 3, bb: 9, a: "foo"}, {writeConcern: {w: 2}}));
- assert.eq(a.bar.count(), 3, "a.count");
- assert.eq(b.bar.count(), 3, "b.count");
+ assert.eq(a.bar.find().itcount(), 3, "a.count");
+ assert.eq(b.bar.find().itcount(), 3, "b.count");
conns[0].disconnect(conns[1]);
conns[0].disconnect(conns[2]);
@@ -112,7 +112,7 @@ load("jstests/replsets/rslib.js");
for (var i = 4; i <= 100; i++) {
assert.writeOK(b.bar.insert({q: i}));
}
- assert.eq(100, b.bar.count(), "u.count");
+ assert.eq(100, b.bar.find().itcount(), "u.count");
// a should not have the new data as it was partitioned.
conns[1].disconnect(conns[2]);
@@ -136,7 +136,7 @@ load("jstests/replsets/rslib.js");
}
});
- assert(a.bar.count() == 3, "t is 3");
+ assert.eq(3, a.bar.find().itcount(), "t is 3");
assert.writeOK(a.bar.insert({q: 7}));
assert.writeOK(a.bar.insert({q: 8}));
diff --git a/jstests/replsets/rollback2.js b/jstests/replsets/rollback2.js
index 911a9d3e128..cd4f5a049b7 100644
--- a/jstests/replsets/rollback2.js
+++ b/jstests/replsets/rollback2.js
@@ -23,8 +23,8 @@ load("jstests/replsets/rslib.js");
assert.eq(6, db.bar.count({q: {$gt: -1}}));
assert.eq(1, db.bar.count({txt: "foo"}));
assert.eq(33, db.bar.findOne({q: 0})["y"]);
- assert.eq(1, db.kap.count());
- assert.eq(0, db.kap2.count());
+ assert.eq(1, db.kap.find().itcount());
+ assert.eq(0, db.kap2.find().itcount());
};
var name = "rollback2js";
@@ -122,7 +122,7 @@ load("jstests/replsets/rslib.js");
return false;
}
});
- assert(a.bar.count() >= 1, "count check");
+ assert.gte(a.bar.find().itcount(), 1, "count check");
assert.writeOK(a.bar.insert({txt: 'foo'}));
assert.writeOK(a.bar.remove({q: 70}));
assert.writeOK(a.bar.update({q: 0}, {$inc: {y: 33}}));
diff --git a/jstests/replsets/rollback3.js b/jstests/replsets/rollback3.js
index 740f9caa383..59b685c7bad 100644
--- a/jstests/replsets/rollback3.js
+++ b/jstests/replsets/rollback3.js
@@ -19,8 +19,8 @@ load("jstests/replsets/rslib.js");
var checkFinalResults = function(db) {
assert.eq(2, db.b.getIndexes().length);
assert.eq(2, db.oldname.getIndexes().length);
- assert.eq(2, db.oldname.count());
- assert.eq(1, db.kap.count());
+ assert.eq(2, db.oldname.find().itcount());
+ assert.eq(1, db.kap.find().itcount());
assert(db.kap.isCapped());
assert.eq(0, db.bar.count({q: 70}));
assert.eq(33, db.bar.findOne({q: 0})["y"]);
@@ -28,8 +28,8 @@ load("jstests/replsets/rslib.js");
assert.eq(1, db.bar.count({txt: "foo"}));
assert.eq(200, db.bar.count({i: {$gt: -1}}));
assert.eq(6, db.bar.count({q: {$gt: -1}}));
- assert.eq(0, db.getSiblingDB("abc").foo.count());
- assert.eq(0, db.getSiblingDB("abc").bar.count());
+ assert.eq(0, db.getSiblingDB("abc").foo.find().itcount());
+ assert.eq(0, db.getSiblingDB("abc").bar.find().itcount());
};
var name = "rollback2js";
@@ -114,7 +114,7 @@ load("jstests/replsets/rslib.js");
// two to see if we transitively rollback?
b.oldname.renameCollection("newname");
b.newname.renameCollection("fooname");
- assert(b.fooname.count() > 0, "count rename");
+ assert(b.fooname.find().itcount() > 0, "count rename");
// test roll back (drop) a whole database
var abc = b.getSisterDB("abc");
assert.writeOK(abc.foo.insert({x: 1}));
@@ -139,7 +139,7 @@ load("jstests/replsets/rslib.js");
return false;
}
});
- assert(a.bar.count() >= 1, "count check");
+ assert(a.bar.find().itcount() >= 1, "count check");
assert.writeOK(a.bar.insert({txt: 'foo'}));
assert.writeOK(a.bar.remove({q: 70}));
assert.writeOK(a.bar.update({q: 0}, {$inc: {y: 33}}));
diff --git a/jstests/replsets/rollback_dropdb.js b/jstests/replsets/rollback_dropdb.js
index 818d74b2ad2..528ba48f96d 100644
--- a/jstests/replsets/rollback_dropdb.js
+++ b/jstests/replsets/rollback_dropdb.js
@@ -41,7 +41,7 @@ replTest.stop(AID);
master = replTest.getPrimary();
assert(b_conn.host === master.host, "b_conn assumed to be master");
b_conn.getDB(name).dropDatabase();
-assert.eq(0, b_conn.getDB(name).foo.count(), "dropping database failed");
+assert.eq(0, b_conn.getDB(name).foo.find().itcount(), "dropping database failed");
// shut down B and bring back the original master
replTest.stop(BID);
diff --git a/jstests/replsets/rollback_index.js b/jstests/replsets/rollback_index.js
index ca03075ad2b..c5decf73ae0 100644
--- a/jstests/replsets/rollback_index.js
+++ b/jstests/replsets/rollback_index.js
@@ -75,7 +75,7 @@ options = {
writeConcern: {w: 1, wtimeout: 60000}
};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
-assert.eq(2, a_conn.getDB(name).foo.count(), 'invalid number of documents on A');
+assert.eq(2, a_conn.getDB(name).foo.find().itcount(), 'invalid number of documents on A');
// restart B, which should rollback.
replTest.restart(BID);
@@ -92,7 +92,7 @@ assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
// Check collections and indexes.
assert.eq(3,
- b_conn.getDB(name).foo.count(),
+ b_conn.getDB(name).foo.find().itcount(),
'Collection on B does not have the same number of documents as A');
assert.eq(
a_conn.getDB(name).foo.getIndexes().length,
diff --git a/jstests/replsets/toostale.js b/jstests/replsets/toostale.js
index 4f9e10ea94e..4f1a1057757 100644
--- a/jstests/replsets/toostale.js
+++ b/jstests/replsets/toostale.js
@@ -78,7 +78,7 @@ print("okay");
print("4: overflow oplog");
reconnect(master.getDB("local"));
-var count = master.getDB("local").oplog.rs.count();
+var count = master.getDB("local").oplog.rs.find().itcount();
var prevCount = -1;
while (count > prevCount) {
print("inserting 1000");
@@ -90,7 +90,7 @@ while (count > prevCount) {
prevCount = count;
replTest.awaitReplication();
- count = master.getDB("local").oplog.rs.count();
+ count = master.getDB("local").oplog.rs.find().itcount();
print("count: " + count + " prev: " + prevCount);
}
diff --git a/jstests/replsets/two_initsync.js b/jstests/replsets/two_initsync.js
index a9d47eb3ff1..51198a814cb 100644
--- a/jstests/replsets/two_initsync.js
+++ b/jstests/replsets/two_initsync.js
@@ -86,7 +86,7 @@ doTest = function(signal) {
printjson(b.isMaster());
wait(function() {
- var c = b.getSisterDB("two").coll.count();
+ var c = b.getSisterDB("two").coll.find().itcount();
print(c);
return c == 20000;
});
diff --git a/jstests/replsets/user_management_wc.js b/jstests/replsets/user_management_wc.js
index 3aa186df277..1b28112c541 100644
--- a/jstests/replsets/user_management_wc.js
+++ b/jstests/replsets/user_management_wc.js
@@ -108,18 +108,18 @@ load('jstests/multiVersion/libs/auth_helpers.js');
adminDB.system.users.remove({});
adminDB.system.roles.remove({});
- assert.eq(0, adminDB.system.users.count());
- assert.eq(0, adminDB.system.roles.count());
+ assert.eq(0, adminDB.system.users.find().itcount());
+ assert.eq(0, adminDB.system.roles.find().itcount());
db.createUser({user: 'lorax2', pwd: 'pwd', roles: ['readWrite']});
db.createRole({role: 'role2', roles: ['readWrite'], privileges: []});
- assert.eq(1, adminDB.system.users.count());
- assert.eq(1, adminDB.system.roles.count());
+ assert.eq(1, adminDB.system.users.find().itcount());
+ assert.eq(1, adminDB.system.roles.find().itcount());
},
confirmFunc: function() {
- assert.eq(2, adminDB.system.users.count());
- assert.eq(2, adminDB.system.roles.count());
+ assert.eq(2, adminDB.system.users.find().itcount());
+ assert.eq(2, adminDB.system.roles.find().itcount());
},
admin: true
});
@@ -160,4 +160,4 @@ load('jstests/multiVersion/libs/auth_helpers.js');
testInvalidWriteConcern(cmd);
});
-})(); \ No newline at end of file
+})();