summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2022-02-14 22:25:55 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-14 22:56:39 +0000
commit792eaed783453a5f840112919fc0adb628961d24 (patch)
tree31fe85d55587ca20ac221622ff77148f576b559c
parent216da31cd1184e33c5f32b521030e594a5bb73be (diff)
downloadmongo-792eaed783453a5f840112919fc0adb628961d24.tar.gz
SERVER-63607 Ensure cursor_valid_after_shard_stepdown.js test leaves eligible primaries
-rw-r--r--jstests/sharding/cursor_valid_after_shard_stepdown.js13
-rw-r--r--src/mongo/shell/replsettest.js12
2 files changed, 17 insertions, 8 deletions
diff --git a/jstests/sharding/cursor_valid_after_shard_stepdown.js b/jstests/sharding/cursor_valid_after_shard_stepdown.js
index 2c393091205..7da55c8b378 100644
--- a/jstests/sharding/cursor_valid_after_shard_stepdown.js
+++ b/jstests/sharding/cursor_valid_after_shard_stepdown.js
@@ -1,16 +1,9 @@
-
-// Checking UUID consistency involves talking to the shard primary, but by the end of this test, the
-// shard does not have a primary.
-TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
-TestData.skipCheckOrphans = true;
-
(function() {
'use strict';
var st = new ShardingTest({shards: 1, rs: {nodes: 2}});
assert.commandWorked(st.s0.adminCommand({enablesharding: 'TestDB'}));
-st.ensurePrimaryShard('TestDB', st.shard0.shardName);
assert.commandWorked(st.s0.adminCommand({shardcollection: 'TestDB.TestColl', key: {x: 1}}));
var db = st.s0.getDB('TestDB');
@@ -23,13 +16,17 @@ assert.commandWorked(coll.insert({x: 2, value: 'Test value 2'}));
// Establish a cursor on the primary (by not using secondaryOk read)
var findCursor = assert.commandWorked(db.runCommand({find: 'TestColl', batchSize: 1})).cursor;
+const primary = st.rs0.getPrimary();
+
// Stepdown the primary of the shard and ensure that that cursor can still be read
-assert.commandWorked(st.rs0.getPrimary().adminCommand({replSetStepDown: 60, force: 1}));
+st.rs0.freeze(primary);
var getMoreCursor =
assert.commandWorked(db.runCommand({getMore: findCursor.id, collection: 'TestColl'})).cursor;
assert.eq(0, getMoreCursor.id);
assert.eq(2, getMoreCursor.nextBatch[0].x);
+st.rs0.unfreeze(primary);
+
st.stop();
})();
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 307aa3c1271..6379f2c81b3 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -2965,6 +2965,18 @@ var ReplSetTest = function(opts) {
}, `Failed to run replSetFreeze cmd on ${node.host}`);
}));
+ /**
+ * Unfreeze a particular node or nodes.
+ *
+ * @param node is a single node or list of nodes, by id or conn
+ */
+ this.unfreeze = _nodeParamToSingleNode(_nodeParamToConn(function(node) {
+ // Ensure node is authenticated.
+ asCluster(node, () => {
+ assert.commandWorked(node.adminCommand({replSetFreeze: 0}));
+ });
+ }));
+
this.stopPrimary = function(signal, opts) {
var primary = this.getPrimary();
var primary_id = this.getNodeId(primary);