Files
mongo/db/repl/testing.js

43 lines
976 B
JavaScript
Raw Normal View History

2010-05-05 14:00:25 -04:00
// helpers for testing repl sets
2010-05-05 16:33:35 -04:00
// run
2010-05-13 17:18:17 -04:00
// mongo --shell <host:port> testing.js
2010-05-05 14:00:25 -04:00
cfg = {
_id: 'asdf',
members: [
{ _id : 0, host : "dm_hp" },
{ _id : 2, host : "dm_hp:27002" }
]
};
2010-05-15 14:48:40 -04:00
c2 = {
_id: 'asdf',
members: [
{ _id: 0, host: "dmthink" },
{ _id: 2, host: "dmthink:27002" }
]
};
2010-05-05 14:00:25 -04:00
db = db.getSisterDB("admin");
local = db.getSisterDB("local");
2010-05-15 13:32:10 -04:00
print("\n\ndb = admin db on localhost:27017");
print("b = admin on localhost:27002");
print("rc(x) = db.runCommand(x)");
2010-05-13 17:18:17 -04:00
print("cfg = samp replset config");
2010-05-15 13:32:10 -04:00
print("i() = replSetInitiate(cfg)");
print("ism() = rc('ismaster')");
print("\n\n");
2010-05-05 14:00:25 -04:00
function rc(c) { return db.runCommand(c); }
2010-05-15 13:32:10 -04:00
function i() { return rc({ replSetInitiate: cfg }); }
function ism() { return rc("isMaster"); }
2010-05-24 08:06:05 -04:00
b = 0;
try {
b = new Mongo("localhost:27002").getDB("admin");
}
catch (e) {
print("\nCouldn't connect to b mongod instance\n");
}