summaryrefslogtreecommitdiff
path: root/jstests/sharding/kill_sessions.js
blob: 4c710c38ffac7dc325b95755d376e21e751f18d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * Run the kill_sessions tests against a sharded cluster.
 *
 * TODO SERVER-45385: These tests can be enabled in multiversion once the logging of session cursor
 * cleanup has been backported and released in last-lts.
 * @tags: [multiversion_incompatible]
 */

load("jstests/libs/kill_sessions.js");

(function() {
'use strict';

// 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);

        assert.soon(function() {
            var fcv =
                host.getDB("admin").runCommand({getParameter: 1, featureCompatibilityVersion: 1});
            return fcv["ok"] && fcv["featureCompatibilityVersion"] != "3.4";
        });
    }

    var args = [forExec, forKill, hosts];
    if (needAuth) {
        KillSessionsTestHelper.runAuth.apply({}, args);
    } else {
        KillSessionsTestHelper.runNoAuth.apply({}, args);
    }

    st.stop();
}

runTests(true);
runTests(false);
})();