diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-08-10 15:02:41 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2017-08-10 17:38:54 -0400 |
commit | e1978af38dff725f0a0a60bca39a21b072751218 (patch) | |
tree | e2e4dcb138db49bbe2e069497ecb19ed753825a8 /jstests/noPassthrough/refresh_logical_session_cache_now.js | |
parent | 1e1d27c271431f24cddcd2339151d7215c1178d1 (diff) | |
download | mongo-e1978af38dff725f0a0a60bca39a21b072751218.tar.gz |
SERVER-29202 Add a refreshLogicalSessionCacheNow test command
Diffstat (limited to 'jstests/noPassthrough/refresh_logical_session_cache_now.js')
-rw-r--r-- | jstests/noPassthrough/refresh_logical_session_cache_now.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/jstests/noPassthrough/refresh_logical_session_cache_now.js b/jstests/noPassthrough/refresh_logical_session_cache_now.js new file mode 100644 index 00000000000..e3fe583f074 --- /dev/null +++ b/jstests/noPassthrough/refresh_logical_session_cache_now.js @@ -0,0 +1,44 @@ +(function() { + "use script"; + + var res; + var refresh = {refreshLogicalSessionCacheNow: 1}; + var startSession = {startSession: 1}; + + // Start up a standalone server. + var conn = MongoRunner.runMongod({nojournal: ""}); + var admin = conn.getDB("admin"); + + // Trigger an initial refresh, as a sanity check. + res = admin.runCommand(refresh); + assert.commandWorked(res, "failed to refresh"); + + // Start a session. Should not be in the collection yet. + res = admin.runCommand(startSession); + assert.commandWorked(res, "unable to start session"); + + assert.eq(admin.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"); + + // Start some new sessions. Should not be in the collection yet. + var numSessions = 100; + for (var i = 0; i < numSessions; i++) { + res = admin.runCommand(startSession); + assert.commandWorked(res, "unable to start session"); + } + + assert.eq(admin.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"); + +}()); |