summaryrefslogtreecommitdiff
path: root/jstests/replsets/initial_sync3.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/initial_sync3.js')
-rw-r--r--jstests/replsets/initial_sync3.js55
1 files changed, 24 insertions, 31 deletions
diff --git a/jstests/replsets/initial_sync3.js b/jstests/replsets/initial_sync3.js
index 7f2af94..ef45581 100644
--- a/jstests/replsets/initial_sync3.js
+++ b/jstests/replsets/initial_sync3.js
@@ -1,11 +1,6 @@
/* test initial sync options
*
- * {state : 1}
- * {state : 2}
- * {name : host+":"+port}
- * {_id : 2}
- * {optime : now}
- * {optime : 1970}
+ * Make sure member can't sync from a member with a different buildIndexes setting.
*/
load("jstests/replsets/rslib.js");
@@ -14,46 +9,44 @@ var host = getHostName();
var port = allocatePorts(7);
print("Start set with three nodes");
-var replTest = new ReplSetTest( {name: name, nodes: 7} );
+var replTest = new ReplSetTest( {name: name, nodes: 3} );
var nodes = replTest.startSet();
replTest.initiate({
_id : name,
members : [
- {_id:0, host : host+":"+port[0]},
- {_id:1, host : host+":"+port[1], initialSync : {state : 1}},
- {_id:2, host : host+":"+port[2], initialSync : {state : 2}},
- {_id:3, host : host+":"+port[3], initialSync : {name : host+":"+port[2]}},
- {_id:4, host : host+":"+port[4], initialSync : {_id : 2}},
- {_id:5, host : host+":"+port[5], initialSync : {optime : new Date()}},
- {_id:6, host : host+":"+port[6], initialSync : {optime : new Date(0)}}
+ {_id:0, host : host+":"+port[0]},
+ {_id:1, host : host+":"+port[1]},
+ {_id:2, host : host+":"+port[2], priority : 0, buildIndexes : false},
]});
var master = replTest.getMaster();
print("Initial sync");
master.getDB("foo").bar.baz.insert({x:1});
+replTest.awaitReplication();
-print("Make sure everyone's secondary");
-wait(function() {
- var status = master.getDB("admin").runCommand({replSetGetStatus:1});
- occasionally(function() {
- printjson(status);
- });
+replTest.stop(0);
+replTest.stop(1);
- if (!status.members) {
- return false;
- }
+print("restart 1, clearing its data directory so it has to resync");
+replTest.start(1);
- for (i=0; i<7; i++) {
- if (status.members[i].state != 1 && status.members[i].state != 2) {
- return false;
- }
- }
- return true;
+print("make sure 1 does not become a secondary (because it cannot clone from 2)");
+sleep(10000);
+reconnect(nodes[1]);
+var result = nodes[1].getDB("admin").runCommand({isMaster : 1});
+assert(!result.ismaster, tojson(result));
+assert(!result.secondary, tojson(result));
- });
+print("bring 0 back up");
+replTest.restart(0);
-replTest.awaitReplication();
+print("now 1 should be able to initial sync");
+assert.soon(function() {
+ var result = nodes[1].getDB("admin").runCommand({isMaster : 1});
+ printjson(result);
+ return result.secondary;
+});
replTest.stopSet();