SERVER-113895: Perform range-based and compound shard key testing for productionized orphan deleter script (#44114)

GitOrigin-RevId: a4b98b9ab9fe4b351c7be6b61e662a99ef7b7b58
This commit is contained in:
David Chen 2025-12-08 17:19:02 -05:00 committed by MongoDB Bot
parent 204229bf94
commit 97ea8de07f
1 changed files with 22 additions and 0 deletions

View File

@ -100,3 +100,25 @@ export function isSlowBuild(conn) {
(rawBuildInfo.hasOwnProperty("buildEnvironment") && rawBuildInfo.buildEnvironment.target_os == "windows")
);
}
/**
* Builds a MinKey or MaxKey object based on shard key structure.
* @param {Object} shardKey - The shard key pattern object (e.g., {x: 1, y: 1})
* @param {Object} keyType - Either MinKey or MaxKey
* @returns {Object} An object with the same keys as shardKey, but values set to keyType
*/
export function buildShardKeyBoundary(shardKey, keyType) {
const boundary = {};
Object.keys(shardKey).forEach((key) => {
boundary[key] = keyType;
});
return boundary;
}
export function buildMinKey(shardKey) {
return buildShardKeyBoundary(shardKey, MinKey);
}
export function buildMaxKey(shardKey) {
return buildShardKeyBoundary(shardKey, MaxKey);
}