summaryrefslogtreecommitdiff
path: root/jstests/rs/test_framework.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-08-11 12:38:57 +0200
committerAntonin Kral <a.kral@bobek.cz>2010-08-11 12:38:57 +0200
commit7645618fd3914cb8a20561625913c20d49504a49 (patch)
tree8370f846f58f6d71165b7a0e2eda04648584ec76 /jstests/rs/test_framework.js
parent68c73c3c7608b4c87f07440dc3232801720b1168 (diff)
downloadmongodb-7645618fd3914cb8a20561625913c20d49504a49.tar.gz
Imported Upstream version 1.6.0
Diffstat (limited to 'jstests/rs/test_framework.js')
-rw-r--r--jstests/rs/test_framework.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/jstests/rs/test_framework.js b/jstests/rs/test_framework.js
new file mode 100644
index 0000000..eb6e628
--- /dev/null
+++ b/jstests/rs/test_framework.js
@@ -0,0 +1,30 @@
+// test helpers
+// load("test_framework.js")
+
+DB.prototype.isMaster = function() {
+ return this.runCommand("isMaster");
+}
+DB.prototype.ismaster = function () { return this.isMaster().ismaster; }
+
+function rs_mongod() {
+ /* run mongod for a replica set member. wipes data dir! */
+ var port = __nextPort++;
+ var not_me = (port == 27000 ? port + 1 : port - 1);
+ var f = startMongodEmpty;
+ var dir = "" + port; // e.g., data/db/27000
+ var conn = f.apply(null, [
+ {
+ port: port,
+ dbpath: "/data/db/" + dir,
+ noprealloc: "",
+ smallfiles: "",
+ oplogSize: "2",
+ //nohttpinterface: ""
+ rest: "", // --rest is best for replica set administration
+ replSet: "asdf/" + hostname() + ":" + not_me
+ }
+ ]
+ );
+ conn.name = "localhost:" + port;
+ return conn;
+}