Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SERVER-4992 Disable dropDatabase command on config
i) Diallow completely via mongos ii) And partially if mongod started with --configsvr
- Loading branch information
1 parent
d66742b
commit eef1039
Showing
3 changed files
with
48 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,38 @@ | ||
var shardA = startMongodEmpty("--shardsvr", "--port", 30001, "--dbpath", "/data/shardA", "--nopreallocj"); | ||
var shardB = startMongodEmpty("--shardsvr", "--port", 30002, "--dbpath", "/data/shardB", "--nopreallocj"); | ||
var configsvr = startMongodEmpty("--configsvr", "--port", 29999, "--dbpath", "/data/configC", "--nopreallocj"); | ||
|
||
var mongos = startMongos({ port : 30000, configdb : "localhost:29999" }) | ||
|
||
var admin = mongos.getDB("admin") | ||
|
||
admin.runCommand({ addshard : "localhost:30001" }) | ||
admin.runCommand({ addshard : "localhost:30002" }) | ||
|
||
var config = configsvr.getDB( "config" ) | ||
|
||
// Try to drop config db via configsvr | ||
|
||
print ( "1: Try to drop config database via configsvr" ) | ||
config.dropDatabase() | ||
|
||
print ( "2: Ensure it wasn't dropped" ) | ||
assert.eq( 1, config.databases.find({ _id : "admin", partitioned : false, primary : "config"}).toArray().length ) | ||
|
||
|
||
// Try to drop config db via mongos | ||
|
||
var config = mongos.getDB( "config" ) | ||
|
||
print ( "1: Try to drop config database via mongos" ) | ||
config.dropDatabase() | ||
|
||
print ( "2: Ensure it wasn't dropped" ) | ||
assert.eq( 1, config.databases.find({ _id : "admin", partitioned : false, primary : "config"}).toArray().length ) | ||
|
||
|
||
// Finish | ||
stopMongod( 30000 ); | ||
stopMongod( 29999 ); | ||
stopMongod( 30001 ); | ||
stopMongod( 30002 ); |
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
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