File: dumprestore10.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 (63 lines) | stat: -rw-r--r-- 1,318 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// simple test to ensure write concern functions as expected

var name = "dumprestore10";

function step(msg) {
    msg = msg || "";
    this.x = (this.x || 0) + 1;
    print('\n' + name + ".js step " + this.x + ' ' + msg);
}

step();

var replTest = new ReplSetTest( {name: name, nodes: 2} );
var nodes = replTest.startSet();
replTest.initiate();
var master = replTest.getMaster();
var total = 1000;

{
    step("store data");
    var foo = master.getDB("foo");
    for (i = 0; i < total; i++) {
        foo.bar.insert({ x: i, y: "abc" });
    }
}

{
    step("wait");
    replTest.awaitReplication();
}

step("mongodump from replset");

var data = "/data/db/dumprestore10-dump1/";

runMongoProgram( "mongodump", "--host", "127.0.0.1:"+replTest.ports[0], "--out", data );


{
    step("remove data after dumping");
    master.getDB("foo").getCollection("bar").drop();
}

{
    step("wait");
    replTest.awaitReplication();
}

step("try mongorestore with write concern");

runMongoProgram( "mongorestore", "--w", "2", "--host", "127.0.0.1:"+replTest.ports[0], "--dir", data );

var x = 0;

// no waiting for replication
x = master.getDB("foo").getCollection("bar").count();

assert.eq(x, total, "mongorestore should have successfully restored the collection");

step("stopSet");
replTest.stopSet();

step("SUCCESS");