summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/replica_set_connection_getmore.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/replica_set_connection_getmore.js')
-rw-r--r--jstests/noPassthrough/replica_set_connection_getmore.js80
1 files changed, 40 insertions, 40 deletions
diff --git a/jstests/noPassthrough/replica_set_connection_getmore.js b/jstests/noPassthrough/replica_set_connection_getmore.js
index acc1d7e31c3..e7167fbd5eb 100644
--- a/jstests/noPassthrough/replica_set_connection_getmore.js
+++ b/jstests/noPassthrough/replica_set_connection_getmore.js
@@ -4,44 +4,44 @@
* @tags: [requires_replication]
*/
(function() {
- "use strict";
- var rst = new ReplSetTest({nodes: 2});
- rst.startSet();
- rst.initiate();
-
- const dbName = "test";
- const collName = "getmore";
-
- // We create our own replica set connection because 'rst.nodes' is an array of direct
- // connections to each individual node.
- var conn = new Mongo(rst.getURL());
-
- // We force a read mode of "compatibility" so that we can test Mongo.prototype.readMode()
- // resolves to "commands" independently of the --readMode passed to the mongo shell running this
- // test.
- conn.forceReadMode("compatibility");
- assert.eq("commands",
- conn.readMode(),
- "replica set connections created by the mongo shell should use 'commands' read mode");
- var coll = conn.getDB(dbName)[collName];
- coll.drop();
-
- // Insert several document so that we can use a cursor to fetch them in multiple batches.
- var res = coll.insert([{}, {}, {}, {}, {}]);
- assert.writeOK(res);
- assert.eq(5, res.nInserted);
-
- // Wait for the secondary to catch up because we're going to try and do reads from it.
- rst.awaitReplication();
-
- // Establish a cursor on the secondary and verify that the getMore operations are routed to it.
- var cursor = coll.find().readPref("secondary").batchSize(2);
- assert.eq(5, cursor.itcount(), "failed to read the documents from the secondary");
-
- // Verify that queries work when the read mode is forced to "legacy" reads.
- conn.forceReadMode("legacy");
- var cursor = coll.find().readPref("secondary").batchSize(2);
- assert.eq(5, cursor.itcount(), "failed to read the documents from the secondary");
-
- rst.stopSet();
+"use strict";
+var rst = new ReplSetTest({nodes: 2});
+rst.startSet();
+rst.initiate();
+
+const dbName = "test";
+const collName = "getmore";
+
+// We create our own replica set connection because 'rst.nodes' is an array of direct
+// connections to each individual node.
+var conn = new Mongo(rst.getURL());
+
+// We force a read mode of "compatibility" so that we can test Mongo.prototype.readMode()
+// resolves to "commands" independently of the --readMode passed to the mongo shell running this
+// test.
+conn.forceReadMode("compatibility");
+assert.eq("commands",
+ conn.readMode(),
+ "replica set connections created by the mongo shell should use 'commands' read mode");
+var coll = conn.getDB(dbName)[collName];
+coll.drop();
+
+// Insert several document so that we can use a cursor to fetch them in multiple batches.
+var res = coll.insert([{}, {}, {}, {}, {}]);
+assert.writeOK(res);
+assert.eq(5, res.nInserted);
+
+// Wait for the secondary to catch up because we're going to try and do reads from it.
+rst.awaitReplication();
+
+// Establish a cursor on the secondary and verify that the getMore operations are routed to it.
+var cursor = coll.find().readPref("secondary").batchSize(2);
+assert.eq(5, cursor.itcount(), "failed to read the documents from the secondary");
+
+// Verify that queries work when the read mode is forced to "legacy" reads.
+conn.forceReadMode("legacy");
+var cursor = coll.find().readPref("secondary").batchSize(2);
+assert.eq(5, cursor.itcount(), "failed to read the documents from the secondary");
+
+rst.stopSet();
})();