Files
mongo/jstests/extensions/extension_serialization.js
Finley Lau bb7e5cdb06 SERVER-111737 Implement query execution serialization for extensions (#42537)
GitOrigin-RevId: 66107ecc3a815824977472888d14ae5185094c85
2025-10-15 17:53:15 +00:00

22 lines
720 B
JavaScript

/**
* Tests that an extension can serialize itself for query execution correctly.
*
* @tags: [featureFlagExtensionsAPI]
*/
import {FixtureHelpers} from "jstests/libs/fixture_helpers.js";
const coll = db[jsTestName()];
coll.drop();
assert.commandWorked(coll.insert({_id: 1}));
// The $shardedExecutionSerialization stage uasserts with the following code in sharded environments.
const kShardedExecutionSerializationCode = 11173701;
{
const pipeline = [{$shardedExecutionSerialization: {}}];
if (FixtureHelpers.isMongos(db)) {
assert.throwsWithCode(() => coll.aggregate(pipeline), kShardedExecutionSerializationCode);
} else {
assert.doesNotThrow(() => coll.aggregate(pipeline));
}
}