jstests/sharding/timeseries_multiple_mongos.js
// Validate the command by running against 'mongos1' as the router.
Validate the command by running against 'mongos1' as the router.
Validate the command by running against ' mongos1 ' as the router .
function validateCommand(cmdCollName, numEntries, unVersioned) {
        for (let shardDB of [shard0DB, shard1DB]) {
            shardDB.setProfilingLevel(0);
            shardDB.system.profile.drop();
            shardDB.setProfilingLevel(2);
        }
        const res = mongos1.runCommand(cmdObj);
        if (numEntries > 0) {
            assert.commandWorked(res);
        } else {
            assert.commandFailed(res);
        }
        const queryField = `command.${Object.keys(cmdObj)[0]}`;
        let filter = {
            [queryField]: cmdCollName,
            "$or": [
                {
                    "$and": [
                        {"command.shardVersion.0": {"$exists": true}},
                        {
                            "command.shardVersion.0":
                                {$ne: ShardVersioningUtil.kIgnoredShardVersion[0]}
                        },
                    ]
                },
                {
                    "$and": [
                        {"command.shardVersion.v": {"$exists": true}},
                        {
                            "command.shardVersion.v":
                                {$ne: ShardVersioningUtil.kIgnoredShardVersion[0]}
                        },
                    ]
                },
            ]
        };
        if (isUpdate) {
            filter = {"op": "update", "ns": `${dbName}.${cmdCollName}`, "ok": {$ne: 0}};
        } else if (isDelete) {
            filter = {"op": "remove", "ns": `${dbName}.${cmdCollName}`, "ok": {$ne: 0}};
        } else if (isCollMod) {
            const command = unVersioned ? "_shardsvrCollMod" : "_shardsvrCollModParticipant";
            filter = {[`command.${command}`]: cmdCollName, "ok": {$ne: 0}};
        } else if (unVersioned && !isCollMod) {
            filter = {
                [queryField]: cmdCollName,
                "$or": [
                    {"command.shardVersion.0": ShardVersioningUtil.kIgnoredShardVersion[0]},
                    {"command.shardVersion.v": ShardVersioningUtil.kIgnoredShardVersion[0]},
                ]
            };
        }
        filter["command.pipeline.0.$indexStats"] = {$exists: false};
        const shard0Entries = shard0DB.system.profile.find(filter).toArray();
        const shard1Entries = shard1DB.system.profile.find(filter).toArray();
        assert.eq(shard0Entries.length + shard1Entries.length,
                  numEntries,
                  {shard0Entries: shard0Entries, shard1Entries: shard1Entries});
    }
function validateCommand ( cmdCollName , numEntries , unVersioned ) { for ( let shardDB of [ shard0DB , shard1DB ] ) { shardDB . setProfilingLevel ( 0 ) ; shardDB . system . profile . drop ( ) ; shardDB . setProfilingLevel ( 2 ) ; } const res = mongos1 . runCommand ( cmdObj ) ; if ( numEntries > 0 ) { assert . commandWorked ( res ) ; } else { assert . commandFailed ( res ) ; } const queryField = ` ${ Object . keys ( cmdObj ) [ 0 ] } ` ; let filter = { [ queryField ] : cmdCollName , "$or" : [ { "$and" : [ { "command.shardVersion.0" : { "$exists" : true } } , { "command.shardVersion.0" : { $ne : ShardVersioningUtil . kIgnoredShardVersion [ 0 ] } } , ] } , { "$and" : [ { "command.shardVersion.v" : { "$exists" : true } } , { "command.shardVersion.v" : { $ne : ShardVersioningUtil . kIgnoredShardVersion [ 0 ] } } , ] } , ] } ; if ( isUpdate ) { filter = { "op" : "update" , "ns" : ` ${ dbName } ${ cmdCollName } ` , "ok" : { $ne : 0 } } ; } else if ( isDelete ) { filter = { "op" : "remove" , "ns" : ` ${ dbName } ${ cmdCollName } ` , "ok" : { $ne : 0 } } ; } else if ( isCollMod ) { const command = unVersioned ? "_shardsvrCollMod" : "_shardsvrCollModParticipant" ; filter = { [ ` ${ command } ` ] : cmdCollName , "ok" : { $ne : 0 } } ; } else if ( unVersioned && ! isCollMod ) { filter = { [ queryField ] : cmdCollName , "$or" : [ { "command.shardVersion.0" : ShardVersioningUtil . kIgnoredShardVersion [ 0 ] } , { "command.shardVersion.v" : ShardVersioningUtil . kIgnoredShardVersion [ 0 ] } , ] } ; } filter [ "command.pipeline.0.$indexStats" ] = { $exists : false } ; const shard0Entries = shard0DB . system . profile . find ( filter ) . toArray ( ) ; const shard1Entries = shard1DB . system . profile . find ( filter ) . toArray ( ) ; assert . eq ( shard0Entries . length + shard1Entries . length , numEntries , { shard0Entries : shard0Entries , shard1Entries : shard1Entries } ) ; }
Validate the command by running against 'mongos1' as the router.
Validate the command by running against ' mongos1 ' as the router .
// Restart profiler. // We currently do not log 'shardVersion' for updates. See SERVER-60354 for details. // Filter out the profiler entries with $indexStats pipeline stage, as the // PeriodicShardedIndexConsistencyChecker can issue an aggregate command with // '[$indexStats: {}]' pipeline periodically. We don't want these entries to be accounted // here.