From 3198769ad5591deed329b0930515455f4ef0f22f Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Mon, 8 Nov 2010 18:04:15 -0500 Subject: add rs lib for common test funcs, fix test --- jstests/replsets/rslib.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 jstests/replsets/rslib.js (limited to 'jstests/replsets/rslib.js') diff --git a/jstests/replsets/rslib.js b/jstests/replsets/rslib.js new file mode 100644 index 00000000000..a849abc7b7a --- /dev/null +++ b/jstests/replsets/rslib.js @@ -0,0 +1,33 @@ + +var w = 0; +var wait = function(f) { + w++; + var n = 0; + while (!f()) { + if( n % 4 == 0 ) + print("waiting " + w); + if (++n == 4) { + print("" + f); + } + assert(n < 200, 'tried 200 times, giving up'); + sleep(1000); + } +} + +var reconnect = function(a) { + wait(function() { + try { + // make this work with either dbs or connections + if (typeof(a.getDB) == "function") { + a.getDB("foo").bar.stats(); + } + else { + a.bar.stats(); + } + return true; + } catch(e) { + print(e); + return false; + } + }); +}; -- cgit v1.2.1