diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2015-02-20 08:55:54 -0500 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2015-02-20 08:55:54 -0500 |
commit | 56202c537bfa6de56ca98d8caa04eaf095b7ef62 (patch) | |
tree | 9b2bb7117a2a1ca61ab9a753824134e938fbc597 | |
parent | 7ed5259ea72ad18e6b56450d7e23a269191b424a (diff) | |
download | mongo-56202c537bfa6de56ca98d8caa04eaf095b7ef62.tar.gz |
SERVER-13357 add slaveOk argument to clone
-rw-r--r-- | jstests/replsets/cloneDb.js | 10 | ||||
-rw-r--r-- | src/mongo/db/commands/clone.cpp | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/jstests/replsets/cloneDb.js b/jstests/replsets/cloneDb.js index f0d93bb7635..e5215477879 100644 --- a/jstests/replsets/cloneDb.js +++ b/jstests/replsets/cloneDb.js @@ -50,13 +50,17 @@ if (jsTest.options().keyFile) { assert.eq(numDocs, standaloneDB[testColName].count(), 'cloneDatabase from PRIMARY to standalone failed (document counts do not match)'); - /* cloning from a SECONDARY does not work (SERVER-13357) - jsTest.log("Clone db from replica set SECONDARY to standalone server"); + jsTest.log("Clone db from replica set SECONDARY to standalone server (should not copy)"); standaloneDB.dropDatabase(); standaloneDB.cloneDatabase(secondary.host); + assert.eq(0, standaloneDB[testColName].count(), + 'cloneDatabase from SECONDARY to standalone copied documents without slaveOk: true'); + + jsTest.log("Clone db from replica set SECONDARY to standalone server using slaveOk"); + standaloneDB.dropDatabase(); + standaloneDB.runCommand({clone: secondary.host, slaveOk: true}); assert.eq(numDocs, standaloneDB[testColName].count(), 'cloneDatabase from SECONDARY to standalone failed (document counts do not match)'); - */ jsTest.log("Switch db and insert data into standalone server"); masterDB = master.getDB(standaloneDBName); diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp index 285456f6174..63b8ae2679d 100644 --- a/src/mongo/db/commands/clone.cpp +++ b/src/mongo/db/commands/clone.cpp @@ -72,7 +72,7 @@ namespace mongo { virtual void help( stringstream &help ) const { help << "clone this database from an instance of the db on another host\n"; - help << "{ clone : \"host13\" }"; + help << "{clone: \"host13\"[, slaveOk: <bool>]}"; } virtual Status checkAuthForCommand(ClientBasic* client, @@ -103,6 +103,7 @@ namespace mongo { CloneOptions opts; opts.fromDB = dbname; opts.logForRepl = ! fromRepl; + opts.slaveOk = cmdObj["slaveOk"].trueValue(); // See if there's any collections we should ignore if( cmdObj["collsToIgnore"].type() == Array ){ |