diff options
author | Kristina Chodorow <kristina@10gen.com> | 2010-11-08 18:04:15 -0500 |
---|---|---|
committer | Kristina Chodorow <kristina@10gen.com> | 2010-11-08 18:04:15 -0500 |
commit | 3198769ad5591deed329b0930515455f4ef0f22f (patch) | |
tree | 04ab22ba9372deedfc093f064f1aa0ca56819e50 /jstests/replsets/rslib.js | |
parent | cee846b21f68568a0fc26fa8f5b5a8b18fd8ea4a (diff) | |
download | mongo-3198769ad5591deed329b0930515455f4ef0f22f.tar.gz |
add rs lib for common test funcs, fix test
Diffstat (limited to 'jstests/replsets/rslib.js')
-rw-r--r-- | jstests/replsets/rslib.js | 33 |
1 files changed, 33 insertions, 0 deletions
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; + } + }); +}; |