0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/slow1/large_role_chain.js
Mathias Stearn 43d933a286 SERVER-13391 Move slowest tests from noPassthrough* (formerly slow{Weekly,Nightly}) to slow*
slow1 and slow2 are new suites to hold very slow tests. The idea is that we
can create slow3, slow4, etc to keep the time to run the longest suite down.
2014-03-27 17:35:16 -04:00

38 lines
1.1 KiB
JavaScript

// Tests SERVER-11475 - Make sure server does't crash when many user defined roles are created where
// each role is a member of the next, creating a large chain.
function runTest(conn) {
var testdb = conn.getDB("rolechain");
testdb.runCommand({dropAllRolesFromDatabase:1});
var chainLen = 2000;
jsTestLog("Generating a chain of " + chainLen + " linked roles");
var roleNameBase = "chainRole";
for (var i = 0; i < chainLen; i++) {
var name = roleNameBase + i;
if (i == 0) {
testdb.runCommand({createRole: name, privileges: [], roles: []});
}
else {
jsTestLog("Creating role " + i);
var prevRole = roleNameBase + (i - 1);
testdb.runCommand({createRole: name, privileges: [], roles: [ prevRole ]});
var roleInfo = testdb.getRole(name);
}
}
}
// run all tests standalone
var conn = MongoRunner.runMongod();
runTest(conn);
MongoRunner.stopMongod(conn);
// run all tests sharded
conn = new ShardingTest({shards: 2, mongos: 1, config: 3});
runTest(conn);
conn.stop();