We could add this testing to an existing jstest, database_and_shard_versioning_all_commands.js.
The test currently loops over all commands, sends the command through mongos, and checks that mongos attached a databaseVersion.
We could split the test case description for each command into "run" and "explain", e.g.:
aggregate: {
sendsDbVersion: true,
sendsShardVersion: true,
command: {aggregate: collName, pipeline: [{$match: {x: 1}}], cursor: {batchSize: 10}},
},
becomes
aggregate: {
run: {
sendsDbVersion: true,
sendsShardVersion: true,
command: {aggregate: collName, pipeline: [{$match: {x: 1}}], cursor: {batchSize: 10}},
},
explain: {
sendsDbVersion: <true|false>
sendsShardVersion: <true|false>
command: {aggregate: collName, pipeline: [{$match: {x: 1}}], cursor: {batchSize: 10}, explain: true}
}
},