summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorRomans Kasperovics <romans.kasperovics@mongodb.com>2022-01-06 22:16:50 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-06 22:47:00 +0000
commit9ce5ff8c50813185e3c7c4351ca775461022ca0e (patch)
treed5a85fc8c4059fe58060067dace250ca7a2df678 /buildscripts
parentd9f48866389096561f9d2582de141e068928f1d6 (diff)
downloadmongo-9ce5ff8c50813185e3c7c4351ca775461022ca0e.tar.gz
SERVER-60349 Allow adding optionalBool fields in IDL compatibility check
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/idl/idl_check_compatibility.py21
-rw-r--r--buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl43
-rw-r--r--buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl36
3 files changed, 92 insertions, 8 deletions
diff --git a/buildscripts/idl/idl_check_compatibility.py b/buildscripts/idl/idl_check_compatibility.py
index 7cd8a7c1324..1b9568c31f5 100644
--- a/buildscripts/idl/idl_check_compatibility.py
+++ b/buildscripts/idl/idl_check_compatibility.py
@@ -575,7 +575,8 @@ def check_reply_fields(ctxt: IDLCompatibilityContext, old_reply: syntax.Struct,
if isinstance(new_field_type,
syntax.Type) and "any" in new_field_type.bson_serialization_type:
# If 'any' is not explicitly allowed as the bson_serialization_type.
- if allow_name not in ALLOW_ANY_TYPE_LIST:
+ any_allow = allow_name in ALLOW_ANY_TYPE_LIST or new_field_type.name == 'optionalBool'
+ if not any_allow:
ctxt.add_reply_field_bson_any_not_allowed_error(
cmd_name, new_field.name, new_field_type.name, new_idl_file_path)
@@ -864,19 +865,23 @@ def check_command_params_or_type_struct_fields(
if new_field.name == old_field.name:
newly_added = False
- if newly_added and not new_field.optional and not new_field.unstable:
- ctxt.add_new_param_or_command_type_field_added_required_error(
- cmd_name, new_field.name, new_idl_file_path, new_struct.name, is_command_parameter)
-
- # Check that a new field does not have an unallowed use of 'any' as the bson_serialization_type.
if newly_added:
+ new_field_type = get_field_type(new_field, new_idl_file, new_idl_file_path)
+ new_field_optional = new_field.optional or (new_field_type
+ and new_field_type.name == 'optionalBool')
+ if not new_field_optional and not new_field.unstable:
+ ctxt.add_new_param_or_command_type_field_added_required_error(
+ cmd_name, new_field.name, new_idl_file_path, new_struct.name,
+ is_command_parameter)
+
+ # Check that a new field does not have an unallowed use of 'any' as the bson_serialization_type.
any_allow_name: str = (cmd_name + "-param-" + new_field.name
if is_command_parameter else cmd_name)
- new_field_type = get_field_type(new_field, new_idl_file, new_idl_file_path)
if isinstance(new_field_type,
syntax.Type) and "any" in new_field_type.bson_serialization_type:
# If 'any' is not explicitly allowed as the bson_serialization_type.
- if any_allow_name not in ALLOW_ANY_TYPE_LIST:
+ any_allow = any_allow_name in ALLOW_ANY_TYPE_LIST or new_field_type.name == 'optionalBool'
+ if not any_allow:
ctxt.add_command_or_param_type_bson_any_not_allowed_error(
cmd_name, new_field_type.name, old_idl_file_path, new_field.name,
is_command_parameter)
diff --git a/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl b/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl
index 2bffaae0a2d..830f533b990 100644
--- a/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl
+++ b/buildscripts/idl/tests/compatibility_test_pass/new/compatibility_test_pass_new.idl
@@ -474,6 +474,17 @@ structs:
chained_structs:
StructCommandParameterTypeRecursive: StructCommandParameterTypeRecursive
+ NewOptionalBoolStruct:
+ description: "This struct gets another field of type optionalBool."
+ fields:
+ ok1:
+ type: bool
+ unstable: false
+ optional: true
+ ok2:
+ type: optionalBool
+ unstable: false
+
commands:
testCommand:
description: "new passing test command, there was no change from the old version"
@@ -1577,3 +1588,35 @@ commands:
reply_type: OkReply
chained_types:
intToIntString: intToIntString
+
+ newParameterOptionalBool:
+ description: "new command can add parameters of type optionalBoolean"
+ command_name: newParameterOptionalBool
+ namespace: ignored
+ cpp_name: newParameterOptionalBool
+ strict: true
+ api_version: "1"
+ reply_type: OkReply
+ fields:
+ flag:
+ type: optionalBool
+ unstable: false
+
+ newReplyOptionalBool:
+ description: "new command can add reply fields of type optionalBoolean"
+ command_name: newReplyOptionalBool
+ namespace: ignored
+ cpp_name: newReplyOptionalBool
+ strict: true
+ api_version: "1"
+ reply_type: NewOptionalBoolStruct
+
+ newCommandTypeOptionalBool:
+ description: "new command can add type fields of type optionalBoolean"
+ command_name: newCommandTypeOptionalBool
+ namespace: type
+ type: NewOptionalBoolStruct
+ cpp_name: newCommandTypeOptionalBool
+ strict: true
+ api_version: "1"
+ reply_type: OkReply
diff --git a/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl b/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl
index 3ba1907be5b..421e3b3978c 100644
--- a/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl
+++ b/buildscripts/idl/tests/compatibility_test_pass/old/compatibility_test_pass_old.idl
@@ -453,6 +453,14 @@ structs:
chained_structs:
StructCommandParameterTypeRecursive: StructCommandParameterTypeRecursive
+ NewOptionalBoolStruct:
+ description: "This struct gets another field of type optionalBool."
+ fields:
+ ok1:
+ type: bool
+ unstable: false
+ optional: true
+
commands:
testCommand:
description: "old passing test command"
@@ -1549,3 +1557,31 @@ commands:
reply_type: OkReply
chained_types:
intToIntString: intToIntString
+
+ newParameterOptionalBool:
+ description: "new command can add parameters of type optionalBoolean"
+ command_name: newParameterOptionalBool
+ namespace: ignored
+ cpp_name: newParameterOptionalBool
+ strict: true
+ api_version: "1"
+ reply_type: OkReply
+
+ newReplyOptionalBool:
+ description: "new command can add reply fields of type optionalBoolean"
+ command_name: newReplyOptionalBool
+ namespace: ignored
+ cpp_name: newReplyOptionalBool
+ strict: true
+ api_version: "1"
+ reply_type: NewOptionalBoolStruct
+
+ newCommandTypeOptionalBool:
+ description: "new command can add type fields of type optionalBoolean"
+ command_name: newCommandTypeOptionalBool
+ namespace: type
+ type: NewOptionalBoolStruct
+ cpp_name: newCommandTypeOptionalBool
+ strict: true
+ api_version: "1"
+ reply_type: OkReply