forked from mongodb/mongo-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TOOLS-296: add simple upgrade/downgrade tests for mongorestore
Former-commit-id: 295d924
- Loading branch information
Sam Helman
committed
Dec 2, 2014
1 parent
64068c0
commit 6f91126
Showing
3 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
(function() { | ||
|
||
// Tests using mongorestore to restore a dump from a 2.4 mongod to a 2.8 mongod. | ||
|
||
jsTest.log('Testing running mongorestore restoring data from a 2.4 mongod to'+ | ||
' a 2.8 mongod'); | ||
|
||
var toolTest = new ToolTest('24_to_28', { binVersion: '2.4' }); | ||
toolTest.startDB('foo'); | ||
|
||
// where we'll put the dump | ||
var dumpTarget = '24_to_28_dump'; | ||
|
||
// the db and collection we'll be using | ||
var testDB = toolTest.db.getSiblingDB('test'); | ||
var testColl = testDB.coll; | ||
|
||
// insert some documents | ||
for (var i = 0; i < 50; i++) { | ||
testColl.insert({ _id: i }); | ||
} | ||
// sanity check the insert worked | ||
assert.eq(50, testColl.count()); | ||
|
||
// dump the data | ||
var ret = toolTest.runTool('dump', '--out', dumpTarget); | ||
assert.eq(0, ret); | ||
|
||
// drop the database | ||
testDB.dropDatabase(); | ||
|
||
// restart the mongod as a 2.8 | ||
stopMongod(toolTest.port); | ||
toolTest.m = null; | ||
toolTest.db = null; | ||
delete toolTest.options.binVersion; | ||
toolTest.startDB('foo'); | ||
|
||
// refresh the db and coll reference | ||
testDB = toolTest.db.getSiblingDB('test'); | ||
testColl = testDB.coll; | ||
|
||
// restore the data | ||
ret = toolTest.runTool('restore', dumpTarget); | ||
assert.eq(0, ret); | ||
|
||
// make sure the data was restored | ||
assert.eq(50, testColl.count()); | ||
for (var i = 0; i < 50; i++) { | ||
assert.eq(1, testColl.count({ _id: i })); | ||
} | ||
|
||
// success | ||
toolTest.stop(); | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
(function() { | ||
|
||
// Tests using mongorestore to restore a dump from a 2.6 mongod to a 2.8 mongod. | ||
|
||
jsTest.log('Testing running mongorestore restoring data from a 2.6 mongod to'+ | ||
' a 2.8 mongod'); | ||
|
||
var toolTest = new ToolTest('26_to_28', { binVersion: '2.6' }); | ||
toolTest.startDB('foo'); | ||
|
||
// where we'll put the dump | ||
var dumpTarget = '26_to_28_dump'; | ||
|
||
// the db and collection we'll be using | ||
var testDB = toolTest.db.getSiblingDB('test'); | ||
var testColl = testDB.coll; | ||
|
||
// insert some documents | ||
for (var i = 0; i < 50; i++) { | ||
testColl.insert({ _id: i }); | ||
} | ||
// sanity check the insert worked | ||
assert.eq(50, testColl.count()); | ||
|
||
// dump the data | ||
var ret = toolTest.runTool('dump', '--out', dumpTarget); | ||
assert.eq(0, ret); | ||
|
||
// drop the database | ||
testDB.dropDatabase(); | ||
|
||
// restart the mongod as a 2.8 | ||
stopMongod(toolTest.port); | ||
toolTest.m = null; | ||
toolTest.db = null; | ||
delete toolTest.options.binVersion; | ||
toolTest.startDB('foo'); | ||
|
||
// refresh the db and coll reference | ||
testDB = toolTest.db.getSiblingDB('test'); | ||
testColl = testDB.coll; | ||
|
||
// restore the data | ||
ret = toolTest.runTool('restore', dumpTarget); | ||
assert.eq(0, ret); | ||
|
||
// make sure the data was restored | ||
assert.eq(50, testColl.count()); | ||
for (var i = 0; i < 50; i++) { | ||
assert.eq(1, testColl.count({ _id: i })); | ||
} | ||
|
||
// success | ||
toolTest.stop(); | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
(function() { | ||
|
||
// Tests using mongorestore to restore a dump from a 2.8 mongod to a 2.6 mongod. | ||
|
||
jsTest.log('Testing running mongorestore restoring data from a 2.8 mongod to'+ | ||
' a 2.6 mongod'); | ||
|
||
var toolTest = new ToolTest('28_to_26'); | ||
toolTest.startDB('foo'); | ||
|
||
// where we'll put the dump | ||
var dumpTarget = '28_to_26_dump'; | ||
|
||
// the db and collection we'll be using | ||
var testDB = toolTest.db.getSiblingDB('test'); | ||
var testColl = testDB.coll; | ||
|
||
// insert some documents | ||
for (var i = 0; i < 50; i++) { | ||
testColl.insert({ _id: i }); | ||
} | ||
// sanity check the insert worked | ||
assert.eq(50, testColl.count()); | ||
|
||
// dump the data | ||
var ret = toolTest.runTool('dump', '--out', dumpTarget); | ||
assert.eq(0, ret); | ||
|
||
// drop the database | ||
testDB.dropDatabase(); | ||
|
||
// restart the mongod as a 2.6 | ||
stopMongod(toolTest.port); | ||
toolTest.m = null; | ||
toolTest.db = null; | ||
toolTest.options = toolTest.options || {}; | ||
toolTest.options.binVersion = '2.6'; | ||
toolTest.startDB('foo'); | ||
|
||
// refresh the db and coll reference | ||
testDB = toolTest.db.getSiblingDB('test'); | ||
testColl = testDB.coll; | ||
|
||
// restore the data | ||
ret = toolTest.runTool('restore', dumpTarget); | ||
assert.eq(0, ret); | ||
|
||
// make sure the data was restored | ||
assert.eq(50, testColl.count()); | ||
for (var i = 0; i < 50; i++) { | ||
assert.eq(1, testColl.count({ _id: i })); | ||
} | ||
|
||
// success | ||
toolTest.stop(); | ||
}()); |