0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-27 23:27:11 +01:00
mongodb/jstests/noPassthrough/currentop_target_all_nodes.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

30 lines
1.0 KiB
JavaScript

// Tests that the $currentOp works as expected when run with the targetAllNodes option turned on and
// off.
//
// @tags: [
// requires_fcv_71,
// ]
import {ShardingTest} from "jstests/libs/shardingtest.js";
const shardCount = 2;
const rsNodesPerShardCount = 2;
const st = new ShardingTest({shards: shardCount, rs: {nodes: rsNodesPerShardCount}});
const clusterAdminDB = st.s.getDB("admin");
function runCurrentOpAgg(shouldTargetAllNodes) {
return clusterAdminDB.aggregate(
[
{$currentOp: {targetAllNodes: shouldTargetAllNodes}},
{$match: {"command.comment": "issuing a currentOp with targetAllNodes"}}
],
{comment: "issuing a currentOp with targetAllNodes"});
}
const targetAllNodesFalse = runCurrentOpAgg(false);
assert.eq(shardCount, targetAllNodesFalse.itcount(), tojson(targetAllNodesFalse));
const targetAllNodesTrue = runCurrentOpAgg(true);
assert.eq(
shardCount * rsNodesPerShardCount, targetAllNodesTrue.itcount(), tojson(targetAllNodesTrue));
st.stop();