summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/sessions_collection_auto_healing.js
blob: 9e2e2df3dc63275f042a9df205638ef05732a2e8 (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
load('jstests/libs/sessions_collection.js');

(function() {
    "use strict";

    var startSession = {startSession: 1};
    var conn = MongoRunner.runMongod({nojournal: ""});

    var admin = conn.getDB("admin");
    var config = conn.getDB("config");

    // Test that we can use sessions before the sessions collection exists.
    {
        validateSessionsCollection(conn, false, false);
        assert.commandWorked(admin.runCommand({startSession: 1}));
        validateSessionsCollection(conn, false, false);
    }

    // Test that a refresh will create the sessions collection.
    {
        assert.commandWorked(admin.runCommand({refreshLogicalSessionCacheNow: 1}));
        validateSessionsCollection(conn, true, true);
    }

    // Test that a refresh will (re)create the TTL index on the sessions collection.
    {
        assert.commandWorked(config.system.sessions.dropIndex({lastUse: 1}));
        validateSessionsCollection(conn, true, false);
        assert.commandWorked(admin.runCommand({refreshLogicalSessionCacheNow: 1}));
        validateSessionsCollection(conn, true, true);
    }

})();