diff options
author | Scott Hernandez <scotthernandez@gmail.com> | 2014-12-30 14:46:29 -0500 |
---|---|---|
committer | Scott Hernandez <scotthernandez@gmail.com> | 2015-01-02 14:21:08 -0500 |
commit | 8b37507dd51cdf058377a24ca0171e7fae6f2c6b (patch) | |
tree | 1bea2528edb8df7cf70fda21f6894e59af820f60 /jstests | |
parent | 430bafbd8643bd1d30513ad231850c6927e8553d (diff) | |
download | mongo-8b37507dd51cdf058377a24ca0171e7fae6f2c6b.tar.gz |
SERVER-16502: open database after repair is done
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/repair_database.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/core/repair_database.js b/jstests/core/repair_database.js new file mode 100644 index 00000000000..ca4bddd4bb1 --- /dev/null +++ b/jstests/core/repair_database.js @@ -0,0 +1,39 @@ +/** + * This tests checks that repair database works and doesn't leave the database in a bad state + * 1.) Drop "repairDB" database + * 2.) Ensure repair works with single collection with an extra index. and one doc + * 3.) Ensure repair works with no docs, same collection/index as above + * 4.) Ensure repair works with 2 collections, one doc in each + */ + +// 1. Drop db +var mydb = db.getSisterDB( "repairDB" ); +mydb.dropDatabase() + +var myColl = mydb.a; + +// 2 +var doc = {_id:1, a:"hello world"}; +myColl.insert(doc); +myColl.ensureIndex({a:1}) +mydb.repairDatabase(); +var foundDoc = myColl.findOne(); + +assert.neq(null, foundDoc) +assert.eq(1, foundDoc._id) + +assert.docEq(doc, myColl.findOne({a:doc.a})) +assert.docEq(doc, myColl.findOne({_id:1})) + +// 3 +var myColl2 = mydb.b; +myColl.remove({}); +mydb.repairDatabase(); + +// 4 +var myColl2 = mydb.b; +myColl.insert(doc); +myColl2.insert(doc); +mydb.repairDatabase(); +assert.docEq(doc, myColl.findOne({a:doc.a})) +assert.docEq(doc, myColl2.findOne({a:doc.a})) |