summaryrefslogtreecommitdiff
path: root/jstests/tool/restorewithauth.js
diff options
context:
space:
mode:
authorMatt Kangas <matt.kangas@mongodb.com>2014-12-10 22:12:58 -0500
committerMatt Kangas <matt.kangas@mongodb.com>2014-12-10 22:13:01 -0500
commitae6df7a0b10cb40c2730b10f4057454ca6733b13 (patch)
treedb1e2884f076d9dca4a143467bc3fa088f8bb092 /jstests/tool/restorewithauth.js
parent98a7e7f9709413ce06f49b48dee98f7080505947 (diff)
downloadmongo-ae6df7a0b10cb40c2730b10f4057454ca6733b13.tar.gz
TOOLS-450 Revert restorewithauth.js
This partially reverts commit bf834456c3e5a02fbe6fed340563a3c5fa548e4c
Diffstat (limited to 'jstests/tool/restorewithauth.js')
-rw-r--r--jstests/tool/restorewithauth.js106
1 files changed, 28 insertions, 78 deletions
diff --git a/jstests/tool/restorewithauth.js b/jstests/tool/restorewithauth.js
index 5c812a6b712..bcf37d95b2e 100644
--- a/jstests/tool/restorewithauth.js
+++ b/jstests/tool/restorewithauth.js
@@ -14,7 +14,6 @@
* 9) Try restore with correct auth credentials. The restore should succeed this time.
*/
-
var port = allocatePorts(1)[0];
baseName = "jstests_restorewithauth";
var conn = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface",
@@ -28,21 +27,16 @@ for( var i = 0; i < 4; i++ ) {
}
// make sure the collection exists
-var listCollOut = foo.runCommand("listCollections");
-assert.eq(1, listCollOut.ok);
-var barColl = null;
-listCollOut.collections.forEach(function(coll) {
- if (coll.name === "bar") {
- barColl = coll;
- }
-});
-assert.neq(null, barColl, "bar collection doesn't exist");
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "bar"}}).collections.length, 1 )
//make sure it has no index except _id
-assert.eq(foo.bar.getIndexes().length, 2);
+assert.eq(foo.bar.getIndexes().length, 1);
+assert.eq(foo.baz.getIndexes().length, 1);
foo.bar.createIndex({x:1});
-assert.eq(foo.bar.getIndexes().length, 3);
+assert.eq(foo.bar.getIndexes().length, 2);
+assert.eq(foo.baz.getIndexes().length, 1);
// get data dump
var dumpdir = MongoRunner.dataDir + "/restorewithauth-dump1/";
@@ -67,37 +61,19 @@ admin.auth( "admin" , "admin" );
var foo = conn.getDB( "foo" )
// make sure no collection with the same name exists
-listCollOut = foo.runCommand("listCollections");
-assert.eq(1, listCollOut.ok);
-barColl = null;
-var bazColl = null;
-listCollOut.collections.forEach(function(coll) {
- if (coll.name === "bar") {
- barColl = coll;
- } else if (coll.name === "baz") {
- bazColl = coll;
- }
-});
-assert.eq(null, barColl, "bar collection already exists");
-assert.eq(null, bazColl, "baz collection already exists");
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "bar"}}).collections.length, 0 )
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "baz"}}).collections.length, 0 )
// now try to restore dump
x = runMongoProgram( "mongorestore", "-h", "127.0.0.1:" + port, "--dir" , dumpdir, "-vvvvv" );
// make sure that the collection isn't restored
-listCollOut = foo.runCommand("listCollections");
-assert.eq(1, listCollOut.ok);
-barColl = null;
-bazColl = null;
-listCollOut.collections.forEach(function(coll) {
- if (coll.name === "bar") {
- barColl = coll;
- } else if (coll.name === "baz") {
- bazColl = coll;
- }
-});
-assert.eq(null, barColl, "bar collection was restored");
-assert.eq(null, bazColl, "baz collection was restored");
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "bar"}}).collections.length, 0 )
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "baz"}}).collections.length, 0 )
// now try to restore dump with correct credentials
x = runMongoProgram( "mongorestore",
@@ -110,19 +86,10 @@ x = runMongoProgram( "mongorestore",
"-vvvvv");
// make sure that the collection was restored
-listCollOut = foo.runCommand("listCollections");
-assert.eq(1, listCollOut.ok);
-barColl = null;
-bazColl = null;
-listCollOut.collections.forEach(function(coll) {
- if (coll.name === "bar") {
- barColl = coll;
- } else if (coll.name === "baz") {
- bazColl = coll;
- }
-});
-assert.neq(null, barColl, "bar collection was not restored");
-assert.neq(null, bazColl, "baz collection was not restored");
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "bar"}}).collections.length, 1 )
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "baz"}}).collections.length, 1 )
// make sure the collection has 4 documents
assert.eq(foo.bar.count(), 4);
@@ -131,19 +98,10 @@ assert.eq(foo.baz.count(), 4);
foo.dropDatabase();
// make sure that the collection is empty
-listCollOut = foo.runCommand("listCollections");
-assert.eq(1, listCollOut.ok);
-barColl = null;
-bazColl = null;
-listCollOut.collections.forEach(function(coll) {
- if (coll.name === "bar") {
- barColl = coll;
- } else if (coll.name === "baz") {
- bazColl = coll;
- }
-});
-assert.eq(null, barColl, "bar collection was restored");
-assert.eq(null, bazColl, "baz collection was restored");
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "bar"}}).collections.length, 0 )
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "baz"}}).collections.length, 0 )
foo.createUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles});
@@ -157,21 +115,13 @@ x = runMongoProgram("mongorestore",
"-vvvvv");
// make sure that the collection was restored
-listCollOut = foo.runCommand("listCollections");
-assert.eq(1, listCollOut.ok);
-barColl = null;
-bazColl = null;
-listCollOut.collections.forEach(function(coll) {
- if (coll.name === "bar") {
- barColl = coll;
- } else if (coll.name === "baz") {
- bazColl = coll;
- }
-});
-assert.neq(null, barColl, "bar collection was not restored");
-assert.neq(null, bazColl, "baz collection was not restored");
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "bar"}}).collections.length, 1 )
+assert.eq( foo.runCommand({"listCollections": 1,
+ "filter": {"name": "baz"}}).collections.length, 1 )
assert.eq(foo.bar.count(), 4);
assert.eq(foo.baz.count(), 4);
-assert.eq(foo.bar.getIndexes().length + foo.baz.getIndexes().length, 3); // _id on foo, _id on bar, x on foo
+assert.eq(foo.bar.getIndexes().length, 2);
+assert.eq(foo.baz.getIndexes().length, 1);
stopMongod( port );