Skip to content

Commit 938ffcc

Browse files
committed
Added test for correctly returning error on write in replicasets to more than the number off servers available
1 parent 44d04bc commit 938ffcc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/replicaset/insert_test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,40 @@ module.exports = testCase({
101101
});
102102
});
103103
},
104+
105+
shouldCorrectlyWaitForReplicationToServersOnInserts : function(test) {
106+
// debug("=========================================== shouldWorkCorrectlyWithInserts")
107+
// Replica configuration
108+
var replSet = new ReplSetServers( [
109+
new Server( RS.host, RS.ports[1], { auto_reconnect: true } ),
110+
new Server( RS.host, RS.ports[0], { auto_reconnect: true } ),
111+
new Server( RS.host, RS.ports[2], { auto_reconnect: true } )
112+
],
113+
{rs_name:RS.name}
114+
);
115+
116+
// Insert some data
117+
var db = new Db('integration_test_', replSet);
118+
db.open(function(err, p_db) {
119+
// Check if we got an error
120+
if(err != null) debug("shouldCorrectlyWaitForReplicationToServersOnInserts :: " + inspect(err));
121+
122+
// Drop collection on replicaset
123+
p_db.dropCollection('testsets', function(err, r) {
124+
if(err != null) debug("shouldCorrectlyWaitForReplicationToServersOnInserts :: " + inspect(err));
125+
// Recreate collection on replicaset
126+
p_db.createCollection('testsets', function(err, collection) {
127+
if(err != null) debug("shouldCorrectlyWaitForReplicationToServersOnInserts :: " + inspect(err));
128+
// Insert a dummy document
129+
collection.insert({a:20}, {safe: {w:7, wtimeout: 10000}}, function(err, r) {
130+
test.equal('timeout', err.err);
131+
test.equal(true, err.wtimeout);
132+
test.done();
133+
});
134+
});
135+
});
136+
});
137+
},
104138

105139
shouldCorrectlyExecuteSafeFindAndModify : function(test) {
106140
// Replica configuration

0 commit comments

Comments
 (0)