mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 00:17:37 +01:00
771dabd098
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
/*
|
|
* Run the kill_sessions tests against a sharded cluster.
|
|
*/
|
|
|
|
import {KillSessionsTestHelper} from "jstests/libs/kill_sessions.js";
|
|
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
|
|
// This test involves killing all sessions, which will not work as expected if the kill command is
|
|
// sent with an implicit session.
|
|
TestData.disableImplicitSessions = true;
|
|
|
|
function runTests(needAuth) {
|
|
var other = {
|
|
rs: true,
|
|
rs0: {nodes: 3},
|
|
rs1: {nodes: 3},
|
|
};
|
|
if (needAuth) {
|
|
other.keyFile = 'jstests/libs/key1';
|
|
}
|
|
|
|
var st = new ShardingTest({shards: 2, mongos: 1, other: other});
|
|
|
|
var forExec = st.s0;
|
|
|
|
if (needAuth) {
|
|
KillSessionsTestHelper.initializeAuth(forExec);
|
|
}
|
|
|
|
var forKill = new Mongo(forExec.host);
|
|
|
|
var r = forExec.getDB("admin").runCommand({
|
|
multicast: {ping: 1},
|
|
db: "admin",
|
|
});
|
|
assert(r.ok);
|
|
|
|
var hosts = [];
|
|
for (var host in r["hosts"]) {
|
|
var host = new Mongo(host);
|
|
if (needAuth) {
|
|
host.getDB("local").auth("__system", "foopdedoop");
|
|
}
|
|
hosts.push(host);
|
|
}
|
|
|
|
var args = [forExec, forKill, hosts];
|
|
if (needAuth) {
|
|
KillSessionsTestHelper.runAuth.apply({}, args);
|
|
} else {
|
|
KillSessionsTestHelper.runNoAuth.apply({}, args);
|
|
}
|
|
|
|
st.stop();
|
|
}
|
|
|
|
runTests(true);
|
|
runTests(false);
|