jstests/sharding/balancing_sessions_collection.js
/*
 * Starts a replica-set shard, adds the shard to the cluster, and increments numShards.
 * Returns the ReplSetTest object for the shard.
 */
Starts a replica-set shard, adds the shard to the cluster, and increments numShards.
Returns the ReplSetTest object for the shard.
Starts a replica - set shard adds the shard to the cluster and increments numShards . Returns the ReplSetTest object for the shard .
function addShardToCluster() {
    const shardName = clusterName + "-rs" + numShards;
    const replTest = new ReplSetTest({name: shardName, nodes: 1});
    replTest.startSet({shardsvr: ""});
    replTest.initiate();
    assert.commandWorked(st.s.adminCommand({addShard: replTest.getURL(), name: shardName}));
    numShards++;
    return replTest;
}
function addShardToCluster ( ) { const shardName = clusterName + "-rs" + numShards ; const replTest = new ReplSetTest ( { name : shardName , nodes : 1 } ) ; replTest . startSet ( { shardsvr : "" } ) ; replTest . initiate ( ) ; assert . commandWorked ( st . s . adminCommand ( { addShard : replTest . getURL ( ) , name : shardName } ) ) ; numShards ++ ; return replTest ; }
Starts a replica-set shard, adds the shard to the cluster, and increments numShards.
Starts a replica - set shard adds the shard to the cluster and increments numShards .