summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/replsets/tags2.js108
-rw-r--r--jstests/replsets/tags_with_reconfig.js105
2 files changed, 101 insertions, 112 deletions
diff --git a/jstests/replsets/tags2.js b/jstests/replsets/tags2.js
index 33e8cdffbad..ff0e81fda97 100644
--- a/jstests/replsets/tags2.js
+++ b/jstests/replsets/tags2.js
@@ -1,59 +1,53 @@
// Change a write concern mode from 2 to 3 servers
-(function() {
- "use strict";
-
- var host = getHostName();
- var replTest = new ReplSetTest({nodes: 4});
- var nodes = replTest.startSet();
- var ports = replTest.ports;
- var conf = {
- _id: "rstag",
- version: 1,
- members: [
- {_id: 0, host: host + ":" + ports[0], tags: {"backup": "A"}},
- {_id: 1, host: host + ":" + ports[1], tags: {"backup": "B"}},
- {_id: 2, host: host + ":" + ports[2], tags: {"backup": "C"}},
- {_id: 3, host: host + ":" + ports[3], tags: {"backup": "D"}, arbiterOnly: true}
- ],
- settings: {getLastErrorModes: {backedUp: {backup: 2}}}
- };
-
- print("arbiters can't have tags");
- var result = nodes[0].getDB("admin").runCommand({replSetInitiate: conf});
- printjson(result);
- assert.eq(result.ok, 0);
-
- conf.members.pop();
- replTest.stop(3);
- replTest.remove(3);
- replTest.initiate(conf);
-
- replTest.awaitReplication();
-
- var master = replTest.getPrimary();
- var db = master.getDB("test");
- var wtimeout = 60 * 1000 * 5;
-
- assert.writeOK(db.foo.insert({x: 1}, {writeConcern: {w: 'backedUp', wtimeout: wtimeout}}));
-
- conf.version = 2;
- conf.settings.getLastErrorModes.backedUp.backup = 3;
- master.getDB("admin").runCommand({replSetReconfig: conf});
- replTest.awaitReplication();
-
- master = replTest.getPrimary();
- var db = master.getDB("test");
- assert.writeOK(db.foo.insert({x: 2}, {writeConcern: {w: 'backedUp', wtimeout: wtimeout}}));
-
- conf.version = 3;
- conf.members[0].priorty = 3;
- conf.members[2].priorty = 0;
- master.getDB("admin").runCommand({replSetReconfig: conf});
-
- master = replTest.getPrimary();
- var db = master.getDB("test");
- assert.writeOK(db.foo.insert({x: 3}, {writeConcern: {w: 'backedUp', wtimeout: wtimeout}}));
-
- replTest.stopSet();
-}()); \ No newline at end of file
+var host = getHostName();
+var replTest = new ReplSetTest({name: "rstag", nodes: 4});
+var nodes = replTest.startSet();
+var ports = replTest.ports;
+var conf = {
+ _id: "rstag",
+ version: 1,
+ members: [
+ {_id: 0, host: host + ":" + ports[0], tags: {"backup": "A"}},
+ {_id: 1, host: host + ":" + ports[1], tags: {"backup": "B"}},
+ {_id: 2, host: host + ":" + ports[2], tags: {"backup": "C"}},
+ {_id: 3, host: host + ":" + ports[3], tags: {"backup": "D"}, arbiterOnly: true}
+ ],
+ settings: {getLastErrorModes: {backedUp: {backup: 2}}}
+};
+
+print("arbiters can't have tags");
+var result = nodes[0].getDB("admin").runCommand({replSetInitiate: conf});
+printjson(result);
+assert.eq(result.ok, 0);
+
+conf.members.pop();
+replTest.stop(3);
+replTest.remove(3);
+replTest.initiate(conf);
+
+replTest.awaitReplication();
+
+master = replTest.getPrimary();
+var db = master.getDB("test");
+assert.writeOK(db.foo.insert({x: 1}, {writeConcern: {w: 'backedUp', wtimeout: 20000}}));
+
+conf.version = 2;
+conf.settings.getLastErrorModes.backedUp.backup = 3;
+master.getDB("admin").runCommand({replSetReconfig: conf});
+replTest.awaitReplication();
+
+master = replTest.getPrimary();
+var db = master.getDB("test");
+assert.writeOK(db.foo.insert({x: 2}, {writeConcern: {w: 'backedUp', wtimeout: 20000}}));
+
+conf.version = 3;
+conf.members[0].priorty = 3;
+conf.members[2].priorty = 0;
+master.getDB("admin").runCommand({replSetReconfig: conf});
+
+master = replTest.getPrimary();
+var db = master.getDB("test");
+assert.writeOK(db.foo.insert({x: 3}, {writeConcern: {w: 'backedUp', wtimeout: 20000}}));
+
+replTest.stopSet();
diff --git a/jstests/replsets/tags_with_reconfig.js b/jstests/replsets/tags_with_reconfig.js
index 53a22ac0889..512a55fe771 100644
--- a/jstests/replsets/tags_with_reconfig.js
+++ b/jstests/replsets/tags_with_reconfig.js
@@ -3,72 +3,67 @@
// time. This would cause us to update stale items in the cache when secondaries
// reported their progress to a primary.
-(function() {
- "use strict";
+// Start a replica set with 3 nodes
+var host = getHostName();
+var replTest = new ReplSetTest({name: "tags_with_reconfig", nodes: 3});
+var nodes = replTest.startSet();
+var ports = replTest.ports;
- // Start a replica set with 3 nodes
- var host = getHostName();
- var replTest = new ReplSetTest({nodes: 3});
- var nodes = replTest.startSet();
- var ports = replTest.ports;
-
- // Set tags and getLastErrorModes
- var conf = {
- _id: "tags_with_reconfig",
- version: 1,
- members: [
- {_id: 0, host: host + ":" + ports[0], tags: {"dc": "bbb"}},
- {_id: 1, host: host + ":" + ports[1], tags: {"dc": "bbb"}},
- {_id: 2, host: host + ":" + ports[2], tags: {"dc": "ccc"}}
- ],
- settings: {
- getLastErrorModes: {
- anydc: {dc: 1},
- alldc: {dc: 2},
- }
+// Set tags and getLastErrorModes
+var conf = {
+ _id: "tags_with_reconfig",
+ version: 1,
+ members: [
+ {_id: 0, host: host + ":" + ports[0], tags: {"dc": "bbb"}},
+ {_id: 1, host: host + ":" + ports[1], tags: {"dc": "bbb"}},
+ {_id: 2, host: host + ":" + ports[2], tags: {"dc": "ccc"}}
+ ],
+ settings: {
+ getLastErrorModes: {
+ anydc: {dc: 1},
+ alldc: {dc: 2},
}
- };
+ }
+};
- replTest.initiate(conf);
- replTest.awaitReplication();
+replTest.initiate(conf);
+replTest.awaitReplication();
- var wtimeout = 60 * 1000 * 5;
- var master = replTest.getPrimary();
- var db = master.getDB("test");
+master = replTest.getPrimary();
+var db = master.getDB("test");
- // Insert a document with write concern : anydc
- assert.writeOK(db.foo.insert({x: 1}, {writeConcern: {w: 'anydc', wtimeout: wtimeout}}));
+// Insert a document with write concern : anydc
+assert.writeOK(db.foo.insert({x: 1}, {writeConcern: {w: 'anydc', wtimeout: 20000}}));
- // Insert a document with write concern : alldc
- assert.writeOK(db.foo.insert({x: 2}, {writeConcern: {w: 'alldc', wtimeout: wtimeout}}));
+// Insert a document with write concern : alldc
+assert.writeOK(db.foo.insert({x: 2}, {writeConcern: {w: 'alldc', wtimeout: 20000}}));
- // Add a new tag to the replica set
- var config = master.getDB("local").system.replset.findOne();
- printjson(config);
- var modes = config.settings.getLastErrorModes;
- config.version++;
- config.members[0].tags.newtag = "newtag";
+// Add a new tag to the replica set
+var config = master.getDB("local").system.replset.findOne();
+printjson(config);
+var modes = config.settings.getLastErrorModes;
+config.version++;
+config.members[0].tags.newtag = "newtag";
- try {
- master.getDB("admin").runCommand({replSetReconfig: config});
- } catch (e) {
- print(e);
- }
+try {
+ master.getDB("admin").runCommand({replSetReconfig: config});
+} catch (e) {
+ print(e);
+}
- replTest.awaitReplication();
+replTest.awaitReplication();
- // Print the new config for replica set
- var config = master.getDB("local").system.replset.findOne();
- printjson(config);
+// Print the new config for replica set
+var config = master.getDB("local").system.replset.findOne();
+printjson(config);
- master = replTest.getPrimary();
- var db = master.getDB("test");
+master = replTest.getPrimary();
+var db = master.getDB("test");
- // Insert a document with write concern : anydc
- assert.writeOK(db.foo.insert({x: 3}, {writeConcern: {w: 'anydc', wtimeout: wtimeout}}));
+// Insert a document with write concern : anydc
+assert.writeOK(db.foo.insert({x: 3}, {writeConcern: {w: 'anydc', wtimeout: 20000}}));
- // Insert a document with write concern : alldc
- assert.writeOK(db.foo.insert({x: 4}, {writeConcern: {w: 'alldc', wtimeout: wtimeout}}));
+// Insert a document with write concern : alldc
+assert.writeOK(db.foo.insert({x: 4}, {writeConcern: {w: 'alldc', wtimeout: 20000}}));
- replTest.stopSet();
-}()); \ No newline at end of file
+replTest.stopSet();