diff options
author | Ian Boros <ian.boros@mongodb.com> | 2021-04-15 11:29:59 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-20 19:59:38 +0000 |
commit | 89e2a97e9ff9c42a1a10ea3e1fcd6c5fbe3b0dfb (patch) | |
tree | 909542c673409041cca82ffc07936c0f3e40eda4 /jstests | |
parent | 634df88202bc43cfa7c4b84cb3e23dca01d39262 (diff) | |
download | mongo-89e2a97e9ff9c42a1a10ea3e1fcd6c5fbe3b0dfb.tar.gz |
SERVER-55623 Fix covered shard filtering on hashed indexes in SBE
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/idhack.js | 6 | ||||
-rw-r--r-- | jstests/libs/sbe_util.js | 23 |
2 files changed, 25 insertions, 4 deletions
diff --git a/jstests/core/idhack.js b/jstests/core/idhack.js index 3a022a1c823..bdfe4d4da08 100644 --- a/jstests/core/idhack.js +++ b/jstests/core/idhack.js @@ -12,11 +12,9 @@ t.drop(); // Include helpers for analyzing explain output. load("jstests/libs/analyze_plan.js"); load("jstests/libs/sbe_explain_helpers.js"); +load("jstests/libs/sbe_util.js"); -const isSBEEnabled = (() => { - const getParam = db.adminCommand({getParameter: 1, featureFlagSBE: 1}); - return getParam.hasOwnProperty("featureFlagSBE") && getParam.featureFlagSBE.value; -})(); +const isSBEEnabled = checkSBEEnabled(db); assert.commandWorked(t.insert({_id: {x: 1}, z: 1})); assert.commandWorked(t.insert({_id: {x: 2}, z: 2})); diff --git a/jstests/libs/sbe_util.js b/jstests/libs/sbe_util.js new file mode 100644 index 00000000000..669b29661f9 --- /dev/null +++ b/jstests/libs/sbe_util.js @@ -0,0 +1,23 @@ +/* + * Utilities for checking whether SBE is enabled. + */ + +load("jstests/libs/discover_topology.js"); // For findNonConfigNodes. +load("jstests/libs/fixture_helpers.js"); // For 'isMongos' + +function checkSBEEnabled(theDB) { + const nodes = DiscoverTopology.findNonConfigNodes(theDB.getMongo()); + + for (const node of nodes) { + // Find a non-mongos node and check whether its SBE feature flag is on. We assume either + // all nodes in the cluster have SBE on or none. + const conn = new Mongo(nodes[0]); + if (FixtureHelpers.isMongos(conn.getDB("admin"))) { + continue; + } + + const getParam = conn.adminCommand({getParameter: 1, featureFlagSBE: 1}); + return getParam.hasOwnProperty("featureFlagSBE") && getParam.featureFlagSBE.value; + } + assert(false, "Couldn't find mongod"); +} |