jstests/libs/write_concern_util.js
// Shards a collection with 'numDocs' documents and creates 2 chunks, one on each of two shards.
Shards a collection with 'numDocs' documents and creates 2 chunks, one on each of two shards.
Shards a collection with ' numDocs ' documents and creates 2 chunks one on each of two shards .
function shardCollectionWithChunks(st, coll, numDocs) {
    var _db = coll.getDB();
    var numberDoc = numDocs || 20;
    coll.createIndex({x: 1}, {unique: true});
    st.ensurePrimaryShard(_db.toString(), st.shard0.shardName);
    st.shardColl(
        coll.getName(), {x: 1}, {x: numberDoc / 2}, {x: numberDoc / 2}, _db.toString(), true);
    for (var i = 0; i < numberDoc; i++) {
        coll.insert({x: i});
    }
    assert.eq(coll.count(), numberDoc);
}
function shardCollectionWithChunks ( st , coll , numDocs ) { var _db = coll . getDB ( ) ; var numberDoc = numDocs || 20 ; coll . createIndex ( { x : 1 } , { unique : true } ) ; st . ensurePrimaryShard ( _db . toString ( ) , st . shard0 . shardName ) ; st . shardColl ( coll . getName ( ) , { x : 1 } , { x : numberDoc / 2 } , { x : numberDoc / 2 } , _db . toString ( ) , true ) ; for ( var i = 0 ; i < numberDoc ; i ++ ) { coll . insert ( { x : i } ) ; } assert . eq ( coll . count ( ) , numberDoc ) ; }
Shards a collection with 'numDocs' documents and creates 2 chunks, one on each of two shards.
Shards a collection with ' numDocs ' documents and creates 2 chunks one on each of two shards .