summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/test/qa-tests/jstests/restore/oplog_replay_and_limit.js
diff options
context:
space:
mode:
authorRamon Fernandez <ramon@mongodb.com>2016-08-25 16:34:34 -0400
committerRamon Fernandez <ramon@mongodb.com>2016-08-25 16:54:18 -0400
commitc330c9991ab45e7d0685d53e699ef26dba065660 (patch)
tree3dc5cd06b5f6c7eaaa4cb20cbe763504c14a772b /src/mongo/gotools/test/qa-tests/jstests/restore/oplog_replay_and_limit.js
parenteb62b862d5ebf179a1bcd9f394070e69c30188ab (diff)
downloadmongo-c330c9991ab45e7d0685d53e699ef26dba065660.tar.gz
Import tools: 5b883d86fdb4df55036d5dba2ca6f9dfa0750b44 from branch v3.3
ref: 1ac1389bda..5b883d86fd for: 3.3.12 SERVER-25814 Initial vendor import: tools
Diffstat (limited to 'src/mongo/gotools/test/qa-tests/jstests/restore/oplog_replay_and_limit.js')
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/restore/oplog_replay_and_limit.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/mongo/gotools/test/qa-tests/jstests/restore/oplog_replay_and_limit.js b/src/mongo/gotools/test/qa-tests/jstests/restore/oplog_replay_and_limit.js
new file mode 100644
index 00000000000..378e018f155
--- /dev/null
+++ b/src/mongo/gotools/test/qa-tests/jstests/restore/oplog_replay_and_limit.js
@@ -0,0 +1,78 @@
+(function() {
+
+ if (typeof getToolTest === 'undefined') {
+ load('jstests/configs/plain_28.config.js');
+ }
+
+ if (dump_targets !== "standard") {
+ print('skipping test incompatable with archiving or compression');
+ return assert(true);
+ }
+
+ // Tests using mongorestore with the --oplogReplay and --oplogLimit flags.
+
+ jsTest.log('Testing restoration with the --oplogReplay and --oplogLimit options');
+
+ var toolTest = getToolTest('oplog_replay_and_limit');
+ var commonToolArgs = getCommonToolArguments();
+
+ // this test uses the testdata/dump_with_oplog directory. this directory contains:
+ // - a test/ subdirectory, which will restore objects { _id: i } for i from
+ // 0-9 to the test.data collection
+ // - an oplog.bson file, which contains oplog entries for inserts of
+ // objects { _id: i } for i from 10-14 to the test.data collection.
+ //
+ // within the oplog.bson file, the entries for i from 10-13 have timestamps
+ // 1416342265:2 through 1416342265:5. the entry for { _id: i } has
+ // timestamp 1500000000:1.
+
+ // the db and collection we'll be using
+ var testDB = toolTest.db.getSiblingDB('test');
+ var testColl = testDB.data;
+
+ // restore the data, without --oplogReplay. _ids 0-9, which appear in the
+ // collection's bson file, should be restored.
+ var ret = toolTest.runTool.apply(toolTest, ['restore']
+ .concat(getRestoreTarget('jstests/restore/testdata/dump_with_oplog'))
+ .concat(commonToolArgs));
+ assert.eq(0, ret);
+ assert.eq(10, testColl.count());
+ for (var i = 0; i < 10; i++) {
+ assert.eq(1, testColl.count({_id: i}));
+ }
+
+ // drop the db
+ testDB.dropDatabase();
+
+ // restore the data, with --oplogReplay. _ids 10-14, appearing
+ // in the oplog.bson file, should be inserted as well.
+ ret = toolTest.runTool.apply(toolTest, ['restore',
+ '--oplogReplay']
+ .concat(getRestoreTarget('jstests/restore/testdata/dump_with_oplog'))
+ .concat(commonToolArgs));
+ assert.eq(0, ret);
+ assert.eq(15, testColl.count());
+ for (i = 0; i < 15; i++) {
+ assert.eq(1, testColl.count({_id: i}));
+ }
+
+ // drop the db
+ testDB.dropDatabase();
+
+ // restore the data, with --oplogReplay and --oplogLimit with a
+ // value that will filter out { _id: 14 } from getting inserted.
+ ret = toolTest.runTool.apply(toolTest, ['restore',
+ '--oplogReplay',
+ '--oplogLimit', '1416342266:0']
+ .concat(getRestoreTarget('jstests/restore/testdata/dump_with_oplog'))
+ .concat(commonToolArgs));
+ assert.eq(0, ret);
+ assert.eq(14, testColl.count());
+ for (i = 0; i < 14; i++) {
+ assert.eq(1, testColl.count({_id: i}));
+ }
+
+ // success
+ toolTest.stop();
+
+}());