summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPV99 <pridhvi.vegesna@mongodb.com>2020-07-28 19:05:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-04 07:22:37 +0000
commit4b967fd6c5e679b33922a4d287755ea987dc882c (patch)
tree7565bdd86fb741d0cc6cfdf49ecc0403e33bdeb8
parent3421f17236e0a0051d398eea42220e4c943d829d (diff)
downloadmongo-4b967fd6c5e679b33922a4d287755ea987dc882c.tar.gz
SERVER-49378 List Commands includes API Version Info
-rw-r--r--jstests/core/version_api_list_commands_verification.js19
-rw-r--r--src/mongo/db/commands/generic.cpp2
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();