mongo/jstests/sharding/test_resharding_test_fixture_using_with_syntax.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

49 lines
1.5 KiB
JavaScript

/**
* Test for the ReshardingTest fixture itself.
*
* Verifies that an uncaught exception in withReshardingInBackground() won't cause the mongo shell
* to abort.
*
* @tags: [
* uses_atclustertime,
* ]
*/
if (_isWindows()) {
jsTest.log("Skipping test on Windows because it makes assumptions about exit codes for" + " std::terminate()");
quit();
}
const awaitShell = startParallelShell(
async function () {
const {ReshardingTest} = await import("jstests/sharding/libs/resharding_test_fixture.js");
const reshardingTest = new ReshardingTest();
reshardingTest.setup();
const ns = "reshardingDb.coll";
const donorShardNames = reshardingTest.donorShardNames;
reshardingTest.createShardedCollection({
ns,
shardKeyPattern: {oldKey: 1},
chunks: [{min: {oldKey: MinKey}, max: {oldKey: MaxKey}, shard: donorShardNames[0]}],
});
const recipientShardNames = reshardingTest.recipientShardNames;
reshardingTest.withReshardingInBackground(
{
newShardKeyPattern: {newKey: 1},
newChunks: [{min: {newKey: MinKey}, max: {newKey: MaxKey}, shard: recipientShardNames[0]}],
},
() => {
throw new Error("Intentionally throwing exception to simulate assertion failure");
},
);
},
undefined,
true,
);
const exitCode = awaitShell({checkExitSuccess: false});
assert.neq(exitCode, 0);
assert.neq(exitCode, MongoRunner.EXIT_ABORT);