summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
authorMatt Broadstone <mbroadst@mongodb.com>2023-05-07 16:15:25 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-05-07 16:55:23 +0000
commit43b87324302209cbfa240d6c6b520007669e4ea6 (patch)
tree7039a07f7116ad86df64fd21eee62f84053ba92e /jstests/replsets
parent948bf37c910d9911160e3b275d3c51b146a9c923 (diff)
downloadmongo-43b87324302209cbfa240d6c6b520007669e4ea6.tar.gz
SERVER-74787 Prepare jstest corpus for implicit strict mode
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/auth1.js2
-rw-r--r--jstests/replsets/auth_no_pri.js2
-rw-r--r--jstests/replsets/groupAndMapReduce.js8
-rw-r--r--jstests/replsets/initial_sync_with_write_load.js2
-rw-r--r--jstests/replsets/libs/basic_replset_test.js132
-rw-r--r--jstests/replsets/localhostAuthBypass.js6
-rw-r--r--jstests/replsets/maintenance.js4
-rw-r--r--jstests/replsets/oplog_note_cmd.js2
-rw-r--r--jstests/replsets/pipelineout.js2
-rw-r--r--jstests/replsets/replset1.js138
-rw-r--r--jstests/replsets/replset2.js6
-rw-r--r--jstests/replsets/replset4.js2
-rw-r--r--jstests/replsets/replset6.js14
-rw-r--r--jstests/replsets/replsets_killop.js30
-rw-r--r--jstests/replsets/rollback_creates_rollback_directory.js2
-rw-r--r--jstests/replsets/secondarydelaysecs_waits_for_writes.js4
-rw-r--r--jstests/replsets/single_server_majority.js2
-rw-r--r--jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js2
-rw-r--r--jstests/replsets/step_down_on_secondary.js2
-rw-r--r--jstests/replsets/temp_namespace.js2
-rw-r--r--jstests/replsets/tenant_migration_donor_initial_sync_recovery.js2
-rw-r--r--jstests/replsets/tenant_migration_donor_startup_recovery.js2
-rw-r--r--jstests/replsets/tenant_migration_large_txn.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_startup_recovery.js2
-rw-r--r--jstests/replsets/tenant_migration_test_max_bson_limit.js4
-rw-r--r--jstests/replsets/unconditional_step_down.js8
28 files changed, 193 insertions, 195 deletions
diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js
index 8e45f6b403e..9f95d74d1fd 100644
--- a/jstests/replsets/auth1.js
+++ b/jstests/replsets/auth1.js
@@ -57,7 +57,7 @@ print("make sure user is written before shutting down");
MongoRunner.stopMongod(m);
print("start up rs");
-var rs = new ReplSetTest({"name": name, "nodes": 3});
+const rs = new ReplSetTest({"name": name, "nodes": 3});
// The first node is started with the pre-populated data directory.
print("start 0 with keyFile");
diff --git a/jstests/replsets/auth_no_pri.js b/jstests/replsets/auth_no_pri.js
index 35629b3a383..99425014e02 100644
--- a/jstests/replsets/auth_no_pri.js
+++ b/jstests/replsets/auth_no_pri.js
@@ -3,7 +3,7 @@
'use strict';
var NODE_COUNT = 3;
-var rs = new ReplSetTest({"nodes": NODE_COUNT, keyFile: "jstests/libs/key1"});
+const rs = new ReplSetTest({"nodes": NODE_COUNT, keyFile: "jstests/libs/key1"});
var nodes = rs.startSet();
rs.initiate();
diff --git a/jstests/replsets/groupAndMapReduce.js b/jstests/replsets/groupAndMapReduce.js
index 22935531bcf..88b0b5ffc3b 100644
--- a/jstests/replsets/groupAndMapReduce.js
+++ b/jstests/replsets/groupAndMapReduce.js
@@ -1,6 +1,6 @@
load("jstests/replsets/rslib.js");
-doTest = function(signal) {
+let doTest = function(signal) {
// Test basic replica set functionality.
// -- Replication
// -- Failover
@@ -32,7 +32,7 @@ doTest = function(signal) {
// and secondaries in the set and wait until the change has replicated.
replTest.awaitReplication();
- secondaries = replTest.getSecondaries();
+ let secondaries = replTest.getSecondaries();
assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
secondaries.forEach(function(secondary) {
// try to read from secondary
@@ -47,10 +47,10 @@ doTest = function(signal) {
print("Calling inline mr() with secondaryOk=true, must succeed");
secondary.setSecondaryOk();
- map = function() {
+ let map = function() {
emit(this.a, 1);
};
- reduce = function(key, vals) {
+ let reduce = function(key, vals) {
var sum = 0;
for (var i = 0; i < vals.length; ++i) {
sum += vals[i];
diff --git a/jstests/replsets/initial_sync_with_write_load.js b/jstests/replsets/initial_sync_with_write_load.js
index c696b347b0b..7e885dc7902 100644
--- a/jstests/replsets/initial_sync_with_write_load.js
+++ b/jstests/replsets/initial_sync_with_write_load.js
@@ -47,7 +47,7 @@ var work = function() {
assert.commandWorked(db.timeToStartTrigger.insert({_id: 1}));
while (true) {
- for (x = 0; x < 100; x++) {
+ for (let x = 0; x < 100; x++) {
db["a" + x].insert({a: x});
}
diff --git a/jstests/replsets/libs/basic_replset_test.js b/jstests/replsets/libs/basic_replset_test.js
new file mode 100644
index 00000000000..38c13987553
--- /dev/null
+++ b/jstests/replsets/libs/basic_replset_test.js
@@ -0,0 +1,132 @@
+load("jstests/replsets/rslib.js");
+load('jstests/replsets/libs/election_metrics.js');
+
+function basicReplsetTest(signal, ssl_options1, ssl_options2, ssl_name) {
+ // Test basic replica set functionality.
+ // -- Replication
+ // -- Failover
+
+ // Choose a name that is unique to the options specified.
+ // This is important because we are depending on a fresh replicaSetMonitor for each run;
+ // each differently-named replica set gets its own monitor.
+ // n0 and n1 get the same SSL config since there are 3 nodes but only 2 different configs
+ let replTest = new ReplSetTest({
+ name: 'testSet' + ssl_name,
+ nodes: {n0: ssl_options1, n1: ssl_options1, n2: ssl_options2}
+ });
+
+ // call startSet() to start each mongod in the replica set
+ replTest.startSet();
+
+ // Call initiate() to send the replSetInitiate command
+ // This will wait for initiation
+ replTest.initiate();
+
+ // Call getPrimary to return a reference to the node that's been
+ // elected primary.
+ let primary = replTest.getPrimary();
+
+ // Check that both the 'called' and 'successful' fields of the 'electionTimeout' election reason
+ // counter have been incremented in serverStatus.
+ const primaryStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
+ verifyServerStatusElectionReasonCounterValue(
+ primaryStatus.electionMetrics, "electionTimeout", 1);
+
+ // Ensure the primary logs an n-op to the oplog upon transitioning to primary.
+ assert.gt(primary.getDB("local").oplog.rs.count({op: 'n', o: {msg: 'new primary'}}), 0);
+
+ // Here's how you save something to primary
+ primary.getDB("foo").foo.save({a: 1000});
+
+ // This method will check the oplogs of the primary
+ // and secondaries in the set and wait until the change has replicated.
+ replTest.awaitReplication();
+
+ let cppconn = new Mongo(replTest.getURL()).getDB("foo");
+ assert.eq(1000, cppconn.foo.findOne().a, "cppconn 1");
+
+ {
+ // check c++ finding other servers
+ let temp = replTest.getURL();
+ temp = temp.substring(0, temp.lastIndexOf(","));
+ temp = new Mongo(temp).getDB("foo");
+ assert.eq(1000, temp.foo.findOne().a, "cppconn 1");
+ }
+
+ // Here's how to stop the primary node
+ let primaryId = replTest.getNodeId(primary);
+ replTest.stop(primaryId);
+
+ // Now let's see who the new primary is:
+ let newPrimary = replTest.getPrimary();
+
+ // Is the new primary the same as the old primary?
+ let newPrimaryId = replTest.getNodeId(newPrimary);
+
+ assert(primaryId != newPrimaryId, "Old primary shouldn't be equal to new primary.");
+
+ reconnect(cppconn);
+ assert.eq(1000, cppconn.foo.findOne().a, "cppconn 2");
+
+ // Now let's write some documents to the new primary
+ let bulk = newPrimary.getDB("bar").bar.initializeUnorderedBulkOp();
+ for (let i = 0; i < 1000; i++) {
+ bulk.insert({a: i});
+ }
+ bulk.execute();
+
+ // Here's how to restart the old primary node:
+ let secondary = replTest.restart(primaryId);
+
+ // Now, let's make sure that the old primary comes up as a secondary
+ assert.soon(function() {
+ let res = secondary.getDB("admin").runCommand({hello: 1});
+ printjson(res);
+ return res['ok'] == 1 && res['isWritablePrimary'] == false;
+ });
+
+ // And we need to make sure that the replset comes back up
+ assert.soon(function() {
+ let res = newPrimary.getDB("admin").runCommand({replSetGetStatus: 1});
+ printjson(res);
+ return res.myState == 1;
+ });
+
+ // And that both secondary nodes have all the updates
+ newPrimary = replTest.getPrimary();
+ assert.eq(1000, newPrimary.getDB("bar").runCommand({count: "bar"}).n, "assumption 2");
+ replTest.awaitSecondaryNodes();
+ replTest.awaitReplication();
+
+ let secondaries = replTest.getSecondaries();
+ assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
+ secondaries.forEach(function(secondary) {
+ secondary.setSecondaryOk();
+ let count = secondary.getDB("bar").runCommand({count: "bar"});
+ printjson(count);
+ assert.eq(1000, count.n, "secondary count wrong: " + secondary);
+ });
+
+ // last error
+ primary = replTest.getPrimary();
+ secondaries = replTest.getSecondaries();
+
+ let db = primary.getDB("foo");
+ let t = db.foo;
+
+ let ts = secondaries.map(function(z) {
+ z.setSecondaryOk();
+ return z.getDB("foo").foo;
+ });
+
+ t.save({a: 1000});
+ t.createIndex({a: 1});
+ replTest.awaitReplication();
+
+ ts.forEach(function(z) {
+ assert.eq(2, z.getIndexKeys().length, "A " + z.getMongo());
+ });
+
+ // Shut down the set and finish the test.
+ replTest.stopSet(signal);
+}
diff --git a/jstests/replsets/localhostAuthBypass.js b/jstests/replsets/localhostAuthBypass.js
index cff02a25193..3c2ce3cbeb0 100644
--- a/jstests/replsets/localhostAuthBypass.js
+++ b/jstests/replsets/localhostAuthBypass.js
@@ -107,7 +107,7 @@ var authenticate = function(mongo) {
};
var start = function(useHostName) {
- var rs = new ReplSetTest(
+ const rs = new ReplSetTest(
{name: replSetName, nodes: 3, keyFile: keyfile, auth: "", useHostName: useHostName});
rs.startSet();
@@ -126,7 +126,7 @@ var runTest = function(useHostName) {
print("=====================");
print("starting replica set: useHostName=" + useHostName);
print("=====================");
- var rs = start(useHostName);
+ const rs = start(useHostName);
var port = rs.getPort(rs.getPrimary());
var host = "localhost:" + port;
var secHosts = [];
@@ -190,7 +190,7 @@ var runNonlocalTest = function(ipAddr) {
print("starting mongod: non-local host access " + ipAddr);
print("==========================");
- var rs = start(false);
+ const rs = start(false);
var port = rs.getPort(rs.getPrimary());
var host = ipAddr + ":" + port;
var secHosts = [];
diff --git a/jstests/replsets/maintenance.js b/jstests/replsets/maintenance.js
index c034ac404d8..274b198e48c 100644
--- a/jstests/replsets/maintenance.js
+++ b/jstests/replsets/maintenance.js
@@ -23,7 +23,7 @@ assert.soon(function() {
return conns[1].getDB("admin").hello().secondary;
});
-join =
+let join =
startParallelShell("db.getSiblingDB('bar').runCommand({compact : 'foo'});", replTest.ports[1]);
print("joining");
@@ -81,7 +81,7 @@ assert.eq(recv.errmsg, "node is recovering");
print("now getmore shouldn't work");
var ex = assert.throws(function() {
- lastDoc = null;
+ let lastDoc = null;
while (cursor.hasNext()) {
lastDoc = cursor.next();
}
diff --git a/jstests/replsets/oplog_note_cmd.js b/jstests/replsets/oplog_note_cmd.js
index 1d94b9a1a41..58536d040ab 100644
--- a/jstests/replsets/oplog_note_cmd.js
+++ b/jstests/replsets/oplog_note_cmd.js
@@ -1,6 +1,6 @@
// Test that the "appendOplogNote" command works properly
-var rs = new ReplSetTest({name: "oplogNoteTest", nodes: 1});
+const rs = new ReplSetTest({name: "oplogNoteTest", nodes: 1});
rs.startSet();
rs.initiate();
diff --git a/jstests/replsets/pipelineout.js b/jstests/replsets/pipelineout.js
index ed05a93dee7..b296081e61e 100644
--- a/jstests/replsets/pipelineout.js
+++ b/jstests/replsets/pipelineout.js
@@ -11,7 +11,7 @@ var primary = replTest.getPrimary().getDB(name);
var secondary = replTest.getSecondary().getDB(name);
// populate the collection
-for (i = 0; i < 5; i++) {
+for (let i = 0; i < 5; i++) {
primary.coll.insert({x: i});
}
replTest.awaitReplication();
diff --git a/jstests/replsets/replset1.js b/jstests/replsets/replset1.js
index 7ce4610495e..a94943c6ced 100644
--- a/jstests/replsets/replset1.js
+++ b/jstests/replsets/replset1.js
@@ -1,138 +1,4 @@
-var ssl_options1;
-var ssl_options2;
-var ssl_name;
-load("jstests/replsets/rslib.js");
-load('jstests/replsets/libs/election_metrics.js');
-var doTest = function(signal) {
- // Test basic replica set functionality.
- // -- Replication
- // -- Failover
+load('jstests/replsets/libs/basic_replset_test.js');
- // Choose a name that is unique to the options specified.
- // This is important because we are depending on a fresh replicaSetMonitor for each run;
- // each differently-named replica set gets its own monitor.
- // n0 and n1 get the same SSL config since there are 3 nodes but only 2 different configs
- var replTest = new ReplSetTest({
- name: 'testSet' + ssl_name,
- nodes: {n0: ssl_options1, n1: ssl_options1, n2: ssl_options2}
- });
-
- // call startSet() to start each mongod in the replica set
- // this returns a list of nodes
- var nodes = replTest.startSet();
-
- // Call initiate() to send the replSetInitiate command
- // This will wait for initiation
- replTest.initiate();
-
- // Call getPrimary to return a reference to the node that's been
- // elected primary.
- var primary = replTest.getPrimary();
-
- // Check that both the 'called' and 'successful' fields of the 'electionTimeout' election reason
- // counter have been incremented in serverStatus.
- const primaryStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
- verifyServerStatusElectionReasonCounterValue(
- primaryStatus.electionMetrics, "electionTimeout", 1);
-
- // Ensure the primary logs an n-op to the oplog upon transitioning to primary.
- assert.gt(primary.getDB("local").oplog.rs.count({op: 'n', o: {msg: 'new primary'}}), 0);
-
- // Here's how you save something to primary
- primary.getDB("foo").foo.save({a: 1000});
-
- // This method will check the oplogs of the primary
- // and secondaries in the set and wait until the change has replicated.
- replTest.awaitReplication();
-
- var cppconn = new Mongo(replTest.getURL()).getDB("foo");
- assert.eq(1000, cppconn.foo.findOne().a, "cppconn 1");
-
- {
- // check c++ finding other servers
- var temp = replTest.getURL();
- temp = temp.substring(0, temp.lastIndexOf(","));
- temp = new Mongo(temp).getDB("foo");
- assert.eq(1000, temp.foo.findOne().a, "cppconn 1");
- }
-
- // Here's how to stop the primary node
- var primaryId = replTest.getNodeId(primary);
- replTest.stop(primaryId);
-
- // Now let's see who the new primary is:
- var newPrimary = replTest.getPrimary();
-
- // Is the new primary the same as the old primary?
- var newPrimaryId = replTest.getNodeId(newPrimary);
-
- assert(primaryId != newPrimaryId, "Old primary shouldn't be equal to new primary.");
-
- reconnect(cppconn);
- assert.eq(1000, cppconn.foo.findOne().a, "cppconn 2");
-
- // Now let's write some documents to the new primary
- var bulk = newPrimary.getDB("bar").bar.initializeUnorderedBulkOp();
- for (var i = 0; i < 1000; i++) {
- bulk.insert({a: i});
- }
- bulk.execute();
-
- // Here's how to restart the old primary node:
- var secondary = replTest.restart(primaryId);
-
- // Now, let's make sure that the old primary comes up as a secondary
- assert.soon(function() {
- var res = secondary.getDB("admin").runCommand({hello: 1});
- printjson(res);
- return res['ok'] == 1 && res['isWritablePrimary'] == false;
- });
-
- // And we need to make sure that the replset comes back up
- assert.soon(function() {
- var res = newPrimary.getDB("admin").runCommand({replSetGetStatus: 1});
- printjson(res);
- return res.myState == 1;
- });
-
- // And that both secondary nodes have all the updates
- newPrimary = replTest.getPrimary();
- assert.eq(1000, newPrimary.getDB("bar").runCommand({count: "bar"}).n, "assumption 2");
- replTest.awaitSecondaryNodes();
- replTest.awaitReplication();
-
- var secondaries = replTest.getSecondaries();
- assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
- secondaries.forEach(function(secondary) {
- secondary.setSecondaryOk();
- var count = secondary.getDB("bar").runCommand({count: "bar"});
- printjson(count);
- assert.eq(1000, count.n, "secondary count wrong: " + secondary);
- });
-
- // last error
- primary = replTest.getPrimary();
- secondaries = replTest.getSecondaries();
-
- var db = primary.getDB("foo");
- var t = db.foo;
-
- var ts = secondaries.map(function(z) {
- z.setSecondaryOk();
- return z.getDB("foo").foo;
- });
-
- t.save({a: 1000});
- t.createIndex({a: 1});
- replTest.awaitReplication();
-
- ts.forEach(function(z) {
- assert.eq(2, z.getIndexKeys().length, "A " + z.getMongo());
- });
-
- // Shut down the set and finish the test.
- replTest.stopSet(signal);
-};
-
-doTest(15);
+basicReplsetTest(15);
print("replset1.js SUCCESS");
diff --git a/jstests/replsets/replset2.js b/jstests/replsets/replset2.js
index 38134794dfb..96305aa7a49 100644
--- a/jstests/replsets/replset2.js
+++ b/jstests/replsets/replset2.js
@@ -1,6 +1,6 @@
load("jstests/replsets/rslib.js");
-doTest = function(signal) {
+let doTest = function(signal) {
// Test replication with write concern.
// Replica set testing API
@@ -50,7 +50,7 @@ doTest = function(signal) {
print("replset2.js **** TEMP 1a ****");
- m1 = primary.getDB(testDB).foo.findOne({n: 1});
+ let m1 = primary.getDB(testDB).foo.findOne({n: 1});
printjson(m1);
assert(m1['n'] == 1, "replset2.js Failed to save to primary on multiple inserts");
@@ -90,7 +90,7 @@ doTest = function(signal) {
print("replset2.js **** V1 ");
var verifyReplication = function(nodeName, collection) {
- data = collection.findOne({n: 1});
+ let data = collection.findOne({n: 1});
assert(data['n'] == 1, "replset2.js Failed to save to " + nodeName);
data = collection.findOne({n: 999});
assert(data['n'] == 999, "replset2.js Failed to save to " + nodeName);
diff --git a/jstests/replsets/replset4.js b/jstests/replsets/replset4.js
index 0ac4141a6df..4b3c8e42783 100644
--- a/jstests/replsets/replset4.js
+++ b/jstests/replsets/replset4.js
@@ -1,4 +1,4 @@
-doTest = function(signal) {
+let doTest = function(signal) {
// Test orphaned primary steps down
var replTest = new ReplSetTest({name: 'testSet', nodes: 3});
diff --git a/jstests/replsets/replset6.js b/jstests/replsets/replset6.js
index fd33175d823..8c1af72aa23 100644
--- a/jstests/replsets/replset6.js
+++ b/jstests/replsets/replset6.js
@@ -1,7 +1,7 @@
// Test replication of collection renaming
-baseName = "jstests_replsets_replset6";
+let baseName = "jstests_replsets_replset6";
var rt = new ReplSetTest({name: "replset6tests", nodes: 2});
var nodes = rt.startSet();
@@ -9,17 +9,17 @@ rt.initiate();
var p = rt.getPrimary();
rt.awaitSecondaryNodes();
var secondaries = rt.getSecondaries();
-s = secondaries[0];
+let s = secondaries[0];
s.setSecondaryOk();
-admin = p.getDB("admin");
+let admin = p.getDB("admin");
-debug = function(foo) {}; // print( foo ); }
+let debug = function(foo) {}; // print( foo ); }
// rename within db
p.getDB(baseName).one.save({a: 1});
assert.soon(function() {
- v = s.getDB(baseName).one.findOne();
+ let v = s.getDB(baseName).one.findOne();
return v && 1 == v.a;
});
@@ -41,8 +41,8 @@ assert.eq(-1, s.getDB(baseName).getCollectionNames().indexOf("one"));
// rename to new db
-first = baseName + "_first";
-second = baseName + "_second";
+let first = baseName + "_first";
+let second = baseName + "_second";
p.getDB(first).one.save({a: 1});
assert.soon(function() {
diff --git a/jstests/replsets/replsets_killop.js b/jstests/replsets/replsets_killop.js
index 3fb42d6a244..8168cd6d1cd 100644
--- a/jstests/replsets/replsets_killop.js
+++ b/jstests/replsets/replsets_killop.js
@@ -1,14 +1,14 @@
// Test correctness of replication while a secondary's get more requests are killed on the primary
// using killop. SERVER-7952
-numDocs = 1e5;
+let numDocs = 1e5;
// Set up a replica set.
-replTest = new ReplSetTest({name: 'test', nodes: 3});
-nodes = replTest.startSet();
+let replTest = new ReplSetTest({name: 'test', nodes: 3});
+let nodes = replTest.startSet();
replTest.initiate();
-primary = replTest.getPrimary();
-secondary = replTest.getSecondary();
+let primary = replTest.getPrimary();
+let secondary = replTest.getSecondary();
db = primary.getDB('test');
db.test.save({a: 0});
replTest.awaitReplication();
@@ -17,7 +17,7 @@ assert.soon(function() {
});
// Start a parallel shell to insert new documents on the primary.
-inserter = startParallelShell(
+let inserter = startParallelShell(
'var bulk = db.test.initializeUnorderedBulkOp(); \
for( i = 1; i < ' +
numDocs +
@@ -27,10 +27,10 @@ inserter = startParallelShell(
bulk.execute();');
// Periodically kill replication get mores.
-for (i = 0; i < 1e3; ++i) {
- allOps = db.currentOp();
- for (j in allOps.inprog) {
- op = allOps.inprog[j];
+for (let i = 0; i < 1e3; ++i) {
+ let allOps = db.currentOp();
+ for (let j in allOps.inprog) {
+ let op = allOps.inprog[j];
if (op.ns == 'local.oplog.rs' && op.op == 'getmore') {
db.killOp(op.opid);
}
@@ -46,20 +46,20 @@ 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.find().itcount();
+ let count = secondary.getDB('test').test.find().itcount();
if (count == numDocs) {
// Return true if the count is as expected.
return true;
}
// Identify and print the missing a-values.
- foundSet = {};
- c = secondary.getDB('test').test.find();
+ let foundSet = {};
+ let c = secondary.getDB('test').test.find();
while (c.hasNext()) {
foundSet['' + c.next().a] = true;
}
- missing = [];
- for (i = 0; i < numDocs; ++i) {
+ let missing = [];
+ for (let i = 0; i < numDocs; ++i) {
if (!(('' + i) in foundSet)) {
missing.push(i);
}
diff --git a/jstests/replsets/rollback_creates_rollback_directory.js b/jstests/replsets/rollback_creates_rollback_directory.js
index 961a7300fe3..b0cccd81ffd 100644
--- a/jstests/replsets/rollback_creates_rollback_directory.js
+++ b/jstests/replsets/rollback_creates_rollback_directory.js
@@ -42,7 +42,7 @@ function runRollbackDirectoryTest(shouldCreateRollbackFiles) {
// Make sure we have an arbiter
assert.soon(function() {
- res = conns[2].getDB("admin").runCommand({replSetGetStatus: 1});
+ let res = conns[2].getDB("admin").runCommand({replSetGetStatus: 1});
return res.myState == 7;
}, "Arbiter failed to initialize.");
diff --git a/jstests/replsets/secondarydelaysecs_waits_for_writes.js b/jstests/replsets/secondarydelaysecs_waits_for_writes.js
index 2b6a9cc8f31..2265c23f609 100644
--- a/jstests/replsets/secondarydelaysecs_waits_for_writes.js
+++ b/jstests/replsets/secondarydelaysecs_waits_for_writes.js
@@ -12,7 +12,7 @@
// ]
load("jstests/replsets/rslib.js");
-doTest = function(signal) {
+let doTest = function(signal) {
var name = "secondaryDelaySecs";
var host = getHostName();
@@ -67,7 +67,7 @@ doTest = function(signal) {
/************* Part 2 *******************/
// how about if we add a new server? will it sync correctly?
- conn = replTest.add();
+ let conn = replTest.add();
config = primary.getSiblingDB("local").system.replset.findOne();
printjson(config);
diff --git a/jstests/replsets/single_server_majority.js b/jstests/replsets/single_server_majority.js
index ee81a5306a9..fab4969d8e4 100644
--- a/jstests/replsets/single_server_majority.js
+++ b/jstests/replsets/single_server_majority.js
@@ -5,7 +5,7 @@ var mongod = MongoRunner.runMongod({});
// get db and collection, then perform a trivial insert
db = mongod.getDB("test");
-col = db.getCollection("single_server_majority");
+let col = db.getCollection("single_server_majority");
col.drop();
// see if we can get a majority write on this single server
diff --git a/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js b/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js
index ec537f873fd..32a295f4d68 100644
--- a/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js
+++ b/jstests/replsets/startup_without_fcv_document_succeeds_if_initial_sync_flag_set.js
@@ -10,7 +10,7 @@
load("jstests/libs/fail_point_util.js");
-rst = new ReplSetTest({nodes: 1});
+let rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();
diff --git a/jstests/replsets/step_down_on_secondary.js b/jstests/replsets/step_down_on_secondary.js
index c74263f7e34..10bc7f4cc23 100644
--- a/jstests/replsets/step_down_on_secondary.js
+++ b/jstests/replsets/step_down_on_secondary.js
@@ -95,7 +95,7 @@ const wTPrintPrepareConflictLogFailPoint = configureFailPoint(primary, "WTPrintP
const joinReadThread = startParallelShell(() => {
db.getMongo().setSecondaryOk();
- oldPrimaryDB = db.getSiblingDB(TestData.dbName);
+ let oldPrimaryDB = db.getSiblingDB(TestData.dbName);
assert.commandFailedWithCode(oldPrimaryDB.runCommand({
find: TestData.collName,
diff --git a/jstests/replsets/temp_namespace.js b/jstests/replsets/temp_namespace.js
index 7cb78c24860..6c89f250ee6 100644
--- a/jstests/replsets/temp_namespace.js
+++ b/jstests/replsets/temp_namespace.js
@@ -70,7 +70,7 @@ replTest.restart(replTest.getNodeId(secondary), {}, /*wait=*/ true);
// wait for the secondary to achieve secondary status
assert.soon(function() {
try {
- res = secondary.getDB("admin").runCommand({replSetGetStatus: 1});
+ let res = secondary.getDB("admin").runCommand({replSetGetStatus: 1});
return res.myState == 2;
} catch (e) {
return false;
diff --git a/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js b/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
index 4d08a30524a..e54da59798f 100644
--- a/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
@@ -149,7 +149,7 @@ if (donorDoc) {
donorDoc.blockTimestamp) == 0);
break;
default:
- throw new Error(`Invalid state "${state}" from donor doc.`);
+ throw new Error(`Invalid state "${donorDoc.state}" from donor doc.`);
}
}
diff --git a/jstests/replsets/tenant_migration_donor_startup_recovery.js b/jstests/replsets/tenant_migration_donor_startup_recovery.js
index d825ff01c7e..f4f28282623 100644
--- a/jstests/replsets/tenant_migration_donor_startup_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_startup_recovery.js
@@ -135,7 +135,7 @@ if (donorDoc) {
// being rebuilt on step up.
break;
default:
- throw new Error(`Invalid state "${state}" from donor doc.`);
+ throw new Error(`Invalid state "${donorDoc.state}" from donor doc.`);
}
}
diff --git a/jstests/replsets/tenant_migration_large_txn.js b/jstests/replsets/tenant_migration_large_txn.js
index 689ed9f5fc8..304933b36dd 100644
--- a/jstests/replsets/tenant_migration_large_txn.js
+++ b/jstests/replsets/tenant_migration_large_txn.js
@@ -51,7 +51,7 @@ function runTransaction(primaryHost, dbName, collName) {
session.getDatabase(dbName)[collName].insert({doc: makeLargeDoc(10)});
session.getDatabase(dbName)[collName].insert({doc: makeLargeDoc(5)});
session.getDatabase(dbName)[collName].insert({doc: makeLargeDoc(5)});
- commitRes = session.commitTransaction_forTesting();
+ let commitRes = session.commitTransaction_forTesting();
assert.eq(1, commitRes.ok);
session.endSession();
}
diff --git a/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js b/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js
index 1e11553310a..df7b18a6f5e 100644
--- a/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js
+++ b/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js
@@ -104,7 +104,7 @@ function runTest({storeFindAndModifyImagesInSideCollection = false}) {
const docsToInsert =
[...Array(numToInsert).keys()].map(i => ({_id: `bulkRetryableWrite${i}`}));
- donorConn = new Mongo(host);
+ let donorConn = new Mongo(host);
const tenantSession4 = donorConn.startSession({retryWrites: true});
const tenantCollection4 = tenantSession4.getDatabase(dbName)[collName];
diff --git a/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js b/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js
index caa8562c137..aaae3cbe9fc 100644
--- a/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js
+++ b/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js
@@ -97,7 +97,7 @@ if (recipientDoc) {
}
break;
default:
- throw new Error(`Invalid state "${state}" from recipient doc.`);
+ throw new Error(`Invalid state "${recipientDoc.state}" from recipient doc.`);
}
}
diff --git a/jstests/replsets/tenant_migration_recipient_startup_recovery.js b/jstests/replsets/tenant_migration_recipient_startup_recovery.js
index a59601be1be..91b7b56dcae 100644
--- a/jstests/replsets/tenant_migration_recipient_startup_recovery.js
+++ b/jstests/replsets/tenant_migration_recipient_startup_recovery.js
@@ -102,7 +102,7 @@ if (recipientDoc) {
}
break;
default:
- throw new Error(`Invalid state "${state}" from recipient doc.`);
+ throw new Error(`Invalid state "${recipientDoc.state}" from recipient doc.`);
}
}
diff --git a/jstests/replsets/tenant_migration_test_max_bson_limit.js b/jstests/replsets/tenant_migration_test_max_bson_limit.js
index 97115f3c764..018f27fc8d2 100644
--- a/jstests/replsets/tenant_migration_test_max_bson_limit.js
+++ b/jstests/replsets/tenant_migration_test_max_bson_limit.js
@@ -28,8 +28,8 @@ function bulkWriteDocsUnordered(primaryHost, dbName, collName, numDocs) {
}
let request = {insert: collName, documents: batch, writeConcern: {w: 1}, ordered: false};
- res = assert.commandFailedWithCode(primaryDB[collName].runCommand(request),
- ErrorCodes.TenantMigrationCommitted);
+ let res = assert.commandFailedWithCode(primaryDB[collName].runCommand(request),
+ ErrorCodes.TenantMigrationCommitted);
return res;
}
diff --git a/jstests/replsets/unconditional_step_down.js b/jstests/replsets/unconditional_step_down.js
index 4908d1a8680..e2a32291062 100644
--- a/jstests/replsets/unconditional_step_down.js
+++ b/jstests/replsets/unconditional_step_down.js
@@ -158,7 +158,7 @@ function runStepsDowntoRemoved(params) {
runStepDownTest({
testMsg: "reconfig command",
stepDownFn: () => {
- load("./jstests/replsets/rslib.js");
+ load("jstests/replsets/rslib.js");
var newConfig = rst.getReplSetConfigFromNode();
var oldMasterId = rst.getNodeId(primary);
@@ -176,7 +176,7 @@ runStepDownTest({
runStepDownTest({
testMsg: "reconfig via heartbeat",
stepDownFn: () => {
- load("./jstests/replsets/rslib.js");
+ load("jstests/replsets/rslib.js");
var newConfig = rst.getReplSetConfigFromNode();
var oldMasterId = rst.getNodeId(primary);
@@ -194,7 +194,7 @@ runStepDownTest({
runStepsDowntoRemoved({
testMsg: "reconfig via heartbeat - primary to removed",
stepDownFn: () => {
- load("./jstests/replsets/rslib.js");
+ load("jstests/replsets/rslib.js");
var newConfig = rst.getReplSetConfigFromNode();
var oldMasterId = rst.getNodeId(primary);
@@ -213,7 +213,7 @@ runStepsDowntoRemoved({
runStepDownTest({
testMsg: "stepdown via heartbeat",
stepDownFn: () => {
- load("./jstests/replsets/rslib.js");
+ load("jstests/replsets/rslib.js");
var newConfig = rst.getReplSetConfigFromNode();
var newMasterId = rst.getNodeId(secondary);