diff options
author | Blake Oler <blake.oler@mongodb.com> | 2019-04-09 18:08:53 -0400 |
---|---|---|
committer | Blake Oler <blake.oler@mongodb.com> | 2019-04-16 15:57:30 -0400 |
commit | 29ef1a415c74c883746325f13a8eaaa1831f8102 (patch) | |
tree | 13ce885258c58747b604a226215bdaca535361a5 /jstests | |
parent | e984f9781d2947e3b1fc10ae8535d630c49b5e94 (diff) | |
download | mongo-29ef1a415c74c883746325f13a8eaaa1831f8102.tar.gz |
SERVER-40346 Use AlternativeSessionRegion to insert config documents as retryable write
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/auth/list_all_sessions.js | 10 | ||||
-rw-r--r-- | jstests/noPassthrough/transaction_reaper.js | 5 | ||||
-rw-r--r-- | jstests/noPassthrough/verify_session_cache_updates.js | 2 | ||||
-rw-r--r-- | jstests/sharding/sessions_collection_auto_healing.js | 5 | ||||
-rw-r--r-- | jstests/sharding/verify_sessions_expiration_sharded.js | 39 |
5 files changed, 34 insertions, 27 deletions
diff --git a/jstests/auth/list_all_sessions.js b/jstests/auth/list_all_sessions.js index 1337fc2e94c..7f077bee537 100644 --- a/jstests/auth/list_all_sessions.js +++ b/jstests/auth/list_all_sessions.js @@ -56,16 +56,12 @@ runListAllSessionsTest(mongod); MongoRunner.stopMongod(mongod); - // TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed. - const st = new ShardingTest({ - shards: 1, - mongos: 1, - config: 1, - other: {keyFile: 'jstests/libs/key1', shardAsReplicaSet: false} - }); + const st = + new ShardingTest({shards: 1, mongos: 1, config: 1, other: {keyFile: 'jstests/libs/key1'}}); // Ensure that the sessions collection exists. st.c0.getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1}); + st.rs0.getPrimary().getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1}); runListAllSessionsTest(st.s0); st.stop(); diff --git a/jstests/noPassthrough/transaction_reaper.js b/jstests/noPassthrough/transaction_reaper.js index 71a0977f972..b0574c099c7 100644 --- a/jstests/noPassthrough/transaction_reaper.js +++ b/jstests/noPassthrough/transaction_reaper.js @@ -50,7 +50,10 @@ this.st.s0.getDB("admin").runCommand({shardCollection: "test.test", key: {_id: 1}}); // Ensure that the sessions collection exists. - this.st.c0.getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1}); + assert.commandWorked( + this.st.c0.getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1})); + assert.commandWorked( + this.st.rs0.getPrimary().getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1})); } Sharding.prototype.stop = function() { diff --git a/jstests/noPassthrough/verify_session_cache_updates.js b/jstests/noPassthrough/verify_session_cache_updates.js index 6fb6d36ea7c..48622ba7b95 100644 --- a/jstests/noPassthrough/verify_session_cache_updates.js +++ b/jstests/noPassthrough/verify_session_cache_updates.js @@ -68,6 +68,8 @@ { var st = new ShardingTest({shards: 1, mongos: 1, config: 1}); + st.rs0.getPrimary().getDB("admin").runCommand({refreshLogicalSessionCacheNow: 1}); + runTest(st.s0); st.stop(); } diff --git a/jstests/sharding/sessions_collection_auto_healing.js b/jstests/sharding/sessions_collection_auto_healing.js index a9526628ee0..8d0c91f9d85 100644 --- a/jstests/sharding/sessions_collection_auto_healing.js +++ b/jstests/sharding/sessions_collection_auto_healing.js @@ -116,7 +116,10 @@ load('jstests/libs/sessions_collection.js'); validateSessionsCollection(shard, true, true); - assert.eq(shardConfig.system.sessions.count(), 1, "did not flush config's sessions"); + // We will have two sessions because of the session used in the shardCollection's retryable + // write to shard the sessions collection. It will disappear after we run the refresh + // function on the shard. + assert.eq(shardConfig.system.sessions.count(), 2, "did not flush config's sessions"); // Now, if we do refreshes on the other servers, their in-mem records will // be written to the collection. diff --git a/jstests/sharding/verify_sessions_expiration_sharded.js b/jstests/sharding/verify_sessions_expiration_sharded.js index 3de71e881b2..fe743f147d6 100644 --- a/jstests/sharding/verify_sessions_expiration_sharded.js +++ b/jstests/sharding/verify_sessions_expiration_sharded.js @@ -27,9 +27,11 @@ const startSession = {startSession: 1}; const failPointName = "waitAfterPinningCursorBeforeGetMoreBatch"; - function refreshSessionsAndVerifyCount(config, expectedCount) { - config.runCommand(refresh); - assert.eq(config.system.sessions.count(), expectedCount); + function refreshSessionsAndVerifyCount(mongosConfig, shardConfig, expectedCount) { + mongosConfig.runCommand(refresh); + shardConfig.runCommand(refresh); + + assert.eq(mongosConfig.system.sessions.count(), expectedCount); } function verifyOpenCursorCount(db, expectedCount) { @@ -49,18 +51,19 @@ let mongos = shardingTest.s; let db = mongos.getDB(dbName); - let config = mongos.getDB("config"); + let mongosConfig = mongos.getDB("config"); + let shardConfig = shardingTest.rs0.getPrimary().getDB("config"); // 1. Verify that sessions expire from config.system.sessions after the timeout has passed. for (let i = 0; i < 5; i++) { let res = db.runCommand(startSession); assert.commandWorked(res, "unable to start session"); } - refreshSessionsAndVerifyCount(config, 5); + refreshSessionsAndVerifyCount(mongosConfig, shardConfig, 5); // Manually delete entries in config.system.sessions to simulate TTL expiration. - assert.commandWorked(config.system.sessions.remove({})); - refreshSessionsAndVerifyCount(config, 0); + assert.commandWorked(mongosConfig.system.sessions.remove({})); + refreshSessionsAndVerifyCount(mongosConfig, shardConfig, 0); // 2. Verify that getMores after finds will update the 'lastUse' field on documents in the // config.system.sessions collection. @@ -77,8 +80,8 @@ assert(cursors[i].hasNext()); } - refreshSessionsAndVerifyCount(config, 5); - verifyOpenCursorCount(config, 5); + refreshSessionsAndVerifyCount(mongosConfig, shardConfig, 5); + verifyOpenCursorCount(mongosConfig, 5); let sessionsCollectionArray; let lastUseValues = []; @@ -87,10 +90,10 @@ cursors[j].next(); } - refreshSessionsAndVerifyCount(config, 5); - verifyOpenCursorCount(config, 5); + refreshSessionsAndVerifyCount(mongosConfig, shardConfig, 5); + verifyOpenCursorCount(mongosConfig, 5); - sessionsCollectionArray = getSessions(config); + sessionsCollectionArray = getSessions(mongosConfig); if (i == 0) { for (let j = 0; j < sessionsCollectionArray.length; j++) { @@ -106,10 +109,10 @@ // 3. Verify that letting sessions expire (simulated by manual deletion) will kill their // cursors. - assert.commandWorked(config.system.sessions.remove({})); + assert.commandWorked(mongosConfig.system.sessions.remove({})); - refreshSessionsAndVerifyCount(config, 0); - verifyOpenCursorCount(config, 0); + refreshSessionsAndVerifyCount(mongosConfig, shardConfig, 0); + verifyOpenCursorCount(mongosConfig, 0); for (let i = 0; i < cursors.length; i++) { assert.commandFailedWithCode( @@ -128,10 +131,10 @@ sessionId: pinnedCursorSession, db: pinnedCursorDB, assertFunction: (cursorId, coll) => { - assert.commandWorked(config.system.sessions.remove({})); + assert.commandWorked(mongosConfig.system.sessions.remove({})); + verifyOpenCursorCount(mongosConfig, 1); - verifyOpenCursorCount(config, 1); - refreshSessionsAndVerifyCount(config, 1); + refreshSessionsAndVerifyCount(mongosConfig, shardConfig, 1); let db = coll.getDB(); assert.commandWorked(db.runCommand({killCursors: coll.getName(), cursors: [cursorId]})); |