jstests/concurrency/fsm_workloads/rename_sharded_collection.js
/*
 * Initialize a collection with expected number of chunks/documents and randomly distribute chunks
 */
Initialize a collection with expected number of chunks/documents and randomly distribute chunks
Initialize a collection with expected number of chunks / documents and randomly distribute chunks
function initAndFillShardedCollection(db, collName, shardNames) {
    const coll = db[collName];
    const ns = coll.getFullName();
    db.adminCommand({shardCollection: ns, key: {x: 1}});
    var nextShardKeyValue = 0;
    for (var i = 0; i < numChunks; i++) {
        for (var j = 0; j < documentsPerChunk; j++) {
            coll.insert({x: nextShardKeyValue++});
        }
        assert.commandWorked(db.adminCommand({split: ns, middle: {x: nextShardKeyValue}}));
        const lastInsertedShardKeyValue = nextShardKeyValue - 1;
        const res = db.adminCommand({
            moveChunk: ns,
            find: {x: lastInsertedShardKeyValue},
            to: shardNames[Random.randInt(shardNames.length)],
        });
        assert.commandWorkedOrFailedWithCode(res, ErrorCodes.ConflictingOperationInProgress);
    }
}
function initAndFillShardedCollection ( db , collName , shardNames ) { const coll = db [ collName ] ; const ns = coll . getFullName ( ) ; db . adminCommand ( { shardCollection : ns , key : { x : 1 } } ) ; var nextShardKeyValue = 0 ; for ( var i = 0 ; i < numChunks ; i ++ ) { for ( var j = 0 ; j < documentsPerChunk ; j ++ ) { coll . insert ( { x : nextShardKeyValue ++ } ) ; } assert . commandWorked ( db . adminCommand ( { split : ns , middle : { x : nextShardKeyValue } } ) ) ; const lastInsertedShardKeyValue = nextShardKeyValue - 1 ; const res = db . adminCommand ( { moveChunk : ns , find : { x : lastInsertedShardKeyValue } , to : shardNames [ Random . randInt ( shardNames . length ) ] , } ) ; assert . commandWorkedOrFailedWithCode ( res , ErrorCodes . ConflictingOperationInProgress ) ; } }
Initialize a collection with expected number of chunks/documents and randomly distribute chunks
Initialize a collection with expected number of chunks / documents and randomly distribute chunks
// When balancer is enabled, move chunks could overlap and fail with // ConflictingOperationInProgress