summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Mir <ali.mir@mongodb.com>2020-08-26 11:28:13 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-04 14:15:35 +0000
commit0c2f4ad0b12d4890ff4c7766641ddb2f9ec7cd63 (patch)
tree68f0b9dc0c19dbef0235688cb8cdfe7ba63cf948
parent3f9e675017474fd53b6cc149ea492aed95b8c92d (diff)
downloadmongo-0c2f4ad0b12d4890ff4c7766641ddb2f9ec7cd63.tar.gz
SERVER-49993 Update _slaves to _secondaries in replsettest.js
-rw-r--r--jstests/free_mon/free_mon_rs_register.js4
-rw-r--r--jstests/gle/gle_sharded_wc.js4
-rw-r--r--jstests/hooks/run_initial_sync_node_validation.js2
-rw-r--r--jstests/noPassthrough/minvalid2.js62
-rw-r--r--jstests/noPassthroughWithMongod/replReads.js4
-rw-r--r--jstests/noPassthroughWithMongod/ttl_repl.js66
-rw-r--r--jstests/replsets/auth1.js54
-rw-r--r--jstests/replsets/buildindexes.js26
-rw-r--r--jstests/replsets/capped_insert_order.js20
-rw-r--r--jstests/replsets/fsync_lock_read_secondaries.js34
-rw-r--r--jstests/replsets/get_replication_info_helper.js4
-rw-r--r--jstests/replsets/groupAndMapReduce.js46
-rw-r--r--jstests/replsets/initial_sync1.js41
-rw-r--r--jstests/replsets/ismaster1.js14
-rw-r--r--jstests/replsets/maintenance2.js30
-rw-r--r--jstests/replsets/maxSyncSourceLagSecs.js33
-rw-r--r--jstests/replsets/pipelineout.js2
-rw-r--r--jstests/replsets/read_committed.js2
-rw-r--r--jstests/replsets/read_committed_after_rollback.js4
-rw-r--r--jstests/replsets/read_committed_lookup.js2
-rw-r--r--jstests/replsets/read_committed_no_snapshots.js5
-rw-r--r--jstests/replsets/read_committed_on_secondary.js2
-rw-r--r--jstests/replsets/read_committed_with_catalog_changes.js2
-rw-r--r--jstests/replsets/refresh_sessions_rs.js3
-rw-r--r--jstests/replsets/replset1.js72
-rw-r--r--jstests/replsets/replset2.js70
-rw-r--r--jstests/replsets/replset3.js34
-rw-r--r--jstests/replsets/replset4.js18
-rw-r--r--jstests/replsets/replset5.js32
-rw-r--r--jstests/replsets/replset6.js12
-rw-r--r--jstests/replsets/replsetrestart1.js21
-rw-r--r--jstests/replsets/slavedelay1.js46
-rw-r--r--jstests/replsets/slavedelay3.js20
-rw-r--r--jstests/replsets/stepdown.js102
-rw-r--r--jstests/replsets/stepdown3.js14
-rw-r--r--jstests/replsets/sync_passive.js24
-rw-r--r--jstests/sharding/read_committed_lookup.js2
-rw-r--r--jstests/sharding/rename.js6
-rw-r--r--jstests/sharding/shard_insert_getlasterror_w2.js3
-rw-r--r--jstests/slow1/replsets_priority1.js19
-rw-r--r--jstests/ssl/initial_sync1_x509.js12
-rw-r--r--src/mongo/shell/replsettest.js22
42 files changed, 500 insertions, 495 deletions
diff --git a/jstests/free_mon/free_mon_rs_register.js b/jstests/free_mon/free_mon_rs_register.js
index 94b07fb1257..1c312d5fb4c 100644
--- a/jstests/free_mon/free_mon_rs_register.js
+++ b/jstests/free_mon/free_mon_rs_register.js
@@ -57,7 +57,7 @@ function isUUID(val) {
assert.eq(isUUID(last_register.payload.uuid['local.oplog.rs']), true);
// Restart the secondary
-var s1 = rst._slaves[0];
+var s1 = rst.getSecondary();
var s1Id = rst.getNodeId(s1);
rst.stop(s1Id);
@@ -77,7 +77,7 @@ WaitForFreeMonServerStatusState(rst.getPrimary(), 'disabled');
WaitForFreeMonServerStatusState(rst.getSecondary(), 'disabled');
// Restart the secondary with it disabled
-var s1 = rst._slaves[0];
+var s1 = rst.getSecondary();
var s1Id = rst.getNodeId(s1);
rst.stop(s1Id);
diff --git a/jstests/gle/gle_sharded_wc.js b/jstests/gle/gle_sharded_wc.js
index 36ad2649142..a936e8f926d 100644
--- a/jstests/gle/gle_sharded_wc.js
+++ b/jstests/gle/gle_sharded_wc.js
@@ -86,7 +86,7 @@ assert.eq(coll.count(), 1);
//
// Successful remove on one shard, write concern timeout on the other
-var s0Id = st.rs0.getNodeId(st.rs0._slaves[0]);
+var s0Id = st.rs0.getNodeId(st.rs0.getSecondary());
st.rs0.stop(s0Id);
coll.remove({});
st.rs1.awaitReplication(); // To ensure the first shard won't timeout
@@ -100,7 +100,7 @@ assert.eq(coll.count(), 0);
//
// Successful remove on two hosts, write concern timeout on both
// We don't aggregate two timeouts together
-var s1Id = st.rs1.getNodeId(st.rs1._slaves[0]);
+var s1Id = st.rs1.getNodeId(st.rs1.getSecondary());
st.rs1.stop(s1Id);
// new writes to both shards to ensure that remove will do something on both of them
coll.insert({_id: -1});
diff --git a/jstests/hooks/run_initial_sync_node_validation.js b/jstests/hooks/run_initial_sync_node_validation.js
index b624267f28a..935e9d46bc5 100644
--- a/jstests/hooks/run_initial_sync_node_validation.js
+++ b/jstests/hooks/run_initial_sync_node_validation.js
@@ -20,7 +20,7 @@ assert(primary, 'calling getPrimary() failed');
// Find the hidden node.
var hiddenNode;
-for (var secondary of rst._slaves) {
+for (var secondary of rst.getSecondaries()) {
var isMasterRes = secondary.getDB('admin').isMaster();
if (isMasterRes.hidden) {
hiddenNode = secondary;
diff --git a/jstests/noPassthrough/minvalid2.js b/jstests/noPassthrough/minvalid2.js
index 5a731f0ffb7..a6004c28c70 100644
--- a/jstests/noPassthrough/minvalid2.js
+++ b/jstests/noPassthrough/minvalid2.js
@@ -1,14 +1,14 @@
/**
* This checks rollback, which shouldn't happen unless we have reached minvalid.
* 1. make 3-member set w/arb (2)
- * 2. shut down slave
- * 3. do writes to master
- * 4. modify master's minvalid
- * 5. shut down master
- * 6. start up slave
- * 7. writes on former slave (now primary)
- * 8. start up master
- * 9. check master does not rollback
+ * 2. shut down secondary
+ * 3. do writes to primary
+ * 4. modify primary's minvalid
+ * 5. shut down primary
+ * 6. start up secondary
+ * 7. writes on former secondary (now primary)
+ * 8. start up primary
+ * 9. check primary does not rollback
*
* If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will
* not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a
@@ -35,29 +35,29 @@ replTest.initiate({
{_id: 2, host: host + ":" + replTest.ports[2], arbiterOnly: true}
]
});
-var slaves = replTest._slaves;
-var master = replTest.getPrimary();
-var masterId = replTest.getNodeId(master);
-var slave = slaves[0];
-var slaveId = replTest.getNodeId(slave);
+var secondaries = replTest.getSecondaries();
+var primary = replTest.getPrimary();
+var primaryId = replTest.getNodeId(primary);
+var secondary = secondaries[0];
+var secondaryId = replTest.getNodeId(secondary);
// Wait for primary to detect that the arbiter is up so that it won't step down when we later take
// the secondary offline.
replTest.waitForState(replTest.nodes[2], ReplSetTest.State.ARBITER);
-var mdb = master.getDB("foo");
+var mdb = primary.getDB("foo");
mdb.foo.save({a: 1000});
replTest.awaitReplication();
-print("2: shut down slave");
-replTest.stop(slaveId);
+print("2: shut down secondary");
+replTest.stop(secondaryId);
-print("3: write to master");
+print("3: write to primary");
assert.commandWorked(mdb.foo.insert({a: 1001}, {writeConcern: {w: 1}}));
-print("4: modify master's minvalid");
-var local = master.getDB("local");
+print("4: modify primary's minvalid");
+var local = primary.getDB("local");
var lastOp = local.oplog.rs.find().sort({$natural: -1}).limit(1).next();
printjson(lastOp);
@@ -71,24 +71,24 @@ local.replset.minvalid.update({},
{upsert: true});
printjson(local.replset.minvalid.findOne());
-print("5: shut down master");
-replTest.stop(masterId);
+print("5: shut down primary");
+replTest.stop(primaryId);
-print("6: start up slave");
-replTest.restart(slaveId);
+print("6: start up secondary");
+replTest.restart(secondaryId);
-print("7: writes on former slave");
-master = replTest.getPrimary();
-mdb1 = master.getDB("foo");
+print("7: writes on former secondary");
+primary = replTest.getPrimary();
+mdb1 = primary.getDB("foo");
mdb1.foo.save({a: 1002});
-print("8: start up former master");
+print("8: start up former primary");
clearRawMongoProgramOutput();
-replTest.restart(masterId);
+replTest.restart(primaryId);
-print("9: check former master " + replTest.nodes[masterId].host + " does not select former slave " +
- slave.host + " as sync source");
-replTest.waitForState(replTest.nodes[masterId], ReplSetTest.State.RECOVERING, 90000);
+print("9: check former primary " + replTest.nodes[primaryId].host +
+ " does not select former secondary " + secondary.host + " as sync source");
+replTest.waitForState(replTest.nodes[primaryId], ReplSetTest.State.RECOVERING, 90000);
// Sync source selection will log this message if it does not detect min valid in the sync
// source candidate's oplog.
diff --git a/jstests/noPassthroughWithMongod/replReads.js b/jstests/noPassthroughWithMongod/replReads.js
index 30fdd3e90ce..5c40dbd900c 100644
--- a/jstests/noPassthroughWithMongod/replReads.js
+++ b/jstests/noPassthroughWithMongod/replReads.js
@@ -13,7 +13,7 @@ function testReadLoadBalancing(numReplicas) {
s.getDB("test").foo.insert({a: 123});
primary = s.rs0.getPrimary();
- secondaries = s.rs0._slaves;
+ secondaries = s.rs0.getSecondaries();
function rsStats() {
return s.getDB("admin").runCommand("connPoolStats")["replicaSets"][s.rs0.name];
@@ -99,7 +99,7 @@ function testReadLoadBalancing(numReplicas) {
}, "one slave not ok", 180000, 5000);
// Secondaries may change here
- secondaries = s.rs0._slaves;
+ secondaries = s.rs0.getSecondaries();
for (var i = 0; i < secondaries.length * 10; i++) {
conn = new Mongo(s._mongos[0].host);
diff --git a/jstests/noPassthroughWithMongod/ttl_repl.js b/jstests/noPassthroughWithMongod/ttl_repl.js
index 1d1f3f001ee..ff15887b93b 100644
--- a/jstests/noPassthroughWithMongod/ttl_repl.js
+++ b/jstests/noPassthroughWithMongod/ttl_repl.js
@@ -16,73 +16,73 @@ var rt = new ReplSetTest({name: "ttl_repl", nodes: 2});
// setup set
var nodes = rt.startSet();
rt.initiate();
-var master = rt.getPrimary();
+var primary = rt.getPrimary();
rt.awaitSecondaryNodes();
-var slave1 = rt._slaves[0];
+var secondary1 = rt.getSecondary();
// shortcuts
-var masterdb = master.getDB('d');
-var slave1db = slave1.getDB('d');
-var mastercol = masterdb['c'];
-var slave1col = slave1db['c'];
+var primarydb = primary.getDB('d');
+var secondary1db = secondary1.getDB('d');
+var primarycol = primarydb['c'];
+var secondary1col = secondary1db['c'];
-mastercol.drop();
-masterdb.createCollection(mastercol.getName());
+primarycol.drop();
+primarydb.createCollection(primarycol.getName());
// create new collection. insert 24 docs, aged at one-hour intervalss
now = (new Date()).getTime();
-var bulk = mastercol.initializeUnorderedBulkOp();
+var bulk = primarycol.initializeUnorderedBulkOp();
for (i = 0; i < 24; i++) {
bulk.insert({x: new Date(now - (3600 * 1000 * i))});
}
assert.commandWorked(bulk.execute());
rt.awaitReplication();
-assert.eq(24, mastercol.count(), "docs not inserted on primary");
-assert.eq(24, slave1col.count(), "docs not inserted on secondary");
+assert.eq(24, primarycol.count(), "docs not inserted on primary");
+assert.eq(24, secondary1col.count(), "docs not inserted on secondary");
print("Initial Stats:");
-print("Master:");
-printjson(mastercol.stats());
-print("Slave1:");
-printjson(slave1col.stats());
+print("Primary:");
+printjson(primarycol.stats());
+print("Secondary1:");
+printjson(secondary1col.stats());
// create TTL index, wait for TTL monitor to kick in, then check that
// the correct number of docs age out
var initialExpireAfterSeconds = 20000;
assert.commandWorked(
- mastercol.ensureIndex({x: 1}, {expireAfterSeconds: initialExpireAfterSeconds}));
+ primarycol.ensureIndex({x: 1}, {expireAfterSeconds: initialExpireAfterSeconds}));
rt.awaitReplication();
sleep(70 * 1000); // TTL monitor runs every 60 seconds, so wait 70
print("Stats after waiting for TTL Monitor:");
-print("Master:");
-printjson(mastercol.stats());
-print("Slave1:");
-printjson(slave1col.stats());
+print("Primary:");
+printjson(primarycol.stats());
+print("Secondary1:");
+printjson(secondary1col.stats());
-assert.eq(6, mastercol.count(), "docs not deleted on primary");
-assert.eq(6, slave1col.count(), "docs not deleted on secondary");
+assert.eq(6, primarycol.count(), "docs not deleted on primary");
+assert.eq(6, secondary1col.count(), "docs not deleted on secondary");
/******** Part 2 ***************/
// add a new secondary, wait for it to fully join
-var slave = rt.add();
+var secondary = rt.add();
var config = rt.getReplSetConfig();
config.version = rt.getReplSetConfigFromNode().version + 1;
reconfig(rt, config);
-var slave2col = slave.getDB('d')['c'];
+var secondary2col = secondary.getDB('d')['c'];
// check that the new secondary has the correct number of docs
-print("New Slave stats:");
-printjson(slave2col.stats());
+print("New Secondary stats:");
+printjson(secondary2col.stats());
-assert.eq(6, slave2col.count(), "wrong number of docs on new secondary");
+assert.eq(6, secondary2col.count(), "wrong number of docs on new secondary");
/******* Part 3 *****************/
// Check that the collMod command successfully updates the expireAfterSeconds field
-masterdb.runCommand({collMod: "c", index: {keyPattern: {x: 1}, expireAfterSeconds: 10000}});
+primarydb.runCommand({collMod: "c", index: {keyPattern: {x: 1}, expireAfterSeconds: 10000}});
rt.awaitReplication();
function getTTLTime(theCollection, theKey) {
@@ -94,14 +94,14 @@ function getTTLTime(theCollection, theKey) {
throw "not found";
}
-printjson(masterdb.c.getIndexes());
-assert.eq(10000, getTTLTime(masterdb.c, {x: 1}));
-assert.eq(10000, getTTLTime(slave1db.c, {x: 1}));
+printjson(primarydb.c.getIndexes());
+assert.eq(10000, getTTLTime(primarydb.c, {x: 1}));
+assert.eq(10000, getTTLTime(secondary1db.c, {x: 1}));
// Verify the format of TTL collMod oplog entry. The old expiration time should be saved,
// and index key patterns should be normalized to index names.
-var masterOplog = master.getDB('local').oplog.rs.find().sort({$natural: 1}).toArray();
-var collModEntry = masterOplog.find(op => op.o.collMod);
+var primaryOplog = primary.getDB('local').oplog.rs.find().sort({$natural: 1}).toArray();
+var collModEntry = primaryOplog.find(op => op.o.collMod);
assert(collModEntry, "collMod entry was not present in the oplog.");
assert.eq(initialExpireAfterSeconds, collModEntry.o2["expireAfterSeconds_old"]);
diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js
index b931524352e..cfc9c405dd1 100644
--- a/jstests/replsets/auth1.js
+++ b/jstests/replsets/auth1.js
@@ -76,19 +76,19 @@ rs.awaitNodesAgreeOnPrimaryNoAuth();
m.getDB('admin').logout(); // In case this node doesn't become primary, make sure its not auth'd
-var master = rs.getPrimary();
+var primary = rs.getPrimary();
rs.awaitSecondaryNodes();
-var mId = rs.getNodeId(master);
-var slave = rs._slaves[0];
-assert.eq(1, master.getDB("admin").auth("foo", "bar"));
-assert.commandWorked(master.getDB("test").foo.insert(
+var mId = rs.getNodeId(primary);
+var secondary = rs.getSecondary();
+assert.eq(1, primary.getDB("admin").auth("foo", "bar"));
+assert.commandWorked(primary.getDB("test").foo.insert(
{x: 1}, {writeConcern: {w: 3, wtimeout: ReplSetTest.kDefaultTimeoutMS}}));
print("try some legal and illegal reads");
-var r = master.getDB("test").foo.findOne();
+var r = primary.getDB("test").foo.findOne();
assert.eq(r.x, 1);
-slave.setSlaveOk();
+secondary.setSlaveOk();
function doQueryOn(p) {
var error = assert.throws(function() {
@@ -98,23 +98,23 @@ function doQueryOn(p) {
assert.gt(error.indexOf("command find requires authentication"), -1, "error was non-auth");
}
-doQueryOn(slave);
-master.adminCommand({logout: 1});
+doQueryOn(secondary);
+primary.adminCommand({logout: 1});
print("unauthorized:");
-printjson(master.adminCommand({replSetGetStatus: 1}));
+printjson(primary.adminCommand({replSetGetStatus: 1}));
-doQueryOn(master);
+doQueryOn(primary);
-result = slave.getDB("test").auth("bar", "baz");
+result = secondary.getDB("test").auth("bar", "baz");
assert.eq(result, 1);
-r = slave.getDB("test").foo.findOne();
+r = secondary.getDB("test").foo.findOne();
assert.eq(r.x, 1);
print("add some data");
-master.getDB("test").auth("bar", "baz");
-var bulk = master.getDB("test").foo.initializeUnorderedBulkOp();
+primary.getDB("test").auth("bar", "baz");
+var bulk = primary.getDB("test").foo.initializeUnorderedBulkOp();
for (var i = 0; i < 1000; i++) {
bulk.insert({x: i, foo: "bar"});
}
@@ -123,11 +123,11 @@ assert.commandWorked(bulk.execute({w: 3, wtimeout: ReplSetTest.kDefaultTimeoutMS
print("fail over");
rs.stop(mId);
-master = rs.getPrimary();
+primary = rs.getPrimary();
print("add some more data 1");
-master.getDB("test").auth("bar", "baz");
-bulk = master.getDB("test").foo.initializeUnorderedBulkOp();
+primary.getDB("test").auth("bar", "baz");
+bulk = primary.getDB("test").foo.initializeUnorderedBulkOp();
for (var i = 0; i < 1000; i++) {
bulk.insert({x: i, foo: "bar"});
}
@@ -135,10 +135,10 @@ assert.commandWorked(bulk.execute({w: 2}));
print("resync");
rs.restart(mId, {"keyFile": key1_600});
-master = rs.getPrimary();
+primary = rs.getPrimary();
print("add some more data 2");
-bulk = master.getDB("test").foo.initializeUnorderedBulkOp();
+bulk = primary.getDB("test").foo.initializeUnorderedBulkOp();
for (var i = 0; i < 1000; i++) {
bulk.insert({x: i, foo: "bar"});
}
@@ -153,22 +153,22 @@ var conn = MongoRunner.runMongod({
keyFile: key2_600
});
-master.getDB("admin").auth("foo", "bar");
-var config = master.getDB("local").system.replset.findOne();
+primary.getDB("admin").auth("foo", "bar");
+var config = primary.getDB("local").system.replset.findOne();
config.members.push({_id: 3, host: rs.host + ":" + port[3]});
config.version++;
try {
- master.adminCommand({replSetReconfig: config});
+ primary.adminCommand({replSetReconfig: config});
} catch (e) {
print("error: " + e);
}
-master = rs.getPrimary();
-master.getDB("admin").auth("foo", "bar");
+primary = rs.getPrimary();
+primary.getDB("admin").auth("foo", "bar");
print("shouldn't ever sync");
for (var i = 0; i < 10; i++) {
print("iteration: " + i);
- var results = master.adminCommand({replSetGetStatus: 1});
+ var results = primary.adminCommand({replSetGetStatus: 1});
printjson(results);
assert(results.members[3].state != 2);
sleep(1000);
@@ -188,7 +188,7 @@ var conn = MongoRunner.runMongod({
wait(function() {
try {
- var results = master.adminCommand({replSetGetStatus: 1});
+ var results = primary.adminCommand({replSetGetStatus: 1});
printjson(results);
return results.members[3].state == 2;
} catch (e) {
diff --git a/jstests/replsets/buildindexes.js b/jstests/replsets/buildindexes.js
index 1276ad73a61..e00a9e94ef7 100644
--- a/jstests/replsets/buildindexes.js
+++ b/jstests/replsets/buildindexes.js
@@ -17,32 +17,32 @@ config.members[2].buildIndexes = false;
replTest.initiate(config);
-var master = replTest.getPrimary().getDB(name);
-var slaveConns = replTest._slaves;
-var slave = [];
-for (var i in slaveConns) {
- slaveConns[i].setSlaveOk();
- slave.push(slaveConns[i].getDB(name));
+var primary = replTest.getPrimary().getDB(name);
+var secondaryConns = replTest.getSecondaries();
+var secondaries = [];
+for (var i in secondaryConns) {
+ secondaryConns[i].setSlaveOk();
+ secondaries.push(secondaryConns[i].getDB(name));
}
replTest.awaitReplication();
-master.x.ensureIndex({y: 1});
+primary.x.ensureIndex({y: 1});
for (i = 0; i < 100; i++) {
- master.x.insert({x: 1, y: "abc", c: 1});
+ primary.x.insert({x: 1, y: "abc", c: 1});
}
replTest.awaitReplication();
-assert.commandWorked(slave[0].runCommand({count: "x"}));
+assert.commandWorked(secondaries[0].runCommand({count: "x"}));
-var indexes = slave[0].stats().indexes;
+var indexes = secondaries[0].stats().indexes;
assert.eq(indexes, 2, 'number of indexes');
-indexes = slave[1].stats().indexes;
+indexes = secondaries[1].stats().indexes;
assert.eq(indexes, 1);
-indexes = slave[0].x.stats().indexSizes;
+indexes = secondaries[0].x.stats().indexSizes;
var count = 0;
for (i in indexes) {
@@ -55,7 +55,7 @@ for (i in indexes) {
assert.eq(count, 2);
-indexes = slave[1].x.stats().indexSizes;
+indexes = secondaries[1].x.stats().indexSizes;
count = 0;
for (i in indexes) {
diff --git a/jstests/replsets/capped_insert_order.js b/jstests/replsets/capped_insert_order.js
index 91f94f9579b..90e4223c75b 100644
--- a/jstests/replsets/capped_insert_order.js
+++ b/jstests/replsets/capped_insert_order.js
@@ -8,23 +8,23 @@ var replTest = new ReplSetTest({name: 'capped_insert_order', nodes: 2});
replTest.startSet();
replTest.initiate();
-var master = replTest.getPrimary();
-var slave = replTest._slaves[0];
+var primary = replTest.getPrimary();
+var secondary = replTest.getSecondary();
var dbName = "db";
-var masterDb = master.getDB(dbName);
-var slaveDb = slave.getDB(dbName);
+var primaryDb = primary.getDB(dbName);
+var secondaryDb = secondary.getDB(dbName);
var collectionName = "collection";
-var masterColl = masterDb[collectionName];
-var slaveColl = slaveDb[collectionName];
+var primaryColl = primaryDb[collectionName];
+var secondaryColl = secondaryDb[collectionName];
// Making a large capped collection to ensure that every document fits.
-masterDb.createCollection(collectionName, {capped: true, size: 1024 * 1024});
+primaryDb.createCollection(collectionName, {capped: true, size: 1024 * 1024});
// Insert 1000 docs with _id from 0 to 999 inclusive.
const nDocuments = 1000;
-var batch = masterColl.initializeOrderedBulkOp();
+var batch = primaryColl.initializeOrderedBulkOp();
for (var i = 0; i < nDocuments; i++) {
batch.insert({_id: i});
}
@@ -42,8 +42,8 @@ function checkCollection(coll) {
assert.eq(i, nDocuments);
}
-checkCollection(masterColl);
-checkCollection(slaveColl);
+checkCollection(primaryColl);
+checkCollection(secondaryColl);
replTest.stopSet();
})();
diff --git a/jstests/replsets/fsync_lock_read_secondaries.js b/jstests/replsets/fsync_lock_read_secondaries.js
index 91e891f79d6..e73ceab58ba 100644
--- a/jstests/replsets/fsync_lock_read_secondaries.js
+++ b/jstests/replsets/fsync_lock_read_secondaries.js
@@ -10,11 +10,11 @@
/*
* 1) Create a replica set.
- * 2) Add some documents to master.
+ * 2) Add some documents to primary.
* 3) Wait until the secondary nodes are in state "SECONDARY".
* 4) Set slaveOk on secondary.
* 5) Take the fsync lock on a secondary. This will stop replication.
- * 6) Insert some more documents to master.
+ * 6) Insert some more documents to primary.
* 7) Expect to be able to read from the secondary; the count of documents should
* be equal to the number of documents added in step 2.
* 8) Release the fsync lock. This will resume replication.
@@ -31,42 +31,44 @@ var replTest = new ReplSetTest({name: 'testSet', nodes: 2, oplogSize: 5});
var nodes = replTest.startSet();
// This will wait for initiation
replTest.initiate();
-var master = replTest.getPrimary();
+var primary = replTest.getPrimary();
-var ret = master.getDB("admin").fsyncLock();
+var ret = primary.getDB("admin").fsyncLock();
if (!ret.ok) {
assert.commandFailedWithCode(ret, ErrorCodes.CommandNotSupported);
jsTestLog("Storage Engine does not support fsyncLock, so bailing");
return;
}
-master.getDB("admin").fsyncUnlock();
+primary.getDB("admin").fsyncUnlock();
var docNum = 100;
for (var i = 0; i < docNum; i++) {
- master.getDB("foo").bar.save({a: i});
+ primary.getDB("foo").bar.save({a: i});
}
-waitForAllMembers(master.getDB("foo"));
+waitForAllMembers(primary.getDB("foo"));
replTest.awaitReplication();
-// Calling getPrimary also populates '_slaves'.
-var slaves = replTest._slaves;
-slaves[0].setSlaveOk();
+// Calling getPrimary also populates '_secondaries'.
+var secondaries = replTest.getSecondaries();
+secondaries[0].setSlaveOk();
-assert.commandWorked(slaves[0].getDB("admin").runCommand({fsync: 1, lock: 1}));
+assert.commandWorked(secondaries[0].getDB("admin").runCommand({fsync: 1, lock: 1}));
var docNum = 1000;
for (var i = 0; i < docNum; i++) {
- master.getDB("foo").bar.save({a: i});
+ primary.getDB("foo").bar.save({a: i});
}
// 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.find().itcount();
-assert.eq(slave0count, 100, "Doc count in fsync lock wrong. Expected (=100), found " + slave0count);
-assert(slaves[0].getDB("admin").fsyncUnlock().ok);
+var secondary0count = secondaries[0].getDB("foo").bar.find().itcount();
+assert.eq(secondary0count,
+ 100,
+ "Doc count in fsync lock wrong. Expected (=100), found " + secondary0count);
+assert(secondaries[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.find().itcount() > 100;
+ return secondaries[0].getDB("foo").bar.find().itcount() > 100;
}, "count of documents stored on the secondary did not increase");
replTest.stopSet();
}());
diff --git a/jstests/replsets/get_replication_info_helper.js b/jstests/replsets/get_replication_info_helper.js
index 39355e2ceda..97d7f573d74 100644
--- a/jstests/replsets/get_replication_info_helper.js
+++ b/jstests/replsets/get_replication_info_helper.js
@@ -35,8 +35,8 @@ mongo();
assert(rawMongoProgramOutput().match("behind the primary"));
// get to a primaryless state
-for (i in replSet._slaves) {
- var secondary = replSet._slaves[i];
+for (i in replSet.getSecondaries()) {
+ var secondary = replSet.getSecondaries()[i];
secondary.getDB('admin').runCommand({replSetFreeze: 120});
}
assert.commandWorked(primary.getDB('admin').runCommand({replSetStepDown: 120, force: true}));
diff --git a/jstests/replsets/groupAndMapReduce.js b/jstests/replsets/groupAndMapReduce.js
index cb63de5cf6d..270436bf62c 100644
--- a/jstests/replsets/groupAndMapReduce.js
+++ b/jstests/replsets/groupAndMapReduce.js
@@ -18,35 +18,35 @@ doTest = function(signal) {
replTest.initiate();
// Call getPrimary to return a reference to the node that's been
- // elected master.
- var master = replTest.getPrimary();
+ // elected primary.
+ var primary = replTest.getPrimary();
// save some records
var len = 100;
for (var i = 0; i < len; ++i) {
- master.getDB("foo").foo.save({a: i});
+ primary.getDB("foo").foo.save({a: i});
}
- waitForAllMembers(master.getDB("foo"));
- // This method will check the oplogs of the master
- // and slaves in the set and wait until the change has replicated.
+ waitForAllMembers(primary.getDB("foo"));
+ // This method will check the oplogs of the primary
+ // and secondaries in the set and wait until the change has replicated.
replTest.awaitReplication();
- slaves = replTest._slaves;
- assert(slaves.length == 2, "Expected 2 slaves but length was " + slaves.length);
- slaves.forEach(function(slave) {
- // try to read from slave
- slave.slaveOk = true;
- var count = slave.getDB("foo").foo.find().itcount();
+ secondaries = replTest.getSecondaries();
+ assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
+ secondaries.forEach(function(secondary) {
+ // try to read from secondary
+ secondary.slaveOk = true;
+ var count = secondary.getDB("foo").foo.find().itcount();
printjson(count);
- assert.eq(len, count, "slave count wrong: " + slave);
+ assert.eq(len, count, "secondary count wrong: " + secondary);
print("Doing a findOne to verify we can get a row");
- var one = slave.getDB("foo").foo.findOne();
+ var one = secondary.getDB("foo").foo.findOne();
printjson(one);
print("Calling inline mr() with slaveOk=true, must succeed");
- slave.slaveOk = true;
+ secondary.slaveOk = true;
map = function() {
emit(this.a, 1);
};
@@ -57,28 +57,28 @@ doTest = function(signal) {
}
return sum;
};
- slave.getDB("foo").foo.mapReduce(map, reduce, {out: {"inline": 1}});
+ secondary.getDB("foo").foo.mapReduce(map, reduce, {out: {"inline": 1}});
print("Calling mr() to collection with slaveOk=true, must fail");
try {
- slave.getDB("foo").foo.mapReduce(map, reduce, "output");
- assert(false, "mapReduce() to collection succeeded on slave");
+ secondary.getDB("foo").foo.mapReduce(map, reduce, "output");
+ assert(false, "mapReduce() to collection succeeded on secondary");
} catch (e) {
print("Received exception: " + e);
}
print("Calling inline mr() with slaveOk=false, must fail");
- slave.slaveOk = false;
+ secondary.slaveOk = false;
try {
- slave.getDB("foo").foo.mapReduce(map, reduce, {out: {"inline": 1}});
- assert(false, "mapReduce() succeeded on slave with slaveOk=false");
+ secondary.getDB("foo").foo.mapReduce(map, reduce, {out: {"inline": 1}});
+ assert(false, "mapReduce() succeeded on secondary with slaveOk=false");
} catch (e) {
print("Received exception: " + e);
}
print("Calling mr() to collection with slaveOk=false, must fail");
try {
- slave.getDB("foo").foo.mapReduce(map, reduce, "output");
- assert(false, "mapReduce() to collection succeeded on slave with slaveOk=false");
+ secondary.getDB("foo").foo.mapReduce(map, reduce, "output");
+ assert(false, "mapReduce() to collection succeeded on secondary with slaveOk=false");
} catch (e) {
print("Received exception: " + e);
}
diff --git a/jstests/replsets/initial_sync1.js b/jstests/replsets/initial_sync1.js
index 764c8be8b80..27154eb37fc 100644
--- a/jstests/replsets/initial_sync1.js
+++ b/jstests/replsets/initial_sync1.js
@@ -34,13 +34,13 @@ var replTest =
var conns = replTest.startSet();
replTest.initiate();
-var master = replTest.getPrimary();
-var foo = master.getDB("foo");
-var admin = master.getDB("admin");
+var primary = replTest.getPrimary();
+var foo = primary.getDB("foo");
+var admin = primary.getDB("admin");
-var slave1 = replTest._slaves[0];
-var admin_s1 = slave1.getDB("admin");
-var local_s1 = slave1.getDB("local");
+var secondary1 = replTest.getSecondary();
+var admin_s1 = secondary1.getDB("admin");
+var local_s1 = secondary1.getDB("local");
print("2. Insert some data");
var bulk = foo.bar.initializeUnorderedBulkOp();
@@ -59,21 +59,22 @@ admin_s1.runCommand({replSetFreeze: 999999});
print("6. Bring up #3");
var hostname = getHostName();
-var slave2 = MongoRunner.runMongod(Object.merge({replSet: basename, oplogSize: 2}, x509_options2));
+var secondary2 =
+ MongoRunner.runMongod(Object.merge({replSet: basename, oplogSize: 2}, x509_options2));
-var local_s2 = slave2.getDB("local");
-var admin_s2 = slave2.getDB("admin");
+var local_s2 = secondary2.getDB("local");
+var admin_s2 = secondary2.getDB("admin");
var config = replTest.getReplSetConfig();
config.version = replTest.getReplSetConfigFromNode().version + 1;
-config.members.push({_id: 2, host: slave2.host});
+config.members.push({_id: 2, host: secondary2.host});
try {
admin.runCommand({replSetReconfig: config});
} catch (e) {
print(e);
}
-reconnect(slave1);
-reconnect(slave2);
+reconnect(secondary1);
+reconnect(secondary2);
replTest.waitForAllNewlyAddedRemovals();
print("Config 1: " + tojsononeline(config));
@@ -88,22 +89,22 @@ print("Config 3: " + tojsononeline(config3));
assert(config3);
assert.eq(config3.version, (config.version + 1));
-replTest.waitForState(slave2, [ReplSetTest.State.SECONDARY, ReplSetTest.State.RECOVERING]);
+replTest.waitForState(secondary2, [ReplSetTest.State.SECONDARY, ReplSetTest.State.RECOVERING]);
print("7. Kill the secondary in the middle of syncing");
-replTest.stop(slave1);
+replTest.stop(secondary1);
print("8. Eventually the new node should become a secondary");
print("if initial sync has started, this will cause it to fail and sleep for 5 minutes");
-replTest.waitForState(slave2, ReplSetTest.State.SECONDARY, 60 * 1000);
+replTest.waitForState(secondary2, ReplSetTest.State.SECONDARY, 60 * 1000);
print("9. Bring the secondary back up");
-replTest.start(slave1, {}, true);
-reconnect(slave1);
-replTest.waitForState(slave1, [ReplSetTest.State.PRIMARY, ReplSetTest.State.SECONDARY]);
+replTest.start(secondary1, {}, true);
+reconnect(secondary1);
+replTest.waitForState(secondary1, [ReplSetTest.State.PRIMARY, ReplSetTest.State.SECONDARY]);
print("10. Insert some stuff");
-master = replTest.getPrimary();
+primary = replTest.getPrimary();
bulk = foo.bar.initializeUnorderedBulkOp();
for (var i = 0; i < 100; i++) {
bulk.insert({date: new Date(), x: i, str: "all the talk on the market"});
@@ -113,5 +114,5 @@ assert.commandWorked(bulk.execute());
print("11. Everyone happy eventually");
replTest.awaitReplication();
-MongoRunner.stopMongod(slave2);
+MongoRunner.stopMongod(secondary2);
replTest.stopSet();
diff --git a/jstests/replsets/ismaster1.js b/jstests/replsets/ismaster1.js
index f87f24cd41a..ce19a9fd3c8 100644
--- a/jstests/replsets/ismaster1.js
+++ b/jstests/replsets/ismaster1.js
@@ -148,6 +148,7 @@ var agreeOnPrimaryAndSetVersion = function(setVersion) {
};
var primary = replTest.getPrimary();
+var secondaries = replTest.getSecondaries();
var expectedVersion = replTest.getReplSetConfigFromNode().version;
assert.soon(function() {
return agreeOnPrimaryAndSetVersion(expectedVersion);
@@ -180,7 +181,7 @@ runHelloCmdAndAliases({
});
runHelloCmdAndAliases({
- conn: replTest._slaves[0],
+ conn: secondaries[0],
name: "secondary",
goodValues: {
setName: "hello_and_aliases",
@@ -204,7 +205,7 @@ runHelloCmdAndAliases({
});
runHelloCmdAndAliases({
- conn: replTest._slaves[1],
+ conn: secondaries[1],
name: "delayed_secondary",
goodValues: {
setName: "hello_and_aliases",
@@ -222,7 +223,7 @@ runHelloCmdAndAliases({
});
runHelloCmdAndAliases({
- conn: replTest._slaves[2],
+ conn: secondaries[2],
name: "arbiter",
goodValues: {
setName: "hello_and_aliases",
@@ -266,6 +267,7 @@ try {
}
primary = replTest.getPrimary();
+secondaries = replTest.getSecondaries();
expectedVersion = config.version;
assert.soon(function() {
return agreeOnPrimaryAndSetVersion(expectedVersion);
@@ -297,7 +299,7 @@ runHelloCmdAndAliases({
});
runHelloCmdAndAliases({
- conn: replTest._slaves[0],
+ conn: secondaries[0],
name: "first_secondary",
goodValues: {
setName: "hello_and_aliases",
@@ -321,7 +323,7 @@ runHelloCmdAndAliases({
});
runHelloCmdAndAliases({
- conn: replTest._slaves[1],
+ conn: secondaries[1],
name: "very_delayed_secondary",
goodValues: {
setName: "hello_and_aliases",
@@ -340,7 +342,7 @@ runHelloCmdAndAliases({
});
runHelloCmdAndAliases({
- conn: replTest._slaves[2],
+ conn: secondaries[2],
name: "arbiter",
goodValues: {
setName: "hello_and_aliases",
diff --git a/jstests/replsets/maintenance2.js b/jstests/replsets/maintenance2.js
index 88561dc693e..2b904346945 100644
--- a/jstests/replsets/maintenance2.js
+++ b/jstests/replsets/maintenance2.js
@@ -16,35 +16,35 @@ var nodes = replTest.startSet();
replTest.initiate();
// Call getPrimary to return a reference to the node that's been
-// elected master.
-var master = replTest.getPrimary();
+// elected primary.
+var primary = replTest.getPrimary();
// save some records
var len = 100;
for (var i = 0; i < len; ++i) {
- master.getDB("foo").foo.save({a: i});
+ primary.getDB("foo").foo.save({a: i});
}
-// This method will check the oplogs of the master
-// and slaves in the set and wait until the change has replicated.
+// This method will check the oplogs of the primary
+// and secondaries in the set and wait until the change has replicated.
// replTest.awaitReplication();
-var slaves = replTest._slaves;
-assert.eq(2, slaves.length, "Expected 2 slaves but length was " + slaves.length);
+var secondaries = replTest.getSecondaries();
+assert.eq(2, secondaries.length, "Expected 2 secondaries but length was " + secondaries.length);
-slaves.forEach(function(slave) {
- // put slave into maintenance (recovery) mode
- assert.commandWorked(slave.getDB("foo").adminCommand({replSetMaintenance: 1}));
+secondaries.forEach(function(secondary) {
+ // put secondary into maintenance (recovery) mode
+ assert.commandWorked(secondary.getDB("foo").adminCommand({replSetMaintenance: 1}));
- var stats = slave.getDB("foo").adminCommand({replSetGetStatus: 1});
- assert.eq(stats.myState, 3, "Slave should be in recovering state.");
+ var stats = secondary.getDB("foo").adminCommand({replSetGetStatus: 1});
+ assert.eq(stats.myState, 3, "Secondary should be in recovering state.");
print("count should fail in recovering state...");
- slave.slaveOk = true;
- assert.commandFailed(slave.getDB("foo").runCommand({count: "foo"}));
+ secondary.slaveOk = true;
+ assert.commandFailed(secondary.getDB("foo").runCommand({count: "foo"}));
// unset maintenance mode when done
- assert.commandWorked(slave.getDB("foo").adminCommand({replSetMaintenance: 0}));
+ assert.commandWorked(secondary.getDB("foo").adminCommand({replSetMaintenance: 0}));
});
// Shut down the set and finish the test.
diff --git a/jstests/replsets/maxSyncSourceLagSecs.js b/jstests/replsets/maxSyncSourceLagSecs.js
index d4b47de9811..6630b5d3072 100644
--- a/jstests/replsets/maxSyncSourceLagSecs.js
+++ b/jstests/replsets/maxSyncSourceLagSecs.js
@@ -21,36 +21,37 @@ replTest.startSet();
replTest.initiate();
replTest.awaitNodesAgreeOnPrimary();
-var master = replTest.getPrimary();
-var slaves = replTest._slaves;
-syncFrom(slaves[0], master, replTest);
-syncFrom(slaves[1], master, replTest);
-master.getDB("foo").bar.save({a: 1});
+var primary = replTest.getPrimary();
+var secondaries = replTest.getSecondaries();
+syncFrom(secondaries[0], primary, replTest);
+syncFrom(secondaries[1], primary, replTest);
+primary.getDB("foo").bar.save({a: 1});
replTest.awaitReplication();
-jsTestLog("Setting sync target of slave 2 to slave 1");
-syncFrom(slaves[1], slaves[0], replTest);
+jsTestLog("Setting sync target of secondary 2 to secondary 1");
+syncFrom(secondaries[1], secondaries[0], replTest);
printjson(replTest.status());
// need to put at least maxSyncSourceLagSecs b/w first op and subsequent ops
// so that the shouldChangeSyncSource logic goes into effect
sleep(4000);
-jsTestLog("Lock slave 1 and add some docs. Force sync target for slave 2 to change to primary");
-assert.commandWorked(slaves[0].getDB("admin").runCommand({fsync: 1, lock: 1}));
+jsTestLog(
+ "Lock secondary 1 and add some docs. Force sync target for secondary 2 to change to primary");
+assert.commandWorked(secondaries[0].getDB("admin").runCommand({fsync: 1, lock: 1}));
assert.soon(function() {
- master.getDB("foo").bar.insert({a: 2});
- var res = slaves[1].getDB("admin").runCommand({"replSetGetStatus": 1});
- return res.syncSourceHost === master.name;
+ primary.getDB("foo").bar.insert({a: 2});
+ var res = secondaries[1].getDB("admin").runCommand({"replSetGetStatus": 1});
+ return res.syncSourceHost === primary.name;
}, "sync target not changed back to primary", 100 * 1000, 2 * 1000);
printjson(replTest.status());
assert.soon(function() {
- return (slaves[1].getDB("foo").bar.count({a: 1}) > 0 &&
- slaves[1].getDB("foo").bar.count({a: 2}) > 0);
-}, "slave should have caught up after syncing to primary.");
+ return (secondaries[1].getDB("foo").bar.count({a: 1}) > 0 &&
+ secondaries[1].getDB("foo").bar.count({a: 2}) > 0);
+}, "secondary should have caught up after syncing to primary.");
-assert.commandWorked(slaves[0].getDB("admin").fsyncUnlock());
+assert.commandWorked(secondaries[0].getDB("admin").fsyncUnlock());
replTest.stopSet();
}());
diff --git a/jstests/replsets/pipelineout.js b/jstests/replsets/pipelineout.js
index d58ebf947bb..90c6805b7a0 100644
--- a/jstests/replsets/pipelineout.js
+++ b/jstests/replsets/pipelineout.js
@@ -8,7 +8,7 @@ replTest.initiate(
{"_id": name, "members": [{"_id": 0, "host": nodes[0]}, {"_id": 1, "host": nodes[1]}]});
var primary = replTest.getPrimary().getDB(name);
-var secondary = replTest._slaves[0].getDB(name);
+var secondary = replTest.getSecondary().getDB(name);
// populate the collection
for (i = 0; i < 5; i++) {
diff --git a/jstests/replsets/read_committed.js b/jstests/replsets/read_committed.js
index 3792d242375..e50af290e35 100644
--- a/jstests/replsets/read_committed.js
+++ b/jstests/replsets/read_committed.js
@@ -70,7 +70,7 @@ replTest.initiate(config);
// Get connections and collection.
var primary = replTest.getPrimary();
-var secondary = replTest._slaves[0];
+var secondary = replTest.getSecondary();
var coll = primary.getDB(name)[name];
var secondaryColl = secondary.getDB(name)[name];
diff --git a/jstests/replsets/read_committed_after_rollback.js b/jstests/replsets/read_committed_after_rollback.js
index fa4c805f0c7..41bd1d29268 100644
--- a/jstests/replsets/read_committed_after_rollback.js
+++ b/jstests/replsets/read_committed_after_rollback.js
@@ -46,9 +46,7 @@ replTest.initiate(config);
// Get connections.
var oldPrimary = replTest.getPrimary();
-var newPrimary = replTest._slaves[0];
-var pureSecondary = replTest._slaves[1];
-var arbiters = [replTest.nodes[3], replTest.nodes[4]];
+var [newPrimary, pureSecondary, ...arbiters] = replTest.getSecondaries();
// This is the collection that all of the tests will use.
var collName = name + '.collection';
diff --git a/jstests/replsets/read_committed_lookup.js b/jstests/replsets/read_committed_lookup.js
index e1c15ce3ca8..ab3c8ed67a0 100644
--- a/jstests/replsets/read_committed_lookup.js
+++ b/jstests/replsets/read_committed_lookup.js
@@ -35,7 +35,7 @@ const config = {
rst.initiate(config);
-let shardSecondary = rst._slaves[0];
+let shardSecondary = rst.getSecondary();
testReadCommittedLookup(rst.getPrimary().getDB("test"), shardSecondary, rst);
diff --git a/jstests/replsets/read_committed_no_snapshots.js b/jstests/replsets/read_committed_no_snapshots.js
index 72f468e3c03..a0fe52cd565 100644
--- a/jstests/replsets/read_committed_no_snapshots.js
+++ b/jstests/replsets/read_committed_no_snapshots.js
@@ -36,9 +36,10 @@ replTest.initiateWithAnyNodeAsPrimary(
// Get connections and collection.
var primary = replTest.getPrimary();
-var healthySecondary = replTest._slaves[0];
+var secondaries = replTest.getSecondaries();
+var healthySecondary = secondaries[0];
healthySecondary.setSlaveOk();
-var noSnapshotSecondary = replTest._slaves[1];
+var noSnapshotSecondary = secondaries[1];
noSnapshotSecondary.setSlaveOk();
// Do a write, wait for it to replicate, and ensure it is visible.
diff --git a/jstests/replsets/read_committed_on_secondary.js b/jstests/replsets/read_committed_on_secondary.js
index 343fa797932..6629b162172 100644
--- a/jstests/replsets/read_committed_on_secondary.js
+++ b/jstests/replsets/read_committed_on_secondary.js
@@ -46,7 +46,7 @@ replTest.initiate(config);
// Get connections and collection.
var primary = replTest.getPrimary();
-var secondary = replTest._slaves[0];
+var secondary = replTest.getSecondary();
var secondaryId = replTest.getNodeId(secondary);
var dbPrimary = primary.getDB(name);
diff --git a/jstests/replsets/read_committed_with_catalog_changes.js b/jstests/replsets/read_committed_with_catalog_changes.js
index 35392018021..1afbaa40f10 100644
--- a/jstests/replsets/read_committed_with_catalog_changes.js
+++ b/jstests/replsets/read_committed_with_catalog_changes.js
@@ -224,7 +224,7 @@ replTest.initiate(config);
// Get connections.
var primary = replTest.getPrimary();
-var secondary = replTest._slaves[0];
+var secondary = replTest.getSecondary();
// This is the DB that all of the tests will use.
var mainDB = primary.getDB('mainDB');
diff --git a/jstests/replsets/refresh_sessions_rs.js b/jstests/replsets/refresh_sessions_rs.js
index 24d553c2df7..b7cddc460fd 100644
--- a/jstests/replsets/refresh_sessions_rs.js
+++ b/jstests/replsets/refresh_sessions_rs.js
@@ -17,8 +17,7 @@ replTest.initiate();
var primary = replTest.getPrimary();
replTest.awaitSecondaryNodes();
-var server2 = replTest._slaves[0];
-var server3 = replTest._slaves[1];
+var [server2, server3] = replTest.getSecondaries();
var db1 = primary.getDB(dbName);
var db2 = server2.getDB(dbName);
diff --git a/jstests/replsets/replset1.js b/jstests/replsets/replset1.js
index e78ab801565..8225422338d 100644
--- a/jstests/replsets/replset1.js
+++ b/jstests/replsets/replset1.js
@@ -26,23 +26,23 @@ var doTest = function(signal) {
replTest.initiate();
// Call getPrimary to return a reference to the node that's been
- // elected master.
- var master = replTest.getPrimary();
+ // 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(master.adminCommand({serverStatus: 1}));
+ 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(master.getDB("local").oplog.rs.count({op: 'n', o: {msg: 'new primary'}}), 0);
+ assert.gt(primary.getDB("local").oplog.rs.count({op: 'n', o: {msg: 'new primary'}}), 0);
- // Here's how you save something to master
- master.getDB("foo").foo.save({a: 1000});
+ // Here's how you save something to primary
+ primary.getDB("foo").foo.save({a: 1000});
- // This method will check the oplogs of the master
- // and slaves in the set and wait until the change has replicated.
+ // 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");
@@ -56,68 +56,68 @@ var doTest = function(signal) {
assert.eq(1000, temp.foo.findOne().a, "cppconn 1");
}
- // Here's how to stop the master node
- var master_id = replTest.getNodeId(master);
- replTest.stop(master_id);
+ // Here's how to stop the primary node
+ var primaryId = replTest.getNodeId(primary);
+ replTest.stop(primaryId);
- // Now let's see who the new master is:
- var new_master = replTest.getPrimary();
+ // Now let's see who the new primary is:
+ var newPrimary = replTest.getPrimary();
- // Is the new master the same as the old master?
- var new_master_id = replTest.getNodeId(new_master);
+ // Is the new primary the same as the old primary?
+ var newPrimaryId = replTest.getNodeId(newPrimary);
- assert(master_id != new_master_id, "Old master shouldn't be equal to new master.");
+ 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 master
- var bulk = new_master.getDB("bar").bar.initializeUnorderedBulkOp();
+ // 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 master node:
- var slave = replTest.restart(master_id);
+ // Here's how to restart the old primary node:
+ var secondary = replTest.restart(primaryId);
- // Now, let's make sure that the old master comes up as a slave
+ // Now, let's make sure that the old primary comes up as a secondary
assert.soon(function() {
- var res = slave.getDB("admin").runCommand({ismaster: 1});
+ var res = secondary.getDB("admin").runCommand({ismaster: 1});
printjson(res);
return res['ok'] == 1 && res['ismaster'] == false;
});
// And we need to make sure that the replset comes back up
assert.soon(function() {
- var res = new_master.getDB("admin").runCommand({replSetGetStatus: 1});
+ var res = newPrimary.getDB("admin").runCommand({replSetGetStatus: 1});
printjson(res);
return res.myState == 1;
});
- // And that both slave nodes have all the updates
- new_master = replTest.getPrimary();
- assert.eq(1000, new_master.getDB("bar").runCommand({count: "bar"}).n, "assumption 2");
+ // 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 slaves = replTest._slaves;
- assert(slaves.length == 2, "Expected 2 slaves but length was " + slaves.length);
- slaves.forEach(function(slave) {
- slave.setSlaveOk();
- var count = slave.getDB("bar").runCommand({count: "bar"});
+ var secondaries = replTest.getSecondaries();
+ assert(secondaries.length == 2, "Expected 2 secondaries but length was " + secondaries.length);
+ secondaries.forEach(function(secondary) {
+ secondary.setSlaveOk();
+ var count = secondary.getDB("bar").runCommand({count: "bar"});
printjson(count);
- assert.eq(1000, count.n, "slave count wrong: " + slave);
+ assert.eq(1000, count.n, "secondary count wrong: " + secondary);
});
// last error
- master = replTest.getPrimary();
- slaves = replTest._slaves;
+ primary = replTest.getPrimary();
+ secondaries = replTest.getSecondaries();
- var db = master.getDB("foo");
+ var db = primary.getDB("foo");
var t = db.foo;
- var ts = slaves.map(function(z) {
+ var ts = secondaries.map(function(z) {
z.setSlaveOk();
return z.getDB("foo").foo;
});
diff --git a/jstests/replsets/replset2.js b/jstests/replsets/replset2.js
index 5c3114a0893..3c9b9613eed 100644
--- a/jstests/replsets/replset2.js
+++ b/jstests/replsets/replset2.js
@@ -18,70 +18,70 @@ doTest = function(signal) {
var testDB = "repl-test";
// Call getPrimary to return a reference to the node that's been
- // elected master.
- var master = replTest.getPrimary();
+ // elected primary.
+ var primary = replTest.getPrimary();
// Wait for replication to a single node
- master.getDB(testDB).bar.insert({n: 1});
+ primary.getDB(testDB).bar.insert({n: 1});
// Wait for states to become PRI,SEC,SEC
- waitForAllMembers(master.getDB(testDB));
+ waitForAllMembers(primary.getDB(testDB));
- var slaves = replTest._slaves;
- slaves.forEach(function(slave) {
- slave.setSlaveOk();
+ var secondaries = replTest.getSecondaries();
+ secondaries.forEach(function(secondary) {
+ secondary.setSlaveOk();
});
// Test write concern with multiple inserts.
print("\n\nreplset2.js **** Try inserting a multiple records -- first insert ****");
- printjson(master.getDB("admin").runCommand("replSetGetStatus"));
+ printjson(primary.getDB("admin").runCommand("replSetGetStatus"));
- var bulk = master.getDB(testDB).foo.initializeUnorderedBulkOp();
+ var bulk = primary.getDB(testDB).foo.initializeUnorderedBulkOp();
bulk.insert({n: 1});
bulk.insert({n: 2});
bulk.insert({n: 3});
print("\nreplset2.js **** TEMP 1 ****");
- printjson(master.getDB("admin").runCommand("replSetGetStatus"));
+ printjson(primary.getDB("admin").runCommand("replSetGetStatus"));
assert.commandWorked(bulk.execute({w: 3, wtimeout: ReplSetTest.kDefaultTimeoutMS}));
print("replset2.js **** TEMP 1a ****");
- m1 = master.getDB(testDB).foo.findOne({n: 1});
+ m1 = primary.getDB(testDB).foo.findOne({n: 1});
printjson(m1);
- assert(m1['n'] == 1, "replset2.js Failed to save to master on multiple inserts");
+ assert(m1['n'] == 1, "replset2.js Failed to save to primary on multiple inserts");
print("replset2.js **** TEMP 1b ****");
- var s0 = slaves[0].getDB(testDB).foo.findOne({n: 1});
- assert(s0['n'] == 1, "replset2.js Failed to replicate to slave 0 on multiple inserts");
+ var s0 = secondaries[0].getDB(testDB).foo.findOne({n: 1});
+ assert(s0['n'] == 1, "replset2.js Failed to replicate to secondary 0 on multiple inserts");
- var s1 = slaves[1].getDB(testDB).foo.findOne({n: 1});
- assert(s1['n'] == 1, "replset2.js Failed to replicate to slave 1 on multiple inserts");
+ var s1 = secondaries[1].getDB(testDB).foo.findOne({n: 1});
+ assert(s1['n'] == 1, "replset2.js Failed to replicate to secondary 1 on multiple inserts");
// Test write concern with a simple insert
print("replset2.js **** Try inserting a single record ****");
- master.getDB(testDB).dropDatabase();
+ primary.getDB(testDB).dropDatabase();
var options = {writeConcern: {w: 3, wtimeout: ReplSetTest.kDefaultTimeoutMS}};
- assert.commandWorked(master.getDB(testDB).foo.insert({n: 1}, options));
+ assert.commandWorked(primary.getDB(testDB).foo.insert({n: 1}, options));
- m1 = master.getDB(testDB).foo.findOne({n: 1});
+ m1 = primary.getDB(testDB).foo.findOne({n: 1});
printjson(m1);
- assert(m1['n'] == 1, "replset2.js Failed to save to master");
+ assert(m1['n'] == 1, "replset2.js Failed to save to primary");
- s0 = slaves[0].getDB(testDB).foo.findOne({n: 1});
- assert(s0['n'] == 1, "replset2.js Failed to replicate to slave 0");
+ s0 = secondaries[0].getDB(testDB).foo.findOne({n: 1});
+ assert(s0['n'] == 1, "replset2.js Failed to replicate to secondary 0");
- s1 = slaves[1].getDB(testDB).foo.findOne({n: 1});
- assert(s1['n'] == 1, "replset2.js Failed to replicate to slave 1");
+ s1 = secondaries[1].getDB(testDB).foo.findOne({n: 1});
+ assert(s1['n'] == 1, "replset2.js Failed to replicate to secondary 1");
print("replset2.js **** Try inserting many records ****");
try {
var bigData = new Array(2000).toString();
- bulk = master.getDB(testDB).baz.initializeUnorderedBulkOp();
+ bulk = primary.getDB(testDB).baz.initializeUnorderedBulkOp();
for (var n = 0; n < 1000; n++) {
bulk.insert({n: n, data: bigData});
}
@@ -98,20 +98,20 @@ doTest = function(signal) {
print("replset2.js **** V2 ");
- verifyReplication("master", master.getDB(testDB).baz);
- verifyReplication("slave 0", slaves[0].getDB(testDB).baz);
- verifyReplication("slave 1", slaves[1].getDB(testDB).baz);
+ verifyReplication("primary", primary.getDB(testDB).baz);
+ verifyReplication("secondary 0", secondaries[0].getDB(testDB).baz);
+ verifyReplication("secondary 1", secondaries[1].getDB(testDB).baz);
} catch (e) {
var errstr = "ERROR: " + e;
errstr += "\nMaster oplog findOne:\n";
errstr +=
- tojson(master.getDB("local").oplog.rs.find().sort({"$natural": -1}).limit(1).next());
- errstr += "\nSlave 0 oplog findOne:\n";
- errstr +=
- tojson(slaves[0].getDB("local").oplog.rs.find().sort({"$natural": -1}).limit(1).next());
- errstr += "\nSlave 1 oplog findOne:\n";
- errstr +=
- tojson(slaves[1].getDB("local").oplog.rs.find().sort({"$natural": -1}).limit(1).next());
+ tojson(primary.getDB("local").oplog.rs.find().sort({"$natural": -1}).limit(1).next());
+ errstr += "\nSecondary 0 oplog findOne:\n";
+ errstr += tojson(
+ secondaries[0].getDB("local").oplog.rs.find().sort({"$natural": -1}).limit(1).next());
+ errstr += "\nSecondary 1 oplog findOne:\n";
+ errstr += tojson(
+ secondaries[1].getDB("local").oplog.rs.find().sort({"$natural": -1}).limit(1).next());
assert(false, errstr);
}
diff --git a/jstests/replsets/replset3.js b/jstests/replsets/replset3.js
index 8723c562601..f24f1b76bb2 100644
--- a/jstests/replsets/replset3.js
+++ b/jstests/replsets/replset3.js
@@ -14,58 +14,58 @@ var doTest = function(signal) {
// This will wait for initiation
replTest.initiate();
- // Get master node
- var master = replTest.getPrimary();
+ // Get primary node
+ var primary = replTest.getPrimary();
- // Write some data to master
+ // Write some data to primary
// NOTE: this test fails unless we write some data.
- master.getDB("foo").foo.insert({a: 1}, {writeConcern: {w: 3, wtimeout: 20000}});
+ primary.getDB("foo").foo.insert({a: 1}, {writeConcern: {w: 3, wtimeout: 20000}});
var phase = 1;
print(phase++);
- // Step down master.
- assert.commandWorked(master.getDB("admin").runCommand({replSetStepDown: 0, force: 1}));
+ // Step down primary.
+ assert.commandWorked(primary.getDB("admin").runCommand({replSetStepDown: 0, force: 1}));
print(phase++);
try {
- var new_master = replTest.getPrimary();
+ var newPrimary = replTest.getPrimary();
} catch (err) {
- throw ("Could not elect new master before timeout.");
+ throw ("Could not elect new primary before timeout.");
}
print(phase++);
- assert(master != new_master, "Old master shouldn't be equal to new master.");
+ assert(primary != newPrimary, "Old primary shouldn't be equal to new primary.");
print(phase++);
- // Make sure that slaves are still up
- var result = new_master.getDB("admin").runCommand({replSetGetStatus: 1});
- assert(result['ok'] == 1, "Could not verify that slaves were still up:" + result);
+ // Make sure that secondaries are still up
+ var result = newPrimary.getDB("admin").runCommand({replSetGetStatus: 1});
+ assert(result['ok'] == 1, "Could not verify that secondaries were still up:" + result);
print(phase++);
- var slaves = replTest._slaves;
+ var secondaries = replTest.getSecondaries();
assert.soon(function() {
try {
- var res = slaves[0].getDB("admin").runCommand({replSetGetStatus: 1});
+ var res = secondaries[0].getDB("admin").runCommand({replSetGetStatus: 1});
} catch (err) {
}
return res.myState == 2;
- }, "Slave 0 state not ready.");
+ }, "Secondary 0 state not ready.");
print(phase++);
assert.soon(function() {
try {
- var res = slaves[1].getDB("admin").runCommand({replSetGetStatus: 1});
+ var res = secondaries[1].getDB("admin").runCommand({replSetGetStatus: 1});
} catch (err) {
}
return res.myState == 2;
- }, "Slave 1 state not ready.");
+ }, "Secondary 1 state not ready.");
print("replset3.js SUCCESS");
diff --git a/jstests/replsets/replset4.js b/jstests/replsets/replset4.js
index 7cf49c2751a..310b5709ebf 100644
--- a/jstests/replsets/replset4.js
+++ b/jstests/replsets/replset4.js
@@ -1,30 +1,30 @@
doTest = function(signal) {
- // Test orphaned master steps down
+ // Test orphaned primary steps down
var replTest = new ReplSetTest({name: 'testSet', nodes: 3});
replTest.startSet();
replTest.initiate();
- var master = replTest.getPrimary();
+ var primary = replTest.getPrimary();
- // Kill both slaves, simulating a network partition
- var slaves = replTest._slaves;
- for (var i = 0; i < slaves.length; i++) {
- var slave_id = replTest.getNodeId(slaves[i]);
- replTest.stop(slave_id);
+ // Kill both secondaries, simulating a network partition
+ var secondaries = replTest.getSecondaries();
+ for (var i = 0; i < secondaries.length; i++) {
+ var secondary_id = replTest.getNodeId(secondaries[i]);
+ replTest.stop(secondary_id);
}
print("replset4.js 1");
assert.soon(function() {
try {
- var result = master.getDB("admin").runCommand({ismaster: 1});
+ var result = primary.getDB("admin").runCommand({ismaster: 1});
return (result['ok'] == 1 && result['ismaster'] == false);
} catch (e) {
print("replset4.js caught " + e);
return false;
}
- }, "Master fails to step down when orphaned.");
+ }, "Primary fails to step down when orphaned.");
print("replset4.js worked, stopping");
replTest.stopSet(signal);
diff --git a/jstests/replsets/replset5.js b/jstests/replsets/replset5.js
index 551f8e7ee94..5488d8a9cd0 100644
--- a/jstests/replsets/replset5.js
+++ b/jstests/replsets/replset5.js
@@ -23,17 +23,17 @@ config.members[2].priority = 0;
reconfig(replTest, config);
//
-var master = replTest.getPrimary();
+var primary = replTest.getPrimary();
replTest.awaitSecondaryNodes();
var testDB = "foo";
// Initial replication
-master.getDB("barDB").bar.save({a: 1});
+primary.getDB("barDB").bar.save({a: 1});
replTest.awaitReplication();
// These writes should be replicated immediately
var docNum = 5000;
-var bulk = master.getDB(testDB).foo.initializeUnorderedBulkOp();
+var bulk = primary.getDB(testDB).foo.initializeUnorderedBulkOp();
for (var n = 0; n < docNum; n++) {
bulk.insert({n: n});
}
@@ -54,30 +54,32 @@ if (wcError != null) {
return;
}
-var slaves = replTest._slaves;
-slaves[0].setSlaveOk();
-slaves[1].setSlaveOk();
+var secondaries = replTest.getSecondaries();
+secondaries[0].setSlaveOk();
+secondaries[1].setSlaveOk();
-var slave0count = slaves[0].getDB(testDB).foo.find().itcount();
-assert(slave0count == docNum, "Slave 0 has " + slave0count + " of " + docNum + " documents!");
+var secondary0Count = secondaries[0].getDB(testDB).foo.find().itcount();
+assert(secondary0Count == docNum,
+ "Slave 0 has " + secondary0Count + " of " + docNum + " documents!");
-var slave1count = slaves[1].getDB(testDB).foo.find().itcount();
-assert(slave1count == docNum, "Slave 1 has " + slave1count + " of " + docNum + " documents!");
+var secondary1Count = secondaries[1].getDB(testDB).foo.find().itcount();
+assert(secondary1Count == docNum,
+ "Slave 1 has " + secondary1Count + " of " + docNum + " documents!");
-var master1count = master.getDB(testDB).foo.find().itcount();
-assert(master1count == docNum, "Master has " + master1count + " of " + docNum + " documents!");
+var primary1Count = primary.getDB(testDB).foo.find().itcount();
+assert(primary1Count == docNum, "Master has " + primary1Count + " of " + docNum + " documents!");
print("replset5.js reconfigure with hidden=1");
-config = master.getDB("local").system.replset.findOne();
+config = primary.getDB("local").system.replset.findOne();
assert.eq(15, config.settings.heartbeatTimeoutSecs);
config.version++;
config.members[2].hidden = 1;
-master = reconfig(replTest, config);
+primary = reconfig(replTest, config);
-config = master.getSiblingDB("local").system.replset.findOne();
+config = primary.getSiblingDB("local").system.replset.findOne();
assert.eq(config.members[2].hidden, true);
replTest.stopSet();
diff --git a/jstests/replsets/replset6.js b/jstests/replsets/replset6.js
index 63e9509e2b7..40998d7f4f2 100644
--- a/jstests/replsets/replset6.js
+++ b/jstests/replsets/replset6.js
@@ -6,18 +6,18 @@ baseName = "jstests_replsets_replset6";
var rt = new ReplSetTest({name: "replset6tests", nodes: 2});
var nodes = rt.startSet();
rt.initiate();
-var m = rt.getPrimary();
+var p = rt.getPrimary();
rt.awaitSecondaryNodes();
-var slaves = rt._slaves;
-s = slaves[0];
+var secondaries = rt.getSecondaries();
+s = secondaries[0];
s.setSlaveOk();
-admin = m.getDB("admin");
+admin = p.getDB("admin");
debug = function(foo) {}; // print( foo ); }
// rename within db
-m.getDB(baseName).one.save({a: 1});
+p.getDB(baseName).one.save({a: 1});
assert.soon(function() {
v = s.getDB(baseName).one.findOne();
return v && 1 == v.a;
@@ -44,7 +44,7 @@ assert.eq(-1, s.getDB(baseName).getCollectionNames().indexOf("one"));
first = baseName + "_first";
second = baseName + "_second";
-m.getDB(first).one.save({a: 1});
+p.getDB(first).one.save({a: 1});
assert.soon(function() {
return s.getDB(first).one.findOne() && 1 == s.getDB(first).one.findOne().a;
});
diff --git a/jstests/replsets/replsetrestart1.js b/jstests/replsets/replsetrestart1.js
index e090a1ff959..952230a1581 100644
--- a/jstests/replsets/replsetrestart1.js
+++ b/jstests/replsets/replsetrestart1.js
@@ -38,15 +38,14 @@ replTest.initiate();
replTest.awaitSecondaryNodes();
// Call getPrimary to return a reference to the node that's been
-// elected master.
-var master = replTest.getPrimary();
-var config1 = master.getDB("local").system.replset.findOne();
+// elected primary.
+var primary = replTest.getPrimary();
+var config1 = primary.getDB("local").system.replset.findOne();
// Now we're going to shut down all nodes
-var mId = replTest.getNodeId(master);
-var s1 = replTest._slaves[0];
+var pId = replTest.getNodeId(primary);
+var [s1, s2] = replTest.getSecondaries();
var s1Id = replTest.getNodeId(s1);
-var s2 = replTest._slaves[1];
var s2Id = replTest.getNodeId(s2);
replTest.stop(s1Id);
@@ -54,17 +53,17 @@ replTest.stop(s2Id);
replTest.waitForState(s1, ReplSetTest.State.DOWN);
replTest.waitForState(s2, ReplSetTest.State.DOWN);
-replTest.stop(mId);
+replTest.stop(pId);
// Now let's restart these nodes
-replTest.restart(mId);
+replTest.restart(pId);
replTest.restart(s1Id);
replTest.restart(s2Id);
-// Make sure that a new master comes up
-master = replTest.getPrimary();
+// Make sure that a new primary comes up
+primary = replTest.getPrimary();
replTest.awaitSecondaryNodes();
-var config2 = master.getDB("local").system.replset.findOne();
+var config2 = primary.getDB("local").system.replset.findOne();
compare_configs(config1, config2);
replTest.stopSet();
}());
diff --git a/jstests/replsets/slavedelay1.js b/jstests/replsets/slavedelay1.js
index 0d3622bd7c7..61a43152288 100644
--- a/jstests/replsets/slavedelay1.js
+++ b/jstests/replsets/slavedelay1.js
@@ -15,44 +15,44 @@ doTest = function(signal) {
replTest.initiate(config);
- var master = replTest.getPrimary().getDB(name);
- var slaveConns = replTest._slaves;
- var slaves = [];
- for (var i in slaveConns) {
- var d = slaveConns[i].getDB(name);
- slaves.push(d);
+ var primary = replTest.getPrimary().getDB(name);
+ var secondaryConns = replTest.getSecondaries();
+ var secondaries = [];
+ for (var i in secondaryConns) {
+ var d = secondaryConns[i].getDB(name);
+ secondaries.push(d);
}
- waitForAllMembers(master);
+ waitForAllMembers(primary);
// insert a record
- assert.commandWorked(master.foo.insert({x: 1}, {writeConcern: {w: 2}}));
+ assert.commandWorked(primary.foo.insert({x: 1}, {writeConcern: {w: 2}}));
- var doc = master.foo.findOne();
+ var doc = primary.foo.findOne();
assert.eq(doc.x, 1);
- // make sure slave has it
- var doc = slaves[0].foo.findOne();
+ // make sure secondary has it
+ var doc = secondaries[0].foo.findOne();
assert.eq(doc.x, 1);
- // make sure delayed slave doesn't have it
+ // make sure delayed secondary doesn't have it
for (var i = 0; i < 8; i++) {
- assert.eq(slaves[1].foo.findOne(), null);
+ assert.eq(secondaries[1].foo.findOne(), null);
sleep(1000);
}
- // within 120 seconds delayed slave should have it
+ // within 120 seconds delayed secondary should have it
assert.soon(function() {
- var z = slaves[1].foo.findOne();
+ var z = secondaries[1].foo.findOne();
return z && z.x == 1;
- }, 'waiting for inserted document ' + tojson(doc) + ' on delayed slave', 120 * 1000);
+ }, 'waiting for inserted document ' + tojson(doc) + ' on delayed secondary', 120 * 1000);
/************* Part 2 *******************/
// how about if we add a new server? will it sync correctly?
conn = replTest.add();
- config = master.getSiblingDB("local").system.replset.findOne();
+ config = primary.getSiblingDB("local").system.replset.findOne();
printjson(config);
config.version++;
config.members.push({
@@ -62,10 +62,10 @@ doTest = function(signal) {
slaveDelay: 30
});
- master = reconfig(replTest, config);
- master = master.getSiblingDB(name);
+ primary = reconfig(replTest, config);
+ primary = primary.getSiblingDB(name);
- assert.commandWorked(master.foo.insert(
+ assert.commandWorked(primary.foo.insert(
{_id: 123, x: 'foo'}, {writeConcern: {w: 2, wtimeout: ReplSetTest.kDefaultTimeoutMS}}));
for (var i = 0; i < 8; i++) {
@@ -86,7 +86,7 @@ doTest = function(signal) {
config.members[3].slaveDelay = 15;
reconfig(replTest, config);
- master = replTest.getPrimary().getDB(name);
+ primary = replTest.getPrimary().getDB(name);
assert.soon(function() {
return conn.getDB("local").system.replset.findOne().version == config.version;
});
@@ -99,8 +99,8 @@ doTest = function(signal) {
});
print("testing insert");
- master.foo.insert({_id: 124, "x": "foo"});
- assert(master.foo.findOne({_id: 124}) != null);
+ primary.foo.insert({_id: 124, "x": "foo"});
+ assert(primary.foo.findOne({_id: 124}) != null);
for (var i = 0; i < 10; i++) {
assert.eq(conn.getDB(name).foo.findOne({_id: 124}), null);
diff --git a/jstests/replsets/slavedelay3.js b/jstests/replsets/slavedelay3.js
index bd9dc6dcb0d..9d09fa4486c 100644
--- a/jstests/replsets/slavedelay3.js
+++ b/jstests/replsets/slavedelay3.js
@@ -11,27 +11,27 @@ config.members[1].slaveDelay = 5;
config.members[2].priority = 0;
replTest.initiate(config);
-var master = replTest.getPrimary().getDB(name);
+var primary = replTest.getPrimary().getDB(name);
-var slaveConns = replTest._slaves;
-var slave = [];
-for (var i in slaveConns) {
- var d = slaveConns[i].getDB(name);
+var secondaryConns = replTest.getSecondaries();
+var secondaries = [];
+for (var i in secondaryConns) {
+ var d = secondaryConns[i].getDB(name);
d.getMongo().setSlaveOk();
- slave.push(d);
+ secondaries.push(d);
}
-waitForAllMembers(master);
+waitForAllMembers(primary);
nodes[0].disconnect(nodes[2]);
-master.foo.insert({x: 1});
+primary.foo.insert({x: 1});
syncFrom(nodes[1], nodes[0], replTest);
-// make sure the record still appears in the remote slave
+// make sure the record still appears in the remote secondary
assert.soon(function() {
- return slave[1].foo.findOne() != null;
+ return secondaries[1].foo.findOne() != null;
});
replTest.stopSet();
diff --git a/jstests/replsets/stepdown.js b/jstests/replsets/stepdown.js
index 278a61cb406..05f3275f11b 100644
--- a/jstests/replsets/stepdown.js
+++ b/jstests/replsets/stepdown.js
@@ -24,11 +24,11 @@ var replTest = new ReplSetTest({
var nodes = replTest.startSet();
replTest.initiate();
replTest.waitForState(nodes[0], ReplSetTest.State.PRIMARY);
-var master = replTest.getPrimary();
+var primary = replTest.getPrimary();
// do a write
print("\ndo a write");
-assert.commandWorked(master.getDB("foo").bar.insert({x: 1}));
+assert.commandWorked(primary.getDB("foo").bar.insert({x: 1}));
replTest.awaitReplication();
// In the event of any error, we have to unlock any nodes that we have fsyncLocked.
@@ -48,8 +48,8 @@ function unlockNodes(nodes) {
var lockedNodes = [];
try {
// lock secondaries
- jsTestLog('Locking nodes: ' + tojson(replTest._slaves));
- replTest._slaves.forEach(function(node) {
+ jsTestLog('Locking nodes: ' + tojson(replTest.getSecondaries()));
+ replTest.getSecondaries().forEach(function(node) {
jsTestLog('Locking node: ' + node);
jsTestLog(
'fsync lock ' + node + ' result: ' +
@@ -57,28 +57,28 @@ try {
lockedNodes.push(node);
});
- jsTestLog('Stepping down primary: ' + master);
+ jsTestLog('Stepping down primary: ' + primary);
for (var i = 0; i < 11; i++) {
// do another write
- assert.commandWorked(master.getDB("foo").bar.insert({x: i}));
+ assert.commandWorked(primary.getDB("foo").bar.insert({x: i}));
}
- let res = assert.commandWorked(master.adminCommand({replSetGetStatus: 1}));
+ let res = assert.commandWorked(primary.adminCommand({replSetGetStatus: 1}));
assert(res.electionCandidateMetrics,
() => "Response should have an 'electionCandidateMetrics' field: " + tojson(res));
- let intitialServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1}));
+ let intitialServerStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
- jsTestLog('Do stepdown of primary ' + master + ' that should not work');
+ jsTestLog('Do stepdown of primary ' + primary + ' that should not work');
// this should fail, so we don't need to try/catch
jsTestLog(
- 'Step down ' + master + ' expected error: ' +
- tojson(assert.commandFailed(master.getDB("admin").runCommand({replSetStepDown: 10}))));
+ 'Step down ' + primary + ' expected error: ' +
+ tojson(assert.commandFailed(primary.getDB("admin").runCommand({replSetStepDown: 10}))));
// Check that the 'total' and 'failed' fields of 'replSetStepDown' have been incremented in
// serverStatus and that they have not been incremented for 'replSetStepDownWithForce'.
- let newServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1}));
+ let newServerStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDown,
newServerStatus.metrics.commands.replSetStepDown,
"total",
@@ -103,14 +103,14 @@ try {
// this case gives us confidence that the behavior in the other cases is the same.
// Stepdown should fail because the stepdown period is negative
- jsTestLog('Do stepdown of primary ' + master + ' that should not work');
+ jsTestLog('Do stepdown of primary ' + primary + ' that should not work');
assert.commandFailedWithCode(
- master.getDB("admin").runCommand({replSetStepDown: -1, force: true}), ErrorCodes.BadValue);
+ primary.getDB("admin").runCommand({replSetStepDown: -1, force: true}), ErrorCodes.BadValue);
// Check that the 'total' and 'failed' fields of 'replSetStepDown' and
// 'replSetStepDownWithForce' have been incremented in serverStatus.
intitialServerStatus = newServerStatus;
- newServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1}));
+ newServerStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDown,
newServerStatus.metrics.commands.replSetStepDown,
"total",
@@ -128,14 +128,14 @@ try {
"failed",
1);
- jsTestLog('Do stepdown of primary ' + master + ' that should work');
+ jsTestLog('Do stepdown of primary ' + primary + ' that should work');
assert.commandWorked(
- master.adminCommand({replSetStepDown: ReplSetTest.kDefaultTimeoutMS, force: true}));
+ primary.adminCommand({replSetStepDown: ReplSetTest.kDefaultTimeoutMS, force: true}));
// Check that the 'total' fields of 'replSetStepDown' and 'replSetStepDownWithForce' have been
// incremented in serverStatus and that their 'failed' fields have not been incremented.
intitialServerStatus = newServerStatus;
- newServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1}));
+ newServerStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDown,
newServerStatus.metrics.commands.replSetStepDown,
"total",
@@ -153,15 +153,15 @@ try {
"failed",
0);
- jsTestLog('Checking isMaster on ' + master);
- var r2 = assert.commandWorked(master.getDB("admin").runCommand({ismaster: 1}));
- jsTestLog('Result from running isMaster on ' + master + ': ' + tojson(r2));
+ jsTestLog('Checking isMaster on ' + primary);
+ var r2 = assert.commandWorked(primary.getDB("admin").runCommand({ismaster: 1}));
+ jsTestLog('Result from running isMaster on ' + primary + ': ' + tojson(r2));
assert.eq(r2.ismaster, false);
assert.eq(r2.secondary, true);
// Check that the 'electionCandidateMetrics' section of the replSetGetStatus response has been
// cleared, since the node is no longer primary.
- res = assert.commandWorked(master.adminCommand({replSetGetStatus: 1}));
+ res = assert.commandWorked(primary.adminCommand({replSetGetStatus: 1}));
assert(!res.electionCandidateMetrics,
() => "Response should not have an 'electionCandidateMetrics' field: " + tojson(res));
@@ -171,15 +171,15 @@ try {
// that the behavior in the other cases is the same.
// Stepdown should fail because the node is no longer primary
- jsTestLog('Do stepdown of primary ' + master + ' that should not work');
- assert.commandFailedWithCode(master.getDB("admin").runCommand(
+ jsTestLog('Do stepdown of primary ' + primary + ' that should not work');
+ assert.commandFailedWithCode(primary.getDB("admin").runCommand(
{replSetStepDown: ReplSetTest.kDefaultTimeoutMS, force: true}),
ErrorCodes.NotWritablePrimary);
// Check that the 'total' and 'failed' fields of 'replSetStepDown' and
// 'replSetStepDownWithForce' have been incremented in serverStatus.
intitialServerStatus = newServerStatus;
- newServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1}));
+ newServerStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDown,
newServerStatus.metrics.commands.replSetStepDown,
"total",
@@ -203,8 +203,8 @@ try {
}
print("\nreset stepped down time");
-assert.commandWorked(master.getDB("admin").runCommand({replSetFreeze: 0}));
-master = replTest.getPrimary();
+assert.commandWorked(primary.getDB("admin").runCommand({replSetFreeze: 0}));
+primary = replTest.getPrimary();
print("\nawait");
replTest.awaitSecondaryNodes(90000);
@@ -214,44 +214,44 @@ replTest.awaitReplication();
// of this assert.soon
assert.soon(function() {
try {
- var result = master.getDB("admin").runCommand({isMaster: 1});
+ var result = primary.getDB("admin").runCommand({isMaster: 1});
return new RegExp(":" + replTest.nodes[0].port + "$").test(result.primary);
} catch (x) {
return false;
}
}, "wait for n0 to be primary", 60000);
-master = replTest.getPrimary();
-var firstMaster = master;
-print("\nmaster is now " + firstMaster);
+primary = replTest.getPrimary();
+var firstPrimary = primary;
+print("\nprimary is now " + firstPrimary);
-assert.adminCommandWorkedAllowingNetworkError(master, {replSetStepDown: 100, force: true});
+assert.adminCommandWorkedAllowingNetworkError(primary, {replSetStepDown: 100, force: true});
-print("\nget a master");
+print("\nget a primary");
replTest.getPrimary();
assert.soon(function() {
- var secondMaster = replTest.getPrimary();
- return firstMaster.host !== secondMaster.host;
-}, "making sure " + firstMaster.host + " isn't still master", 60000);
+ var secondPrimary = replTest.getPrimary();
+ return firstPrimary.host !== secondPrimary.host;
+}, "making sure " + firstPrimary.host + " isn't still primary", 60000);
// Add arbiter for shutdown tests
replTest.add();
print("\ncheck shutdown command");
-master = replTest.getPrimary();
-var slave = replTest._slaves[0];
+primary = replTest.getPrimary();
+var secondary = replTest.getSecondary();
try {
- slave.adminCommand({shutdown: 1});
+ secondary.adminCommand({shutdown: 1});
} catch (e) {
print(e);
}
-master = replTest.getPrimary();
+primary = replTest.getPrimary();
assert.soon(function() {
try {
- var result = master.getDB("admin").runCommand({replSetGetStatus: 1});
+ var result = primary.getDB("admin").runCommand({replSetGetStatus: 1});
for (var i in result.members) {
if (result.members[i].self) {
continue;
@@ -260,36 +260,36 @@ assert.soon(function() {
return result.members[i].health == 0;
}
} catch (e) {
- print("error getting status from master: " + e);
- master = replTest.getPrimary();
+ print("error getting status from primary: " + e);
+ primary = replTest.getPrimary();
return false;
}
-}, 'make sure master knows that slave is down before proceeding');
+}, 'make sure primary knows that secondary is down before proceeding');
-print("\nrunning shutdown without force on master: " + master);
+print("\nrunning shutdown without force on primary: " + primary);
-// this should fail because the master can't reach an up-to-date secondary (because the only
+// this should fail because the primary can't reach an up-to-date secondary (because the only
// secondary is down)
var now = new Date();
-assert.commandFailed(master.getDB("admin").runCommand({shutdown: 1, timeoutSecs: 3}));
+assert.commandFailed(primary.getDB("admin").runCommand({shutdown: 1, timeoutSecs: 3}));
// on windows, javascript and the server perceive time differently, to compensate here we use 2750ms
assert.gte((new Date()) - now, 2750);
print("\nsend shutdown command");
-var currentMaster = replTest.getPrimary();
+var currentPrimary = replTest.getPrimary();
try {
- printjson(currentMaster.getDB("admin").runCommand({shutdown: 1, force: true}));
+ printjson(currentPrimary.getDB("admin").runCommand({shutdown: 1, force: true}));
} catch (e) {
if (!isNetworkError(e)) {
throw e;
}
}
-print("checking " + currentMaster + " is actually shutting down");
+print("checking " + currentPrimary + " is actually shutting down");
assert.soon(function() {
try {
- currentMaster.findOne();
+ currentPrimary.findOne();
} catch (e) {
return true;
}
diff --git a/jstests/replsets/stepdown3.js b/jstests/replsets/stepdown3.js
index 5566e7379a1..53f8029908b 100644
--- a/jstests/replsets/stepdown3.js
+++ b/jstests/replsets/stepdown3.js
@@ -8,36 +8,36 @@
var replTest = new ReplSetTest({name: 'testSet', nodes: 2});
var nodes = replTest.startSet();
replTest.initiate();
-var master = replTest.getPrimary();
+var primary = replTest.getPrimary();
// do a write to allow stepping down of the primary;
// otherwise, the primary will refuse to step down
print("\ndo a write");
-master.getDB("test").foo.insert({x: 1});
+primary.getDB("test").foo.insert({x: 1});
replTest.awaitReplication();
// do another write, because the first one might be longer than 10 seconds ago
// on the secondary (due to starting up), and we need to be within 10 seconds
// to step down.
var options = {writeConcern: {w: 2, wtimeout: 30000}};
-assert.commandWorked(master.getDB("test").foo.insert({x: 2}, options));
+assert.commandWorked(primary.getDB("test").foo.insert({x: 2}, options));
// lock secondary, to pause replication
print("\nlock secondary");
-var locked = replTest._slaves[0];
+var locked = replTest.getSecondary();
printjson(locked.getDB("admin").runCommand({fsync: 1, lock: 1}));
// do a write
print("\ndo a write");
-master.getDB("test").foo.insert({x: 3});
+primary.getDB("test").foo.insert({x: 3});
// step down the primary asyncronously
print("stepdown");
var command =
"sleep(4000); assert.commandWorked(db.adminCommand( { replSetStepDown : 60, force : 1 } ));";
-var awaitShell = startParallelShell(command, master.port);
+var awaitShell = startParallelShell(command, primary.port);
print("getlasterror; should return an error");
-let result = master.getDB("test").runCommand({getLastError: 1, w: 2, wtimeout: 10 * 60 * 1000});
+let result = primary.getDB("test").runCommand({getLastError: 1, w: 2, wtimeout: 10 * 60 * 1000});
assert(ErrorCodes.isNotMasterError(result.code));
print("result of gle:");
printjson(result);
diff --git a/jstests/replsets/sync_passive.js b/jstests/replsets/sync_passive.js
index c97d320c96e..1c9f385e918 100644
--- a/jstests/replsets/sync_passive.js
+++ b/jstests/replsets/sync_passive.js
@@ -31,13 +31,13 @@ config.members[2].priority = 0;
replTest.initiate(config);
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
-var master = replTest.getPrimary().getDB("test");
-var server0 = master;
-var server1 = replTest._slaves[0];
+var primary = replTest.getPrimary().getDB("test");
+var server0 = primary;
+var server1 = replTest.getSecondary();
print("Initial sync");
for (var i = 0; i < 100; i++) {
- master.foo.insert({x: i});
+ primary.foo.insert({x: i});
}
replTest.awaitReplication();
@@ -46,10 +46,10 @@ replTest.stop(1);
print("add some data");
for (var i = 0; i < 1000; i++) {
- master.bar.insert({x: i});
+ primary.bar.insert({x: i});
}
-const liveSlaves = [replTest.nodes[2]];
-replTest.awaitReplication(null, null, liveSlaves);
+const liveSecondaries = [replTest.nodes[2]];
+replTest.awaitReplication(null, null, liveSecondaries);
print("stop #0");
replTest.stop(0);
@@ -58,15 +58,15 @@ print("restart #1");
replTest.restart(1);
print("check sync");
-replTest.awaitReplication(null, null, liveSlaves);
+replTest.awaitReplication(null, null, liveSecondaries);
print("add data");
reconnect(server1);
-master = replTest.getPrimary().getDB("test");
+primary = replTest.getPrimary().getDB("test");
for (var i = 0; i < 1000; i++) {
- master.bar.insert({x: i});
+ primary.bar.insert({x: i});
}
-replTest.awaitReplication(null, null, liveSlaves);
+replTest.awaitReplication(null, null, liveSecondaries);
print("kill #1");
replTest.stop(1);
@@ -76,7 +76,7 @@ replTest.restart(0);
reconnect(server0);
print("wait for sync");
-replTest.awaitReplication(null, null, liveSlaves);
+replTest.awaitReplication(null, null, liveSecondaries);
print("bring #1 back up, make sure everything's okay");
replTest.restart(1);
diff --git a/jstests/sharding/read_committed_lookup.js b/jstests/sharding/read_committed_lookup.js
index 512850785e8..95b5c2b25d8 100644
--- a/jstests/sharding/read_committed_lookup.js
+++ b/jstests/sharding/read_committed_lookup.js
@@ -33,7 +33,7 @@ const config = {
rst.initiate(config);
-let shardSecondary = rst._slaves[0];
+let shardSecondary = rst.getSecondary();
// Confirm read committed works on a cluster with a database that is not sharding enabled.
let st = new ShardingTest({
diff --git a/jstests/sharding/rename.js b/jstests/sharding/rename.js
index 1588d1eb3a6..ba82e88fa2b 100644
--- a/jstests/sharding/rename.js
+++ b/jstests/sharding/rename.js
@@ -75,12 +75,12 @@ jsTest.log("Testing write concern (2)");
// Kill any node. Don't care if it's a primary or secondary.
replTest.stop(0);
-// Call getPrimary() to populate replTest._slaves.
+// Call getPrimary() to populate replTest._secondaries.
replTest.getPrimary();
-let liveSlaves = replTest._slaves.filter(function(node) {
+let liveSecondaries = replTest.getSecondaries().filter(function(node) {
return node.host !== replTest.nodes[0].host;
});
-replTest.awaitSecondaryNodes(null, liveSlaves);
+replTest.awaitSecondaryNodes(null, liveSecondaries);
awaitRSClientHosts(s.s, replTest.getPrimary(), {ok: true, ismaster: true}, replTest.name);
assert.commandWorked(db.foo.insert({_id: 4}));
diff --git a/jstests/sharding/shard_insert_getlasterror_w2.js b/jstests/sharding/shard_insert_getlasterror_w2.js
index 6593c65f86a..7bde30b2dc5 100644
--- a/jstests/sharding/shard_insert_getlasterror_w2.js
+++ b/jstests/sharding/shard_insert_getlasterror_w2.js
@@ -64,8 +64,7 @@ assert.commandWorked(bulk.execute({w: replNodes, wtimeout: 30000}));
// Take down two nodes and make sure slaveOk reads still work
var primary = replSet1.getPrimary();
-var secondary1 = replSet1._slaves[0];
-var secondary2 = replSet1._slaves[1];
+var [secondary1, secondary2] = replSet1.getSecondaries();
replSet1.stop(secondary1);
replSet1.stop(secondary2);
replSet1.waitForState(primary, ReplSetTest.State.SECONDARY);
diff --git a/jstests/slow1/replsets_priority1.js b/jstests/slow1/replsets_priority1.js
index 66d3780770d..3ff6c058cc7 100644
--- a/jstests/slow1/replsets_priority1.js
+++ b/jstests/slow1/replsets_priority1.js
@@ -134,21 +134,22 @@ for (var i = 0; i < n; i++) {
assert.soon(() => isConfigCommitted(master));
assert.commandWorked(master.adminCommand({replSetReconfig: config}));
- jsTestLog("replsets_priority1.js wait for 2 slaves");
+ jsTestLog("replsets_priority1.js wait for 2 secondaries");
assert.soon(function() {
rs.getPrimary();
- return rs._slaves.length == 2;
- }, "2 slaves");
+ return rs.getSecondaries().length == 2;
+ }, "2 secondaries");
jsTestLog("replsets_priority1.js wait for new config version " + config.version);
assert.soon(function() {
var versions = [0, 0];
- rs._slaves[0].setSlaveOk();
- versions[0] = rs._slaves[0].getDB("local").system.replset.findOne().version;
- rs._slaves[1].setSlaveOk();
- versions[1] = rs._slaves[1].getDB("local").system.replset.findOne().version;
+ var secondaries = rs.getSecondaries();
+ secondaries[0].setSlaveOk();
+ versions[0] = secondaries[0].getDB("local").system.replset.findOne().version;
+ secondaries[1].setSlaveOk();
+ versions[1] = secondaries[1].getDB("local").system.replset.findOne().version;
return versions[0] == config.version && versions[1] == config.version;
});
@@ -177,10 +178,10 @@ for (var i = 0; i < n; i++) {
checkPrimaryIs(second);
// Wait for election oplog entry to be replicated, to avoid rollbacks later on.
- let liveSlaves = rs.nodes.filter(function(node) {
+ let liveSecondaries = rs.nodes.filter(function(node) {
return node.host !== max.host && node.host !== second.host;
});
- rs.awaitReplication(null, null, liveSlaves);
+ rs.awaitReplication(null, null, liveSecondaries);
jsTestLog("restart max " + max._id);
diff --git a/jstests/ssl/initial_sync1_x509.js b/jstests/ssl/initial_sync1_x509.js
index 10fa594927c..7a8621ef55b 100644
--- a/jstests/ssl/initial_sync1_x509.js
+++ b/jstests/ssl/initial_sync1_x509.js
@@ -36,12 +36,12 @@ function runInitialSyncTest() {
Object.extend(replTest.getReplSetConfig(),
{writeConcernMajorityJournalDefault: wcMajorityJournalDefault}));
- var master = replTest.getPrimary();
- var foo = master.getDB("foo");
- var admin = master.getDB("admin");
+ var primary = replTest.getPrimary();
+ var foo = primary.getDB("foo");
+ var admin = primary.getDB("admin");
- var slave1 = replTest._slaves[0];
- var admin_s1 = slave1.getDB("admin");
+ var secondary1 = replTest.getSecondary();
+ var admin_s1 = secondary1.getDB("admin");
print("2. Create a root user.");
admin.createUser({user: "root", pwd: "pass", roles: ["root"]});
@@ -60,7 +60,7 @@ function runInitialSyncTest() {
replTest.awaitReplication();
print("5. Insert some stuff");
- master = replTest.getPrimary();
+ primary = replTest.getPrimary();
bulk = foo.bar.initializeUnorderedBulkOp();
for (var i = 0; i < 100; i++) {
bulk.insert({date: new Date(), x: i, str: "all the talk on the market"});
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 250bc15aa82..2e85e28b406 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -129,13 +129,13 @@ var ReplSetTest = function(opts) {
* Invokes the 'hello' command via it's alias 'ismaster' on each individual node and returns the
* current primary, or false if none is found. Populates the following cached values:
* '_primary': the current primary
- * '_slaves': all nodes other than '_primary' (note this includes arbiters)
+ * '_secondaries': all nodes other than '_primary' (note this includes arbiters)
* '_liveNodes': all currently reachable nodes
*/
function _callHello() {
self._liveNodes = [];
self._primary = null;
- self._slaves = [];
+ self._secondaries = [];
var twoPrimaries = false;
let canAcceptWrites = false;
@@ -155,11 +155,11 @@ var ReplSetTest = function(opts) {
canAcceptWrites = n.ismaster;
}
} else {
- self._slaves.push(node);
+ self._secondaries.push(node);
}
} catch (err) {
print("ReplSetTest Could not call ismaster on node " + node + ": " + tojson(err));
- self._slaves.push(node);
+ self._secondaries.push(node);
}
});
if (twoPrimaries || !self._primary || !canAcceptWrites) {
@@ -175,7 +175,7 @@ var ReplSetTest = function(opts) {
*/
function _determineLiveSecondaries() {
_callHello();
- return self._slaves.filter(function(n) {
+ return self._secondaries.filter(function(n) {
return self._liveNodes.indexOf(n) !== -1;
});
}
@@ -690,7 +690,7 @@ var ReplSetTest = function(opts) {
// Reload who the current secondaries are
self.getPrimary(timeout);
- var secondariesToCheck = secondaries || self._slaves;
+ var secondariesToCheck = secondaries || self._secondaries;
var len = secondariesToCheck.length;
var ready = true;
@@ -1909,7 +1909,7 @@ var ReplSetTest = function(opts) {
// on all secondary nodes or just 'secondaries', if specified. The timeout will reset if any of
// the secondaries makes progress.
this.awaitReplication = function(timeout, secondaryOpTimeType, secondaries, retryIntervalMS) {
- if (secondaries !== undefined && secondaries !== self._slaves) {
+ if (secondaries !== undefined && secondaries !== self._secondaries) {
print("ReplSetTest awaitReplication: going to check only " +
secondaries.map(s => s.host));
}
@@ -1955,7 +1955,7 @@ var ReplSetTest = function(opts) {
", is " + tojson(primaryLatestOpTime));
let nodesCaughtUp = false;
- let secondariesToCheck = secondaries || self._slaves;
+ let secondariesToCheck = secondaries || self._secondaries;
let nodeProgress = Array(secondariesToCheck.length);
const Progress = Object.freeze({
@@ -2249,7 +2249,7 @@ var ReplSetTest = function(opts) {
this.getHashes = function(dbName, secondaries) {
assert.neq(dbName, 'local', 'Cannot run getHashes() on the "local" database');
- // _determineLiveSecondaries() repopulates both 'self._slaves' and 'self._primary'. If
+ // _determineLiveSecondaries() repopulates both 'self._secondaries' and 'self._primary'. If
// we're passed an explicit set of secondaries we don't want to do that.
secondaries = secondaries || _determineLiveSecondaries();
@@ -2377,7 +2377,7 @@ var ReplSetTest = function(opts) {
// We don't expect the local database to match because some of its
// collections are not replicated.
dbBlacklist.push('local');
- secondaries = secondaries || rst._slaves;
+ secondaries = secondaries || rst._secondaries;
var success = true;
var hasDumpedOplog = false;
@@ -2641,7 +2641,7 @@ var ReplSetTest = function(opts) {
* is exhausted on any node being checked.
*/
function checkOplogs(rst, secondaries, msgPrefix = 'checkOplogs') {
- secondaries = secondaries || rst._slaves;
+ secondaries = secondaries || rst._secondaries;
const kCappedPositionLostSentinel = Object.create(null);
const OplogReader = function(mongo) {
this._safelyPerformCursorOperation = function(name, operation, onCappedPositionLost) {