File: dumpsecondary.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (38 lines) | stat: -rw-r--r-- 1,270 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var replTest = new ReplSetTest( {name: 'testSet', nodes: 2} );

var nodes = replTest.startSet();
replTest.initiate();

var master = replTest.getMaster();
db = master.getDB("foo")
db.foo.save({a: 1000});
replTest.awaitReplication();
replTest.awaitSecondaryNodes();

assert.eq( 1 , db.foo.count() , "setup" );

var slaves = replTest.liveNodes.slaves;
assert( slaves.length == 1, "Expected 1 slave but length was " + slaves.length );
slave = slaves[0];

var args = ['mongodump', '-h', slave.host, '--out', '/data/db/jstests_tool_dumpsecondary_external/'];
var authargs = ['--username', jsTest.options().authUser, '--password', jsTest.options().authPassword];
if (jsTest.options().keyFile) {
    args = args.concat(authargs);
}
runMongoProgram.apply(null, args);
db.foo.drop()

assert.eq( 0 , db.foo.count() , "after drop" );
args = ['mongorestore', '-h', master.host, '/data/db/jstests_tool_dumpsecondary_external/'];
if (jsTest.options().keyFile) {
    args = args.concat(authargs);
}
runMongoProgram.apply(null, args)
assert.soon( "db.foo.findOne()" , "no data after sleep" );
assert.eq( 1 , db.foo.count() , "after restore" );
assert.eq( 1000 , db.foo.findOne().a , "after restore 2" );

resetDbpath('/data/db/jstests_tool_dumpsecondary_external')

replTest.stopSet(15)