summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoustafa Maher <m.maher@10gen.com>2021-02-22 21:15:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-23 22:19:12 +0000
commitbd5979b18572c26ac44b36c8e5e32972c12a82d5 (patch)
tree08f98d05f17758aefd29acb9c45cd88684fe7256
parent8425cce3e66561cf726faaaf534d0939bffe9197 (diff)
downloadmongo-bd5979b18572c26ac44b36c8e5e32972c12a82d5.tar.gz
SERVER-51878 Enable test that checks all API V1 commands have an associated IDL file for specifying inputs/outputs
-rw-r--r--buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py41
1 files changed, 35 insertions, 6 deletions
diff --git a/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py b/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py
index 0840dfadf8c..1ed5ba9694c 100644
--- a/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py
+++ b/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py
@@ -75,6 +75,17 @@ def parse_idl(idl_path: str, import_directories: List[str]) -> syntax.IDLParsedS
return parsed_doc
+def is_test_idl(idl_path: str) -> bool:
+ """Check if an IDL file is a test file."""
+ test_idls_subpaths = ["/idl/tests/", "unittest.idl"]
+
+ for file_name in test_idls_subpaths:
+ if idl_path.find(file_name) != -1:
+ return True
+
+ return False
+
+
def get_command_definitions(api_version: str, directory: str,
import_directories: List[str]) -> Dict[str, syntax.Command]:
"""Get parsed IDL definitions of commands in a given API version."""
@@ -83,9 +94,10 @@ def get_command_definitions(api_version: str, directory: str,
def gen():
for idl_path in sorted(list_idls(directory)):
- for command in parse_idl(idl_path, import_directories).spec.symbols.commands:
- if command.api_version == api_version:
- yield command.name, command
+ if not is_test_idl(idl_path):
+ for command in parse_idl(idl_path, import_directories).spec.symbols.commands:
+ if command.api_version == api_version:
+ yield command.command_name, command
idl_commands = dict(gen())
LOGGER.debug("Found %s IDL commands in API Version %s", len(idl_commands), api_version)
@@ -147,9 +159,25 @@ def assert_command_sets_equal(api_version: str, command_sets: Dict[str, Set[str]
if other_commands - commands:
LOGGER.error("%s has commands not in %s: %s", other_name, name,
other_commands - commands)
- # TODO(SERVER-51878): Enable this assertion.
- # raise AssertionError(
- # f"{name} and {other_name} have different commands in API Version {api_version}")
+ raise AssertionError(
+ f"{name} and {other_name} have different commands in API Version {api_version}")
+
+
+def remove_skipped_commands(command_sets: Dict[str, Set[str]]):
+ """Remove skipped commands from command_sets."""
+ skipped_commands = {
+ "testDeprecation",
+ "testVersions1And2",
+ "testRemoval",
+ "testDeprecationInVersion2",
+ # Idl specifies the command_name as hello.
+ "isMaster",
+ # TODO(SERVER-53149): remove getMore.
+ "getMore"
+ }
+
+ for key in command_sets.keys():
+ command_sets[key].difference_update(skipped_commands)
def main():
@@ -177,6 +205,7 @@ def main():
command_sets["mongod"] = list_commands_for_api(args.api_version, "mongod", args.install_dir)
command_sets["mongos"] = list_commands_for_api(args.api_version, "mongos", args.install_dir)
command_sets["idl"] = set(get_command_definitions(args.api_version, os.getcwd(), args.include))
+ remove_skipped_commands(command_sets)
assert_command_sets_equal(args.api_version, command_sets)