diff options
author | Shaun Verch <shaun.verch@10gen.com> | 2014-03-06 16:37:01 -0500 |
---|---|---|
committer | Shaun Verch <shaun.verch@10gen.com> | 2014-03-11 11:49:49 -0400 |
commit | 6816eddd30a0015f1eadb1bb48dff2f10cac187c (patch) | |
tree | 7b89ac79344db8c469d938248dd5f62880880a97 /jstests/auth/copyauth_between_shards.js | |
parent | 8ff46a852e18f41161a0061d3dd810fd2468d535 (diff) | |
download | mongo-6816eddd30a0015f1eadb1bb48dff2f10cac187c.tar.gz |
SERVER-12820 Added jstest for various possible copydb command uses
Diffstat (limited to 'jstests/auth/copyauth_between_shards.js')
-rw-r--r-- | jstests/auth/copyauth_between_shards.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/jstests/auth/copyauth_between_shards.js b/jstests/auth/copyauth_between_shards.js new file mode 100644 index 00000000000..cd95c9e1508 --- /dev/null +++ b/jstests/auth/copyauth_between_shards.js @@ -0,0 +1,59 @@ +// Test copyDatabase command inside a sharded cluster with and without auth. Tests with auth are +// currently disabled due to SERVER-13080. + +var baseName = "jstests_clone_copyauth_between_shards"; + +function copydbWithinShardedCluster(useReplSets, passCredentials, useAuth) { + var clusterConfig = {shards : 1, + mongos : 1, + config : 1 }; + + if (useAuth) { + clusterConfig.auth = ""; + clusterConfig.keyFile = "jstests/libs/key1"; + } + + if (useReplSets) { + clusterConfig.rs = {}; + } + var st = new ShardingTest(clusterConfig); + + var mongos = st.s; + + var test1 = mongos.getDB('test1'); + var test2 = mongos.getDB('test2'); + + if (useAuth) { + mongos.getDB("admin").createUser({user: "super", pwd: "super", roles: ["root"]}); + assert.throws(function() { mongos.getDB("test1")["test1"].findOne(); }); + mongos.getDB("admin").auth("super", "super"); + } + + test1.getCollection('test').insert({foo: 'bar'}); + jsTestLog('Test document on source db:'); + printjson(test1.getCollection('test').findOne()); + jsTestLog('copydb'); + + // The copyDatabase command acts differently depending on whether we pass username and password + if (passCredentials) { + var result = mongos.getDB('admin').copyDatabase('test1', 'test2', undefined, "super", "super"); + } + else { + var result = mongos.getDB('admin').copyDatabase('test1', 'test2'); + } + printjson(result); + assert.eq(result.ok, 1.0); + jsTestLog('Test document on destination db:'); + printjson(test2.getCollection('test').findOne()); + st.stop(); +} + +// SERVER-13080 +//copydbWithinShardedCluster(true, true, true); +//copydbWithinShardedCluster(false, true, true); +//copydbWithinShardedCluster(true, false, true); +//copydbWithinShardedCluster(false, false, true); +copydbWithinShardedCluster(true, false, false); +copydbWithinShardedCluster(false, false, false); + +print(baseName + " success!"); |