diff options
-rw-r--r-- | jstests/core/version_api_list_commands_verification.js | 19 | ||||
-rw-r--r-- | src/mongo/db/commands/generic.cpp | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/jstests/core/version_api_list_commands_verification.js b/jstests/core/version_api_list_commands_verification.js new file mode 100644 index 00000000000..8836398e918 --- /dev/null +++ b/jstests/core/version_api_list_commands_verification.js @@ -0,0 +1,19 @@ +/** + * Checks that listCommands returns the API Version information of a command. + * + * @tags: [requires_fcv_46, requires_non_retryable_commands] + */ + +(function() { +"use strict"; + +const resListCommands = db.runCommand({listCommands: 1}); +assert.commandWorked(resListCommands); +const {find, serverStatus, testDeprecation} = resListCommands["commands"]; +assert(JSON.stringify(find.apiVersions) == "[\"1\"]"); +assert(JSON.stringify(find.deprecatedApiVersions) == "[]"); +assert(JSON.stringify(serverStatus.apiVersions) == "[]"); +assert(JSON.stringify(serverStatus.deprecatedApiVersions) == "[]"); +assert(JSON.stringify(testDeprecation.apiVersions) == "[\"1\"]"); +assert(JSON.stringify(testDeprecation.deprecatedApiVersions) == "[\"1\"]"); +})();
\ No newline at end of file diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index 1a52d0f7bfa..19a43f0aa3e 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -184,6 +184,8 @@ public: if (c->secondaryAllowed(opCtx->getServiceContext()) == Command::AllowedOnSecondary::kOptIn) temp.append("slaveOverrideOk", true); + temp.append("apiVersions", c->apiVersions()); + temp.append("deprecatedApiVersions", c->deprecatedApiVersions()); temp.done(); } b.done(); |