Files
mongo/jstests/concurrency/fsm_workloads/explain_count.js
alabid f6a65290f2 SERVER-16648 Additional FSM-based concurrency workloads with some cleanup and blacklisting
Includes workloads for:
    explain
    compact
    reindex
    collMod
    count
    distinct
    touch
    $where
Added to blacklists in FSM runners
Fixed the way we check for storage engines
Added two options for arbitrary function execution against cluster:
    - Specified via ClusterOptions as setupFunctions to be run on the
      cluster before workloads are run
    - As part of setup and teardown with the cluster provided as a third
      argument to these workload functions
2015-02-05 16:14:37 -05:00

60 lines
2.4 KiB
JavaScript

'use strict';
/**
* explain_count.js
*
* Runs explain() and count() on a collection.
*/
load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload
load('jstests/concurrency/fsm_workloads/explain.js'); // for $config
load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongos
load('jstests/libs/analyze_plan.js'); // for planHasStage
var $config = extendWorkload($config, function($config, $super) {
function assertNCounted(num, obj, db) {
var stage = obj.executionStats.executionStages;
// get sharded stage(s) if counting on mongos
if (isMongos(db)) {
stage = stage.shards[0].executionStages;
}
assertWhenOwnColl.eq(num, stage.nCounted);
}
$config.states = Object.extend({
explainBasicCount: function explainBasicCount(db, collName) {
var res = db[collName].explain().count();
assertAlways.commandWorked(res);
assertAlways(planHasStage(res.queryPlanner.winningPlan, 'COUNT'));
},
explainCountHint: function explainCountHint(db, collName) {
assertWhenOwnColl(function() {
var res = db[collName].explain()
.find({ i: this.nInserted / 2 })
.hint({ i: 1 }).count();
assertWhenOwnColl.commandWorked(res);
assertWhenOwnColl(planHasStage(res.queryPlanner.winningPlan, 'COUNT'));
assertWhenOwnColl(planHasStage(res.queryPlanner.winningPlan, 'COUNT_SCAN'));
});
},
explainCountNoSkipLimit: function explainCountNoSkipLimit(db, collName) {
var res = db[collName].explain('executionStats')
.find({ i: this.nInserted }).skip(1).count(false);
assertAlways.commandWorked(res);
assertNCounted(1, res, db);
},
explainCountSkipLimit: function explainCountSkipLimit(db, collName) {
var res = db[collName].explain('executionStats')
.find({ i: this.nInserted }).skip(1).count(true);
assertAlways.commandWorked(res);
assertNCounted(0, res, db);
}
}, $super.states);
$config.transitions = Object.extend({
explain: $config.data.assignEqualProbsToTransitions($config.states)
}, $super.transitions);
return $config;
});