diff options
Diffstat (limited to 'buildscripts/idl')
| -rw-r--r-- | buildscripts/idl/check_stable_api_commands_have_idl_definitions.py | 14 | ||||
| -rw-r--r-- | buildscripts/idl/gen_all_feature_flag_list.py | 26 | ||||
| -rw-r--r-- | buildscripts/idl/idl/parser.py | 6 | ||||
| -rw-r--r-- | buildscripts/idl/idl_check_compatibility.py | 9 |
4 files changed, 30 insertions, 25 deletions
diff --git a/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py b/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py index c18077ace76..2a9d3c72420 100644 --- a/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py +++ b/buildscripts/idl/check_stable_api_commands_have_idl_definitions.py @@ -96,16 +96,16 @@ def list_commands_for_api(api_version: str, mongod_or_mongos: str, install_dir: if mongod_or_mongos == "mongod": logger = loggers.new_fixture_logger("MongoDFixture", 0) logger.parent = LOGGER - fixture: interface.Fixture = fixturelib.make_fixture("MongoDFixture", logger, 0, - dbpath_prefix=dbpath.name, - mongod_executable=mongod_executable) + fixture: interface.Fixture = fixturelib.make_fixture( + "MongoDFixture", logger, 0, dbpath_prefix=dbpath.name, + mongod_executable=mongod_executable, mongod_options={"set_parameters": {}}) else: logger = loggers.new_fixture_logger("ShardedClusterFixture", 0) logger.parent = LOGGER - fixture = fixturelib.make_fixture("ShardedClusterFixture", logger, 0, - dbpath_prefix=dbpath.name, - mongos_executable=mongos_executable, - mongod_executable=mongod_executable, mongod_options={}) + fixture = fixturelib.make_fixture( + "ShardedClusterFixture", logger, 0, dbpath_prefix=dbpath.name, + mongos_executable=mongos_executable, mongod_executable=mongod_executable, + mongod_options={"set_parameters": {}}) fixture.setup() fixture.await_ready() diff --git a/buildscripts/idl/gen_all_feature_flag_list.py b/buildscripts/idl/gen_all_feature_flag_list.py index 518583898cb..c7496803b3b 100644 --- a/buildscripts/idl/gen_all_feature_flag_list.py +++ b/buildscripts/idl/gen_all_feature_flag_list.py @@ -30,7 +30,6 @@ Generate a file containing a list of disabled feature flags. Used by resmoke.py to run only feature flag tests. """ -import argparse import os import sys @@ -43,6 +42,7 @@ sys.path.append(os.path.normpath(os.path.join(os.path.abspath(__file__), '../../ # pylint: disable=wrong-import-position import buildscripts.idl.lib as lib +from buildscripts.idl.idl import parser def is_third_party_idl(idl_path: str) -> bool: @@ -56,13 +56,14 @@ def is_third_party_idl(idl_path: str) -> bool: return False -def gen_all_feature_flags(idl_dir: str, import_dirs: List[str]): +def gen_all_feature_flags(idl_dir: str = os.getcwd()): """Generate a list of all feature flags.""" all_flags = [] for idl_path in sorted(lib.list_idls(idl_dir)): if is_third_party_idl(idl_path): continue - for feature_flag in lib.parse_idl(idl_path, import_dirs).spec.feature_flags: + doc = parser.parse_file(open(idl_path), idl_path) + for feature_flag in doc.spec.feature_flags: if feature_flag.default.literal != "true": all_flags.append(feature_flag.name) @@ -72,18 +73,17 @@ def gen_all_feature_flags(idl_dir: str, import_dirs: List[str]): return list(set(all_flags) - set(force_disabled_flags)) -def main(): - """Run the main function.""" - arg_parser = argparse.ArgumentParser(description=__doc__) - arg_parser.add_argument("--import-dir", dest="import_dirs", type=str, action="append", - help="Directory to search for IDL import files") +def gen_all_feature_flags_file(filename: str = lib.ALL_FEATURE_FLAG_FILE): + """Output generated list of feature flags to specified file.""" + flags = gen_all_feature_flags() + with open(filename, "w") as output_file: + output_file.write("\n".join(flags)) + print("Generated: ", os.path.realpath(output_file.name)) - args = arg_parser.parse_args() - flags = gen_all_feature_flags(os.getcwd(), args.import_dirs) - with open(lib.ALL_FEATURE_FLAG_FILE, "w") as output_file: - for flag in flags: - output_file.write("%s\n" % flag) +def main(): + """Run the main function.""" + gen_all_feature_flags_file() if __name__ == '__main__': diff --git a/buildscripts/idl/idl/parser.py b/buildscripts/idl/idl/parser.py index 2d9925db500..356edf0e265 100644 --- a/buildscripts/idl/idl/parser.py +++ b/buildscripts/idl/idl/parser.py @@ -1001,7 +1001,7 @@ def _propagate_globals(spec): idltype.cpp_type = _prefix_with_namespace(cpp_namespace, idltype.cpp_type) -def _parse(stream, error_file_name): +def parse_file(stream, error_file_name): # type: (Any, str) -> syntax.IDLParsedSpec """ Parse a YAML document into an idl.syntax tree. @@ -1105,7 +1105,7 @@ def parse(stream, input_file_name, resolver): """ # pylint: disable=too-many-locals - root_doc = _parse(stream, input_file_name) + root_doc = parse_file(stream, input_file_name) if root_doc.errors: return root_doc @@ -1142,7 +1142,7 @@ def parse(stream, input_file_name, resolver): # Parse imported file with resolver.open(resolved_file_name) as file_stream: - parsed_doc = _parse(file_stream, resolved_file_name) + parsed_doc = parse_file(file_stream, resolved_file_name) # Check for errors if parsed_doc.errors: diff --git a/buildscripts/idl/idl_check_compatibility.py b/buildscripts/idl/idl_check_compatibility.py index 1a30f29428a..64fd3541bc7 100644 --- a/buildscripts/idl/idl_check_compatibility.py +++ b/buildscripts/idl/idl_check_compatibility.py @@ -824,8 +824,13 @@ def check_param_or_type_validator(ctxt: IDLCompatibilityContext, old_field: synt ctxt.add_command_or_param_type_validators_not_equal_error( cmd_name, new_field.name, new_idl_file_path, type_name, is_command_parameter) else: - ctxt.add_command_or_param_type_contains_validator_error( - cmd_name, new_field.name, new_idl_file_path, type_name, is_command_parameter) + new_field_name: str = cmd_name + "-param-" + new_field.name + # In SERVER-77382 we fixed the error handling of creating time-series collections by + # adding a new validator to two 'stable' fields, but it didn't break any stable API + # guarantees. + if new_field_name not in ["create-param-timeField", "create-param-metaField"]: + ctxt.add_command_or_param_type_contains_validator_error( + cmd_name, new_field.name, new_idl_file_path, type_name, is_command_parameter) def get_all_struct_fields(struct: syntax.Struct, idl_file: syntax.IDLParsedSpec, |
