jstests/sharding/libs/resharding_test_fixture.js
/**
     * Reshards an existing collection using the specified new shard key and new chunk ranges.
     *
     * @param newChunks - an array of
     * {min: <shardKeyValue0>, max: <shardKeyValue1>, shard: <shardName>} objects. The chunks must
     * form a partition of the {shardKey: MinKey} --> {shardKey: MaxKey} space.
     *
     * @param duringReshardingFn - a function which optionally accepts the temporary resharding
     * namespace string. It is only guaranteed to be called after mongos has started running the
     * reshardCollection command. Callers should use DiscoverTopology.findConnectedNodes() to
     * introspect the state of the donor or recipient shards if they need more specific
     * synchronization.
     *
     * @param expectedErrorCode - the expected response code for the reshardCollection command.
     *
     * @param postCheckConsistencyFn - a function for evaluating additional correctness
     * assertions. This function is called in the critical section, after the `reshardCollection`
     * command has shuffled data, but before the coordinator persists a decision.
     *
     * @param postDecisionPersistedFn - a function for evaluating addition assertions after
     * the decision has been persisted, but before the resharding operation finishes and returns
     * to the client.
     *
     * @param afterReshardingFn - a function that will be called after the resharding operation
     * finishes but before checking the the state post resharding. By the time afterReshardingFn
     * is called the temporary resharding collection will either have been dropped or renamed.
     */
Reshards an existing collection using the specified new shard key and new chunk ranges.
@param newChunks - an array of
{min: , max: , shard: } objects. The chunks must
form a partition of the {shardKey: MinKey} --> {shardKey: MaxKey} space.

@param duringReshardingFn - a function which optionally accepts the temporary resharding
namespace string. It is only guaranteed to be called after mongos has started running the
reshardCollection command. Callers should use DiscoverTopology.findConnectedNodes() to
introspect the state of the donor or recipient shards if they need more specific
synchronization.

@param expectedErrorCode - the expected response code for the reshardCollection command.

@param postCheckConsistencyFn - a function for evaluating additional correctness
assertions. This function is called in the critical section, after the `reshardCollection`
command has shuffled data, but before the coordinator persists a decision.

@param postDecisionPersistedFn - a function for evaluating addition assertions after
the decision has been persisted, but before the resharding operation finishes and returns
to the client.

@param afterReshardingFn - a function that will be called after the resharding operation
finishes but before checking the the state post resharding. By the time afterReshardingFn
is called the temporary resharding collection will either have been dropped or renamed.
Reshards an existing collection using the specified new shard key and new chunk ranges . @param newChunks - an array of { min : max : shard : } objects . The chunks must form a partition of the { shardKey : MinKey } -- > { shardKey : MaxKey } space . @param duringReshardingFn - a function which optionally accepts the temporary resharding namespace string . It is only guaranteed to be called after mongos has started running the reshardCollection command . Callers should use DiscoverTopology . findConnectedNodes () to introspect the state of the donor or recipient shards if they need more specific synchronization . @param expectedErrorCode - the expected response code for the reshardCollection command . @param postCheckConsistencyFn - a function for evaluating additional correctness assertions . This function is called in the critical section after the ` reshardCollection ` command has shuffled data but before the coordinator persists a decision . @param postDecisionPersistedFn - a function for evaluating addition assertions after the decision has been persisted but before the resharding operation finishes and returns to the client . @param afterReshardingFn - a function that will be called after the resharding operation finishes but before checking the the state post resharding . By the time afterReshardingFn is called the temporary resharding collection will either have been dropped or renamed .
withReshardingInBackground({newShardKeyPattern, newChunks},
                               duringReshardingFn = (tempNs) => {},
                               {
                                   expectedErrorCode = ErrorCodes.OK,
                                   postCheckConsistencyFn = (tempNs) => {},
                                   postDecisionPersistedFn = () => {},
                                   afterReshardingFn = () => {}
                               } = {}) {
        this._startReshardingInBackgroundAndAllowCommandFailure({newShardKeyPattern, newChunks},
                                                                expectedErrorCode);
        assert.soon(() => {
            const op = this._findReshardingCommandOp();
            return op !== undefined || this._commandDoneSignal.getCount() === 0;
        }, "failed to find reshardCollection in $currentOp output");
        this._callFunctionSafely(() => duringReshardingFn(this._tempNs));
        this._checkConsistencyAndPostState(expectedErrorCode,
                                           () => postCheckConsistencyFn(this._tempNs),
                                           () => postDecisionPersistedFn(),
                                           () => afterReshardingFn());
    }
withReshardingInBackground ( { newShardKeyPattern , newChunks } , duringReshardingFn = ( tempNs ) => { } , { expectedErrorCode = ErrorCodes . OK , postCheckConsistencyFn = ( tempNs ) => { } , postDecisionPersistedFn = ( ) => { } , afterReshardingFn = ( ) => { } } = { } ) { this . _startReshardingInBackgroundAndAllowCommandFailure ( { newShardKeyPattern , newChunks } , expectedErrorCode ) ; assert . soon ( ( ) => { const op = this . _findReshardingCommandOp ( ) ; return op !== undefined || this . _commandDoneSignal . getCount ( ) === 0 ; } , "failed to find reshardCollection in $currentOp output" ) ; this . _callFunctionSafely ( ( ) => duringReshardingFn ( this . _tempNs ) ) ; this . _checkConsistencyAndPostState ( expectedErrorCode , ( ) => postCheckConsistencyFn ( this . _tempNs ) , ( ) => postDecisionPersistedFn ( ) , ( ) => afterReshardingFn ( ) ) ; }
Reshards an existing collection using the specified new shard key and new chunk ranges.
Reshards an existing collection using the specified new shard key and new chunk ranges .