While working on
SERVER-25875, it became evident that to adequately test the CommitChunkMigration command with JS testing requires cumbersome failpoint additions. Continuing to add failpoints would make future changes increasingly difficult. Unit testing is far more appropriate in this case than adding failpoints and JS test setup in order to mimic unit testing.
As part of this ticket, the code from the CommitChunkMigration command should be moved to be a commitChunkMigration method on ShardingCatalogManager with the following parameters:
- Collection namespace
- Migrated chunk - ChunkType
- Control chunk (optional) - ChunkType
- From shard - ShardId
- To shard - ShardId
The current parameters fromShardCollectionVersion and shardHasDistributedLock will be removed in place of the exact chunk version being transmitted and the newly written unit-tests.
In addition to the change above, unit-tests must be implemented similar to what we do for split and merge. The following test case should be included:
- Correctly migrating a chunk
- Correctly migrating the last chunk from a shard (i.e., there is no control chunk)
- The expected chunk version does not match
- The expected chunk epoch does not match
- The from shard does not match