summaryrefslogtreecommitdiff
path: root/jstests/sharding/test_resharding_test_fixture_using_with_syntax.js
blob: 9a028bb88253ae626d5a48fcaa66e4481d9661de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * Test for the ReshardingTest fixture itself.
 *
 * Verifies that an uncaught exception in withReshardingInBackground() won't cause the mongo shell
 * to abort.
 *
 * @tags: [
 *   uses_atclustertime,
 * ]
 */
(function() {
"use strict";

if (_isWindows()) {
    jsTest.log("Skipping test on Windows because it makes assumptions about exit codes for" +
               " std::terminate()");
    return;
}

const awaitShell = startParallelShell(function() {
    load("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);
})();