Skip to content

Commit

Permalink
SERVER-9005 change test to not depend on replication speed
Browse files Browse the repository at this point in the history
  • Loading branch information
monkey101 committed Jun 26, 2013
1 parent becf20f commit c82f38b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions jstests/replsets/get_last_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ replTest.initiate();
var master = replTest.getMaster();
var mdb = master.getDB("test");
mdb.foo.insert({ _id: "1" });
replTest.awaitReplication();

var gle = master.getDB("test").runCommand({getLastError : 1, j : true, wtimeout : 60000});

print('Trying j=true, 60000ms timeout');
printjson(gle);
assert.eq(gle.err, null);
Expand All @@ -26,26 +26,29 @@ assert.eq(gle.wtime, null);
assert.eq(gle.waited, null);
assert.eq(gle.wtimeout, null);

gle = mdb.getLastErrorObj(2, 100);
print('Trying w=2, 100ms timeout.');
// Await replication to ensure this will succeed
replTest.awaitReplication();
gle = mdb.getLastErrorObj(2, 5);
print('Trying w=2, 5ms timeout.');
printjson(gle);
assert.eq(gle.err, null);
assert.eq(gle.writtenTo.length, 2);
assert.gte(gle.wtime, 0);
assert.eq(gle.waited, null);
assert.eq(gle.wtimeout, null);

gle = mdb.getLastErrorObj(3, 100);
print('Trying w=3, 100ms timeout. Should timeout.');
// only two members in the set, this must fail fast
gle = mdb.getLastErrorObj(3, 5);
print('Trying w=3, 5ms timeout. Should timeout.');
printjson(gle);
assert.eq(gle.err, "timeout");
assert.eq(gle.writtenTo.length, 2);
assert.eq(gle.wtime, null);
assert.gte(gle.waited, 100);
assert.gte(gle.waited, 5);
assert.eq(gle.wtimeout, true);

gle = mdb.getLastErrorObj("majority", 100);
print('Trying w=majority, 100ms timeout.');
gle = mdb.getLastErrorObj("majority", 5);
print('Trying w=majority, 5ms timeout.');
printjson(gle);
assert.eq(gle.err, null);
assert.eq(gle.writtenTo.length, 2);
Expand Down

0 comments on commit c82f38b

Please sign in to comment.