summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough
diff options
context:
space:
mode:
authorsamantharitter <samantha.ritter@10gen.com>2017-09-19 18:19:35 -0400
committersamantharitter <samantha.ritter@10gen.com>2017-09-25 10:32:55 -0400
commitf007ee07aebecd5371c38388423b05cd82ef02a2 (patch)
tree50c5ab6034ed22e95d690c37e5e8bd06dbba5ca9 /jstests/noPassthrough
parent1b549500669e8b2b2f7846aa5867f00b849ebd21 (diff)
downloadmongo-f007ee07aebecd5371c38388423b05cd82ef02a2.tar.gz
SERVER-31174 Move the sessions collection to config.system.sessions
Diffstat (limited to 'jstests/noPassthrough')
-rw-r--r--jstests/noPassthrough/end_sessions_command.js7
-rw-r--r--jstests/noPassthrough/logical_session_feature_compatibility.js3
-rw-r--r--jstests/noPassthrough/refresh_logical_session_cache_now.js9
-rw-r--r--jstests/noPassthrough/refresh_sessions_command.js15
-rw-r--r--jstests/noPassthrough/system_indexes.js16
-rw-r--r--jstests/noPassthrough/transaction_reaper.js6
-rw-r--r--jstests/noPassthrough/verify_session_cache_updates.js4
7 files changed, 34 insertions, 26 deletions
diff --git a/jstests/noPassthrough/end_sessions_command.js b/jstests/noPassthrough/end_sessions_command.js
index 3d6ae307a52..fed53476856 100644
--- a/jstests/noPassthrough/end_sessions_command.js
+++ b/jstests/noPassthrough/end_sessions_command.js
@@ -8,6 +8,7 @@
// Start up a standalone server.
var conn = MongoRunner.runMongod({nojournal: ""});
var admin = conn.getDB("admin");
+ var config = conn.getDB("config");
// Trigger an initial refresh, as a sanity check.
res = admin.runCommand(refresh);
@@ -23,7 +24,7 @@
res = admin.runCommand(refresh);
assert.commandWorked(res, "failed to refresh");
- assert.eq(admin.system.sessions.count(), 20, "refresh should have written 20 session records");
+ assert.eq(config.system.sessions.count(), 20, "refresh should have written 20 session records");
var endSessionsIds = [];
for (var i = 0; i < 10; i++) {
@@ -35,7 +36,7 @@
res = admin.runCommand(refresh);
assert.commandWorked(res, "failed to refresh");
- assert.eq(admin.system.sessions.count(),
+ assert.eq(config.system.sessions.count(),
10,
"endSessions and refresh should result in 10 remaining sessions");
@@ -52,7 +53,7 @@
res = admin.runCommand(refresh);
assert.commandWorked(res, "failed to refresh");
- assert.eq(admin.system.sessions.count(),
+ assert.eq(config.system.sessions.count(),
0,
"endSessions and refresh should result in 0 remaining sessions");
diff --git a/jstests/noPassthrough/logical_session_feature_compatibility.js b/jstests/noPassthrough/logical_session_feature_compatibility.js
index f060e499ecf..20ccfe483cf 100644
--- a/jstests/noPassthrough/logical_session_feature_compatibility.js
+++ b/jstests/noPassthrough/logical_session_feature_compatibility.js
@@ -85,6 +85,7 @@
var conn = MongoRunner.runMongod({nojournal: ""});
var admin = conn.getDB("admin");
+ var config = conn.getDB("config");
assert.commandWorked(admin.adminCommand({setFeatureCompatibilityVersion: "3.6"}));
@@ -102,6 +103,6 @@
admin.runCommand({refreshLogicalSessionCacheNow: 1});
- assert.eq(admin.system.sessions.find().count(), 11);
+ assert.eq(config.system.sessions.find().count(), 11);
})();
diff --git a/jstests/noPassthrough/refresh_logical_session_cache_now.js b/jstests/noPassthrough/refresh_logical_session_cache_now.js
index e3fe583f074..6d10cbca451 100644
--- a/jstests/noPassthrough/refresh_logical_session_cache_now.js
+++ b/jstests/noPassthrough/refresh_logical_session_cache_now.js
@@ -8,6 +8,7 @@
// Start up a standalone server.
var conn = MongoRunner.runMongod({nojournal: ""});
var admin = conn.getDB("admin");
+ var config = conn.getDB("config");
// Trigger an initial refresh, as a sanity check.
res = admin.runCommand(refresh);
@@ -17,13 +18,13 @@
res = admin.runCommand(startSession);
assert.commandWorked(res, "unable to start session");
- assert.eq(admin.system.sessions.count(), 0, "should not have session records yet");
+ assert.eq(config.system.sessions.count(), 0, "should not have session records yet");
// Trigger a refresh. Session should now be in the collection.
res = admin.runCommand(refresh);
assert.commandWorked(res, "failed to refresh");
- assert.eq(admin.system.sessions.count(), 1, "should have written session records");
+ assert.eq(config.system.sessions.count(), 1, "should have written session records");
// Start some new sessions. Should not be in the collection yet.
var numSessions = 100;
@@ -32,13 +33,13 @@
assert.commandWorked(res, "unable to start session");
}
- assert.eq(admin.system.sessions.count(), 1, "should not have more session records yet");
+ assert.eq(config.system.sessions.count(), 1, "should not have more session records yet");
// Trigger another refresh. All sessions should now be in the collection.
res = admin.runCommand(refresh);
assert.commandWorked(res, "failed to refresh");
assert.eq(
- admin.system.sessions.count(), numSessions + 1, "should have written session records");
+ config.system.sessions.count(), numSessions + 1, "should have written session records");
}());
diff --git a/jstests/noPassthrough/refresh_sessions_command.js b/jstests/noPassthrough/refresh_sessions_command.js
index 0c08d0891ce..80b249faca7 100644
--- a/jstests/noPassthrough/refresh_sessions_command.js
+++ b/jstests/noPassthrough/refresh_sessions_command.js
@@ -37,13 +37,14 @@
admin.auth("admin", "admin");
result = admin.runCommand({
- createRole: 'readAdmin',
- privileges: [{resource: {db: 'admin', collection: 'system.sessions'}, actions: ['find']}],
+ createRole: 'readSessionsCollection',
+ privileges: [{resource: {db: 'config', collection: 'system.sessions'}, actions: ['find']}],
roles: []
});
- assert.commandWorked(result, "couldn't make readAdmin role");
+ assert.commandWorked(result, "couldn't make readSessionsCollection role");
- admin.createUser({user: 'readAdmin', pwd: 'pwd', roles: ['readAdmin']});
+ admin.createUser(
+ {user: 'readSessionsCollection', pwd: 'pwd', roles: ['readSessionsCollection']});
admin.logout();
// Test that we cannot run refreshSessions unauthenticated if --auth is on.
@@ -75,10 +76,12 @@
// Test that once we force a refresh, all of these sessions are in the sessions collection.
admin.logout();
- admin.auth("readAdmin", "pwd");
+ admin.auth("readSessionsCollection", "pwd");
result = admin.runCommand({refreshLogicalSessionCacheNow: 1});
assert.commandWorked(result, "could not force refresh");
- assert.eq(admin.system.sessions.count(), 3, "should have refreshed all session records");
+
+ var config = conn.getDB("config");
+ assert.eq(config.system.sessions.count(), 3, "should have refreshed all session records");
MongoRunner.stopMongod(conn);
})();
diff --git a/jstests/noPassthrough/system_indexes.js b/jstests/noPassthrough/system_indexes.js
index dd27ea4a92d..95f9d90c4a2 100644
--- a/jstests/noPassthrough/system_indexes.js
+++ b/jstests/noPassthrough/system_indexes.js
@@ -6,6 +6,7 @@
(function() {
let conn = MongoRunner.runMongod({smallfiles: ""});
+ let config = conn.getDB("config");
let db = conn.getDB("admin");
// TEST: User and role collections start off with no indexes
@@ -65,15 +66,16 @@
assert.eq(2, db.system.roles.getIndexes().length);
// TEST: Inserting to the sessions collection creates indexes
- assert.eq(0, db.system.sessions.getIndexes().length);
- db.system.sessions.insert({lastUse: new Date()});
- assert.eq(2, db.system.sessions.getIndexes().length);
+ config = conn.getDB("config");
+ assert.eq(0, config.system.sessions.getIndexes().length);
+ config.system.sessions.insert({lastUse: new Date()});
+ assert.eq(2, config.system.sessions.getIndexes().length);
- // TEST: Destroying admin.system.sessions index and restarting will recreate it
- assert.commandWorked(db.system.sessions.dropIndexes());
+ // TEST: Destroying config.system.sessions index and restarting will recreate it
+ assert.commandWorked(config.system.sessions.dropIndexes());
MongoRunner.stopMongod(conn);
conn = MongoRunner.runMongod({restart: conn, cleanData: false});
- db = conn.getDB("admin");
- assert.eq(2, db.system.sessions.getIndexes().length);
+ config = conn.getDB("config");
+ assert.eq(2, config.system.sessions.getIndexes().length);
})();
diff --git a/jstests/noPassthrough/transaction_reaper.js b/jstests/noPassthrough/transaction_reaper.js
index c9a9e992cb2..8fbaae0aed0 100644
--- a/jstests/noPassthrough/transaction_reaper.js
+++ b/jstests/noPassthrough/transaction_reaper.js
@@ -92,7 +92,7 @@
};
Fixture.prototype.assertOutstandingSessions = function(count) {
- assert.eq(count, this.getDB("admin").system.sessions.count());
+ assert.eq(count, this.getDB("config").system.sessions.count());
};
Fixture.prototype.refresh = function() {
@@ -119,7 +119,7 @@
{
var fixture = new Fixture(new Impl(-1));
// Remove a session
- fixture.getDB("admin").system.sessions.remove({});
+ fixture.getDB("config").system.sessions.remove({});
fixture.assertOutstandingTransactions(nSessions);
fixture.assertOutstandingSessions(0);
@@ -134,7 +134,7 @@
{
var fixture = new Fixture(new Impl(30));
// Remove a session
- fixture.getDB("admin").system.sessions.remove({});
+ fixture.getDB("config").system.sessions.remove({});
fixture.assertOutstandingTransactions(nSessions);
fixture.assertOutstandingSessions(0);
diff --git a/jstests/noPassthrough/verify_session_cache_updates.js b/jstests/noPassthrough/verify_session_cache_updates.js
index e9912144e6f..e2d51bd27e5 100644
--- a/jstests/noPassthrough/verify_session_cache_updates.js
+++ b/jstests/noPassthrough/verify_session_cache_updates.js
@@ -8,12 +8,12 @@
function verify(conn, nRecords) {
conn.getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1});
- assert.eq(nRecords, conn.getDB("admin").system.sessions.find({}).count());
+ assert.eq(nRecords, conn.getDB("config").system.sessions.find({}).count());
}
function getLastUse(conn) {
conn.getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1});
- return conn.getDB("admin").system.sessions.findOne({}).lastUse;
+ return conn.getDB("config").system.sessions.findOne({}).lastUse;
}
// initially we have no sessions