jstests/ssl/libs/ssl_helpers.js
/**
 * Takes in two mongod/mongos configuration options and runs a basic
 * sharding test to see if they can work together...
 */
Takes in two mongod/mongos configuration options and runs a basic
sharding test to see if they can work together
Takes in two mongod / mongos configuration options and runs a basic sharding test to see if they can work together
function mixedShardTest(options1, options2, shouldSucceed) {
    try {
        var st = new ShardingTest({
            mongos : [options1],
            config : [options1],
            shards : [options1, options2]
        });
        st.stopBalancer();
        var r = st.adminCommand({enableSharding: "test"});
        assert.eq(r, true, "error enabling sharding for this configuration");
        r = st.adminCommand({ movePrimary: 'test', to: 'shard0001' });
        var db1 = st.getDB("test");
        r = st.adminCommand({ shardCollection : "test.col" , key : { _id : 1 } });
        assert.eq(r, true, "error sharding collection for this configuration");
        var bigstr = Array(1024*1024).join("#");
        var bulk = db1.col.initializeUnorderedBulkOp();
        for(var i = 0; i < 128; i++){
            bulk.insert({ _id: i, string: bigstr });
        }
        assert.writeOK(bulk.execute());
        assert.eq(128, db1.col.count(), "error retrieving documents from cluster");
        r = st.getDB('test').adminCommand({ moveChunk: 'test.col',
                                            find: { _id: 0 }, to: 'shard0000' });
        assert(r.ok, "error moving chunks: " + tojson(r));
        db1.col.remove({});
    } catch(e) {
        if (shouldSucceed) throw e;
        print("IMPORTANT! => Test failed when it should have failed...continuing...");
    } finally {
        if(st) {
            st.stop();
        }
    }
}
function mixedShardTest ( options1 , options2 , shouldSucceed ) { try { var st = new ShardingTest ( { mongos : [ options1 ] , config : [ options1 ] , shards : [ options1 , options2 ] } ) ; st . stopBalancer ( ) ; var r = st . adminCommand ( { enableSharding : "test" } ) ; assert . eq ( r , true , "error enabling sharding for this configuration" ) ; r = st . adminCommand ( { movePrimary : 'test' , to : 'shard0001' } ) ; var db1 = st . getDB ( "test" ) ; r = st . adminCommand ( { shardCollection : "test.col" , key : { _id : 1 } } ) ; assert . eq ( r , true , "error sharding collection for this configuration" ) ; var bigstr = Array ( 1024 * 1024 ) . join ( "#" ) ; var bulk = db1 . col . initializeUnorderedBulkOp ( ) ; for ( var i = 0 ; i < 128 ; i ++ ) { bulk . insert ( { _id : i , string : bigstr } ) ; } assert . writeOK ( bulk . execute ( ) ) ; assert . eq ( 128 , db1 . col . count ( ) , "error retrieving documents from cluster" ) ; r = st . getDB ( 'test' ) . adminCommand ( { moveChunk : 'test.col' , find : { _id : 0 } , to : 'shard0000' } ) ; assert ( r . ok , "error moving chunks: " + tojson ( r ) ) ; db1 . col . remove ( { } ) ; } catch ( e ) { if ( shouldSucceed ) throw e ; print ( "IMPORTANT! => Test failed when it should have failed...continuing..." ) ; } finally { if ( st ) { st . stop ( ) ; } } }
Takes in two mongod/mongos configuration options and runs a basic
 sharding test to see if they can work together...
Takes in two mongod / mongos configuration options and runs a basic sharding test to see if they can work together ...
// Test mongos talking to config servers // Test mongos talking to shards // Test shards talking to each other //silence error if we should fail... // This has to be done in order for failure // to not prevent future tests from running...