summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamy Lanka <samy.lanka@mongodb.com>2022-02-03 16:13:48 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-03 17:14:59 +0000
commit038b3ab5b4cc32da116097a256e25105046e1836 (patch)
tree2dfa821966d687e82fc4f3c32a151953a2aa0eb5
parent0e4e2c4a28fee3358ff2f0f0f102f0e8b59185d0 (diff)
downloadmongo-038b3ab5b4cc32da116097a256e25105046e1836.tar.gz
SERVER-61285 Test that the capped parameter for the create command can't be used with apiStrict=true
-rw-r--r--jstests/core/api_version_create.js39
-rw-r--r--src/mongo/db/commands/create.idl2
2 files changed, 41 insertions, 0 deletions
diff --git a/jstests/core/api_version_create.js b/jstests/core/api_version_create.js
new file mode 100644
index 00000000000..e3a4ed00f66
--- /dev/null
+++ b/jstests/core/api_version_create.js
@@ -0,0 +1,39 @@
+/**
+ * Tests the create command with API versioning enabled.
+ *
+ * @tags: [
+ * uses_api_parameters,
+ * ]
+ */
+(function() {
+"use strict";
+
+const testDB = db.getSiblingDB("createAPIVersion");
+testDB.dropDatabase();
+
+// Test the command with 'apiStrict'.
+assert.commandWorked(testDB.runCommand({create: "basicCreate", apiVersion: "1", apiStrict: true}));
+
+// Test the command with 'apiStrict'.
+assert.commandWorked(testDB.runCommand(
+ {create: "basicCreateCappedFalse", capped: false, apiVersion: "1", apiStrict: true}));
+
+// Test that creating a capped collection fails with apiStrict=true.
+assert.commandFailedWithCode(testDB.runCommand({
+ create: "withCappedTrue",
+ capped: true,
+ size: 1000,
+ apiVersion: "1",
+ apiStrict: true,
+}),
+ ErrorCodes.APIStrictError);
+
+// Test that creating a capped collection fails without the size parameter.
+assert.commandFailedWithCode(testDB.runCommand({
+ create: "withCappedTrueNoSize",
+ capped: true,
+ apiVersion: "1",
+ apiStrict: true,
+}),
+ ErrorCodes.InvalidOptions);
+})(); \ No newline at end of file
diff --git a/src/mongo/db/commands/create.idl b/src/mongo/db/commands/create.idl
index a824d3ae167..9ba1e6a82a3 100644
--- a/src/mongo/db/commands/create.idl
+++ b/src/mongo/db/commands/create.idl
@@ -85,6 +85,8 @@ commands:
must also set a maximum size in the 'size' field."
type: safeBool
default: false
+ # The capped parameter should actually be unstable, and in practice it is, because
+ # it is required to also set the 'size' field, which is properly marked as unstable.
unstable: false
autoIndexId:
description: "Specify false to disable the automatic creation of an index on the