summaryrefslogtreecommitdiff
path: root/jstests/replsets/sessions_collection_auto_healing.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/sessions_collection_auto_healing.js')
-rw-r--r--jstests/replsets/sessions_collection_auto_healing.js36
1 files changed, 35 insertions, 1 deletions
diff --git a/jstests/replsets/sessions_collection_auto_healing.js b/jstests/replsets/sessions_collection_auto_healing.js
index 28f3dc51bba..f8240fc58d6 100644
--- a/jstests/replsets/sessions_collection_auto_healing.js
+++ b/jstests/replsets/sessions_collection_auto_healing.js
@@ -9,7 +9,11 @@ TestData.disableImplicitSessions = true;
var replTest = new ReplSetTest({
name: 'refresh',
- nodes: [{rsConfig: {votes: 1, priority: 1}}, {rsConfig: {votes: 0, priority: 0}}]
+ nodes: [
+ {/* primary */},
+ {/* secondary */ rsConfig: {priority: 0}},
+ {/* arbiter */ rsConfig: {arbiterOnly: true}}
+ ]
});
var nodes = replTest.startSet();
@@ -21,6 +25,11 @@ replTest.awaitSecondaryNodes();
var secondary = replTest.getSecondary();
var secondaryAdmin = secondary.getDB("admin");
+let arbiter = replTest.getArbiter();
+
+const refreshErrorMsgRegex =
+ new RegExp("Failed to refresh session cache, will try again at the next refresh interval");
+
// Get the current value of the TTL index so that we can verify it's being properly applied.
let res = assert.commandWorked(
primary.adminCommand({getParameter: 1, localLogicalSessionTimeoutMinutes: 1}));
@@ -64,6 +73,22 @@ let timeoutMinutes = res.localLogicalSessionTimeoutMinutes;
replTest.awaitReplication();
validateSessionsCollection(secondary, false, false, timeoutMinutes);
}
+
+// Test that a refresh on an arbiter does not create the sessions collection.
+{
+ validateSessionsCollection(primary, false, false, timeoutMinutes);
+
+ assert.commandWorked(arbiter.adminCommand({clearLog: 'global'}));
+ assert.commandWorked(arbiter.adminCommand({refreshLogicalSessionCacheNow: 1}));
+
+ validateSessionsCollection(primary, false, false, timeoutMinutes);
+
+ if (!jsTest.options().useRandomBinVersionsWithinReplicaSet) {
+ // Verify that the arbiter did not try to set up the session collection or refresh.
+ assert.eq(false, checkLog.checkContainsOnce(arbiter, refreshErrorMsgRegex));
+ }
+}
+
// Test that a refresh on the primary creates the sessions collection.
{
validateSessionsCollection(primary, false, false, timeoutMinutes);
@@ -87,6 +112,15 @@ let timeoutMinutes = res.localLogicalSessionTimeoutMinutes;
validateSessionsCollection(primary, true, false, timeoutMinutes);
}
+// Test that a refresh on an arbiter will not create the TTL index on the sessions collection.
+{
+ validateSessionsCollection(primary, true, false, timeoutMinutes);
+
+ assert.commandWorked(arbiter.adminCommand({refreshLogicalSessionCacheNow: 1}));
+
+ validateSessionsCollection(primary, true, false, timeoutMinutes);
+}
+
// Test that a refresh on the primary will create the TTL index on the sessions collection.
{
validateSessionsCollection(primary, true, false, timeoutMinutes);