diff --git a/jstests/sharding/libs/resharding_test_fixture.js b/jstests/sharding/libs/resharding_test_fixture.js
|
index 5bfde1c09b..2b2304cadf 100644
|
--- a/jstests/sharding/libs/resharding_test_fixture.js
|
+++ b/jstests/sharding/libs/resharding_test_fixture.js
|
@@ -90,7 +90,10 @@ var ReshardingTest = class {
|
setup() {
|
const mongosOptions = {setParameter: {}};
|
const configOptions = {setParameter: {}};
|
- const rsOptions = {setParameter: {}};
|
+ // XXX: Make this configurable by an argument to the ReshardingTest constructor or make
|
+ // resharding_critical_section_ttl_monitor.js not depend on the TTL monitor being disabled
|
+ // at startup.
|
+ const rsOptions = {setParameter: {ttlMonitorEnabled: false, ttlMonitorSleepSecs: 1}};
|
|
if (this._minimumOperationDurationMS !== undefined) {
|
configOptions.setParameter.reshardingMinimumOperationDurationMillis =
|
diff --git a/jstests/sharding/resharding_critical_section_ttl_monitor.js b/jstests/sharding/resharding_critical_section_ttl_monitor.js
|
new file mode 100644
|
index 0000000000..5eb91cbc9a
|
--- /dev/null
|
+++ b/jstests/sharding/resharding_critical_section_ttl_monitor.js
|
@@ -0,0 +1,49 @@
|
+(function() {
|
+"use strict";
|
+
|
+load("jstests/libs/discover_topology.js");
|
+load("jstests/sharding/libs/resharding_test_fixture.js");
|
+
|
+const reshardingTest = new ReshardingTest();
|
+
|
+reshardingTest.setup();
|
+
|
+const donorShardNames = reshardingTest.donorShardNames;
|
+const sourceCollection = reshardingTest.createShardedCollection({
|
+ ns: "reshardingDb.coll",
|
+ shardKeyPattern: {oldKey: 1},
|
+ chunks: [{min: {oldKey: MinKey}, max: {oldKey: MaxKey}, shard: donorShardNames[0]}],
|
+});
|
+
|
+const numDocs = 5;
|
+assert.commandWorked(sourceCollection.insert(
|
+ Array.from({length: numDocs}, (_, i) => ({oldKey: i, newKey: i, time: new Date(0)}))));
|
+
|
+assert.commandWorked(sourceCollection.createIndex({time: 1}, {expireAfterSeconds: 0}));
|
+
|
+const mongos = sourceCollection.getMongo();
|
+const topology = DiscoverTopology.findConnectedNodes(mongos);
|
+const donor0 = new Mongo(topology.shards[donorShardNames[0]].primary);
|
+
|
+const recipientShardNames = reshardingTest.recipientShardNames;
|
+reshardingTest.withReshardingInBackground( //
|
+ {
|
+ newShardKeyPattern: {newKey: 1},
|
+ newChunks: [{min: {newKey: MinKey}, max: {newKey: MaxKey}, shard: recipientShardNames[0]}],
|
+ },
|
+ () => {},
|
+ {
|
+ postCheckConsistencyFn: () => {
|
+ assert.eq(sourceCollection.find().itcount(), numDocs);
|
+ assert.commandWorked(donor0.adminCommand({setParameter: 1, ttlMonitorEnabled: true}));
|
+ assert.soon(() => {
|
+ const serverStatus = assert.commandWorked(donor0.adminCommand({serverStatus: 1}));
|
+ return serverStatus.metrics.ttl.passes >= 1;
|
+ }, "timed out waiting for the TTL monitor to run");
|
+
|
+ reshardingTest._checkConsistency();
|
+ }
|
+ });
|
+
|
+reshardingTest.teardown();
|
+})();
|