diff --git a/bazel/wrapper_hook/BUILD.bazel b/bazel/wrapper_hook/BUILD.bazel index 795000f87a8..b916f2bffb0 100644 --- a/bazel/wrapper_hook/BUILD.bazel +++ b/bazel/wrapper_hook/BUILD.bazel @@ -8,6 +8,7 @@ py_library( "autogenerated_targets.py", "check_resources.py", "compiledb.py", + "compiledb_postprocess.py", "engflow_check.py", "generate_common_bes_bazelrc.py", "git_age_check.py", @@ -19,7 +20,13 @@ py_library( "wrapper_util.py", "write_wrapper_hook_bazelrc.py", ], + data = [ + "bazel_commands.commands", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts:setup_clang_tidy", + ], ) py_library( diff --git a/bazel/wrapper_hook/compiledb_postprocess.py b/bazel/wrapper_hook/compiledb_postprocess.py index 611ef765974..137da16a14d 100644 --- a/bazel/wrapper_hook/compiledb_postprocess.py +++ b/bazel/wrapper_hook/compiledb_postprocess.py @@ -2,8 +2,7 @@ import json import os import pathlib import tempfile -from urllib.parse import urlparse, unquote - +from urllib.parse import unquote, urlparse COMPILE_COMMAND_FRAGMENT_EXT = ".compile_command.json" diff --git a/buildscripts/BUILD.bazel b/buildscripts/BUILD.bazel index 67421d0b00e..bf4b6023186 100644 --- a/buildscripts/BUILD.bazel +++ b/buildscripts/BUILD.bazel @@ -45,15 +45,19 @@ py_binary( ], ) +py_library( + name = "build_system_options", + srcs = ["build_system_options.py"], + visibility = ["//visibility:public"], +) + py_binary( name = "mongosymb", - srcs = [ - "build_system_options.py", - "mongosymb.py", - ], + srcs = ["mongosymb.py"], main = "mongosymb.py", visibility = ["//visibility:public"], deps = [ + "//buildscripts:build_system_options", "//buildscripts/util", dependency( "requests", @@ -311,13 +315,25 @@ py_binary( "//buildscripts/patch_builds", "//buildscripts/resmokelib", dependency( - "structlog", + "click", group = "evergreen", ), dependency( "gitpython", group = "evergreen", ), + dependency( + "pydantic", + group = "evergreen", + ), + dependency( + "pyyaml", + group = "core", + ), + dependency( + "structlog", + group = "evergreen", + ), ], ) @@ -421,6 +437,7 @@ py_binary( py_binary( name = "validate_evg_project_config", srcs = ["validate_evg_project_config.py"], + visibility = ["//visibility:public"], deps = [ "//buildscripts/ciconfig", dependency( @@ -590,3 +607,237 @@ py_binary( ), ], ) + +py_library( + name = "check_for_noexcept", + srcs = ["check_for_noexcept.py"], + visibility = ["//visibility:public"], + deps = [ + dependency( + "gitpython", + group = "evergreen", + ), + dependency( + "structlog", + group = "evergreen", + ), + dependency( + "typer", + group = "core", + ), + ], +) + +py_library( + name = "debugsymb_mapper", + srcs = ["debugsymb_mapper.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:build_system_options", + "//buildscripts/resmokelib", + "//buildscripts/util", + dependency( + "requests", + group = "core", + ), + ], +) + +py_library( + name = "evergreen_activate_gen_tasks", + srcs = ["evergreen_activate_gen_tasks.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + dependency( + "click", + group = "evergreen", + ), + dependency( + "requests", + group = "core", + ), + dependency( + "structlog", + group = "evergreen", + ), + dependency( + "pydantic", + group = "evergreen", + ), + dependency( + "retry", + group = "testing", + ), + dependency( + "evergreen-py", + group = "testing", + ), + ], +) + +py_library( + name = "evergreen_resmoke_job_count", + srcs = ["evergreen_resmoke_job_count.py"], + visibility = ["//visibility:public"], + deps = [ + dependency( + "psutil", + group = "build-metrics", + ), + dependency( + "structlog", + group = "evergreen", + ), + dependency( + "pyyaml", + group = "core", + ), + ], +) + +py_library( + name = "evergreen_task_tags", + srcs = ["evergreen_task_tags.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/ciconfig", + ], +) + +py_library( + name = "feature_flag_tags_check", + srcs = ["feature_flag_tags_check.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_library( + name = "jepsen_report", + srcs = ["jepsen_report.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:simple_report", + dependency( + "click", + group = "evergreen", + ), + dependency( + "typing-extensions", + group = "core", + ), + ], +) + +py_library( + name = "package_test_internal", + srcs = ["package_test_internal.py"], + visibility = ["//visibility:public"], +) + +py_library( + name = "packager", + srcs = ["packager.py"], + visibility = ["//visibility:public"], + deps = [ + dependency( + "gitpython", + group = "evergreen", + ), + ], +) + +py_library( + name = "powercycle_sentinel", + srcs = ["powercycle_sentinel.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + dependency( + "click", + group = "evergreen", + ), + dependency( + "structlog", + group = "evergreen", + ), + dependency( + "evergreen-py", + group = "testing", + ), + ], +) + +py_library( + name = "sort_backport_multiversion", + srcs = ["sort_backport_multiversion.py"], + visibility = ["//visibility:public"], + deps = [ + dependency( + "pyyaml", + group = "core", + ), + ], +) + +py_library( + name = "validate_commit_message", + srcs = ["validate_commit_message.py"], + visibility = ["//visibility:public"], + deps = [ + "@bazel_rules_mongo//utils:evergreen_git", + "@poetry//:library_pathspec", + dependency( + "requests", + group = "core", + ), + dependency( + "structlog", + group = "evergreen", + ), + dependency( + "typer", + group = "core", + ), + dependency( + "gitpython", + group = "evergreen", + ), + dependency( + "typing-extensions", + group = "core", + ), + ], +) + +py_library( + name = "todo_check", + srcs = ["todo_check.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:validate_commit_message", + dependency( + "click", + group = "evergreen", + ), + dependency( + "evergreen-py", + group = "testing", + ), + ], +) + +py_library( + name = "validate_mongocryptd", + srcs = ["validate_mongocryptd.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/ciconfig", + dependency( + "pyyaml", + group = "core", + ), + ], +) diff --git a/buildscripts/client/BUILD.bazel b/buildscripts/client/BUILD.bazel index c19ca6f62f6..580742cb8e7 100644 --- a/buildscripts/client/BUILD.bazel +++ b/buildscripts/client/BUILD.bazel @@ -1,6 +1,26 @@ -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets +load("@poetry//:dependencies.bzl", "dependency") load("@rules_python//python:defs.bzl", "py_library") +py_library( + name = "jiraclient", + srcs = [ + "__init__.py", + "jiraclient.py", + ], + visibility = ["//visibility:public"], + deps = [ + dependency( + "jira", + group = "jira-client", + ), + dependency( + "pydantic", + group = "evergreen", + ), + ], +) + +# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets py_library( name = "all_python_files", srcs = glob(["*.py"]), diff --git a/buildscripts/monitor_build_status/BUILD.bazel b/buildscripts/monitor_build_status/BUILD.bazel index e0d1a0e26a7..2de00fbbaaa 100644 --- a/buildscripts/monitor_build_status/BUILD.bazel +++ b/buildscripts/monitor_build_status/BUILD.bazel @@ -1,4 +1,40 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "monitor_build_status", + srcs = glob(["*.py"]), + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/client:jiraclient", + "//buildscripts/util", + dependency( + "jira", + group = "jira-client", + ), + "@poetry//:library_python_dateutil", + dependency( + "requests", + group = "core", + ), + dependency( + "structlog", + group = "evergreen", + ), + dependency( + "tabulate", + group = "build-metrics", + ), + dependency( + "typer", + group = "core", + ), + dependency( + "typing-extensions", + group = "core", + ), + ], +) # TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets py_library( diff --git a/buildscripts/resmoke_proxy/BUILD.bazel b/buildscripts/resmoke_proxy/BUILD.bazel index 48ce6cb22c2..1fe6457ff6a 100644 --- a/buildscripts/resmoke_proxy/BUILD.bazel +++ b/buildscripts/resmoke_proxy/BUILD.bazel @@ -1,3 +1,4 @@ +load("@poetry//:dependencies.bzl", "dependency") load("@rules_python//python:defs.bzl", "py_binary") py_binary( @@ -8,6 +9,10 @@ py_binary( ], visibility = ["//visibility:public"], deps = [ - "//buildscripts/resmokelib", + "//buildscripts:resmoke", + dependency( + "inject", + group = "evergreen", + ), ], ) diff --git a/buildscripts/resmokeconfig/BUILD.bazel b/buildscripts/resmokeconfig/BUILD.bazel index 643980a8c01..207cadfd5ed 100644 --- a/buildscripts/resmokeconfig/BUILD.bazel +++ b/buildscripts/resmokeconfig/BUILD.bazel @@ -3,6 +3,11 @@ load("//bazel:mongo_js_rules.bzl", "mongo_js_library") package(default_visibility = ["//visibility:public"]) +exports_files([ + "fully_disabled_feature_flags.yml", + "resmoke_modules.yml", +]) + filegroup( name = "all_files", srcs = glob(["**"]), diff --git a/buildscripts/resmokelib/configure_resmoke.py b/buildscripts/resmokelib/configure_resmoke.py index b19ce42a79c..74a94a895cb 100644 --- a/buildscripts/resmokelib/configure_resmoke.py +++ b/buildscripts/resmokelib/configure_resmoke.py @@ -430,7 +430,8 @@ def _set_up_tracing( extra_context["git.branch_name"] = branch_name except Exception: print( - "Unable to setup git repo. This will result in incomplete telemetry data being uploaded." + "Unable to setup git repo. This will result in incomplete telemetry data being uploaded.", + file=sys.stderr, ) processor = BatchedBaggageSpanProcessor(OTLPSpanExporter(endpoint=COLLECTOR_ENDPOINT)) diff --git a/buildscripts/sbom/BUILD.bazel b/buildscripts/sbom/BUILD.bazel index 52936b518a8..5bb1fe83772 100644 --- a/buildscripts/sbom/BUILD.bazel +++ b/buildscripts/sbom/BUILD.bazel @@ -1,5 +1,7 @@ load("@rules_python//python:defs.bzl", "py_binary", "py_library") +exports_files(["metadata.cdx.json"]) + py_library( name = "config", srcs = ["config.py"], diff --git a/buildscripts/tests/BUILD.bazel b/buildscripts/tests/BUILD.bazel index efa42a5041b..a191f67061c 100644 --- a/buildscripts/tests/BUILD.bazel +++ b/buildscripts/tests/BUILD.bazel @@ -34,6 +34,313 @@ py_test( ], ) +py_test( + name = "test_activate_task", + srcs = ["test_activate_task.py"], + visibility = ["//visibility:public"], + deps = [ + "//evergreen:all_python_files", + ], +) + +py_test( + name = "test_bazel_plus_test_interface", + srcs = ["test_bazel_plus_test_interface.py"], + visibility = ["//visibility:public"], + deps = [ + "//bazel/wrapper_hook", + ], +) + +py_test( + name = "test_bazel_run_resmoke", + srcs = ["test_bazel_run_resmoke.py"], + data = [ + "//buildscripts/resmokeconfig:all_files", + "//buildscripts/resmokeconfig/loggers:all_files", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_check_for_noexcept", + srcs = ["test_check_for_noexcept.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:check_for_noexcept", + ], +) + +py_test( + name = "test_codeowners_auto_approver", + srcs = ["test_codeowners_auto_approver.py"], + visibility = ["//visibility:public"], + deps = [ + "@bazel_rules_mongo//codeowners", + ], +) + +py_test( + name = "test_compiledb_output_format", + srcs = ["test_compiledb_output_format.py"], + visibility = ["//visibility:public"], + deps = [ + "//bazel/wrapper_hook", + ], +) + +py_test( + name = "test_compiledb_posthook", + srcs = ["test_compiledb_posthook.py"], + visibility = ["//visibility:public"], + deps = [ + "//bazel/wrapper_hook", + ], +) + +py_test( + name = "test_debugsymb_mapper", + srcs = ["test_debugsymb_mapper.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:debugsymb_mapper", + ], +) + +py_test( + name = "test_errorcodes", + srcs = ["test_errorcodes.py"], + data = glob(["data/errorcodes/**/*"]), + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:errorcodes", + ], +) + +py_test( + name = "test_evergreen_activate_gen_tasks", + srcs = ["test_evergreen_activate_gen_tasks.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:evergreen_activate_gen_tasks", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_evergreen_resmoke_job_count", + srcs = ["test_evergreen_resmoke_job_count.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:evergreen_resmoke_job_count", + ], +) + +py_test( + name = "test_evergreen_task_tags", + srcs = ["test_evergreen_task_tags.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:evergreen_task_tags", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_evergreen_task_timeout", + srcs = ["test_evergreen_task_timeout.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:evergreen_task_timeout", + ], +) + +py_test( + name = "test_exception_extractor", + srcs = ["test_exception_extractor.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_feature_flag_tags_check", + srcs = ["test_feature_flag_tags_check.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:feature_flag_tags_check", + ], +) + +py_test( + name = "test_feature_flags", + srcs = ["test_feature_flags.py"], + data = ["//buildscripts/resmokeconfig:fully_disabled_feature_flags.yml"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/idl", + "//buildscripts/resmokelib", + dependency( + "pyyaml", + group = "core", + ), + ], +) + +py_test( + name = "test_generate_sbom", + srcs = ["test_generate_sbom.py"], + data = [ + "//buildscripts/sbom:metadata.cdx.json", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/sbom:config", + "//buildscripts/sbom:endorctl_utils", + "//buildscripts/sbom:sbom_utils", + ], +) + +py_test( + name = "test_jepsen_report", + srcs = ["test_jepsen_report.py"], + data = ["//buildscripts/tests:test_jepsen_report_corpus.log.txt"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:jepsen_report", + ], +) + +py_test( + name = "test_legacy_commands_check", + srcs = ["test_legacy_commands_check.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:legacy_commands_check", + ], +) + +py_test( + name = "test_merge_tidy_configs", + srcs = ["test_merge_tidy_configs.py"], + visibility = ["//visibility:public"], + deps = [ + "//bazel:merge_tidy_configs", + dependency( + "pyyaml", + group = "core", + ), + ], +) + +py_test( + name = "test_mongosymb", + srcs = ["test_mongosymb.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:mongosymb", + ], +) + +py_test( + name = "test_package_test_internal", + srcs = ["test_package_test_internal.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:package_test_internal", + ], +) + +py_test( + name = "test_packager", + srcs = ["test_packager.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:packager", + ], +) + +py_test( + name = "test_powercycle_sentinel", + srcs = ["test_powercycle_sentinel.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:powercycle_sentinel", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_simple_report", + srcs = ["test_simple_report.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:simple_report", + ], +) + +py_test( + name = "test_sort_backport_multiversion", + srcs = ["test_sort_backport_multiversion.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:sort_backport_multiversion", + ], +) + +py_test( + name = "test_todo_check", + srcs = ["test_todo_check.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:todo_check", + ], +) + +py_test( + name = "test_todo_linter", + srcs = ["test_todo_linter.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:todo_linter", + ], +) + +py_test( + name = "test_validate_evg_project_config", + srcs = ["test_validate_evg_project_config.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:validate_evg_project_config", + ], +) + +py_test( + name = "test_validate_mongocryptd", + srcs = ["test_validate_mongocryptd.py"], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:validate_mongocryptd", + dependency( + "mock", + group = "testing", + ), + ], +) + # TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets py_library( name = "all_python_files", diff --git a/buildscripts/tests/ciconfig/BUILD.bazel b/buildscripts/tests/ciconfig/BUILD.bazel index ae60cee7ffa..5aaaae2d2ba 100644 --- a/buildscripts/tests/ciconfig/BUILD.bazel +++ b/buildscripts/tests/ciconfig/BUILD.bazel @@ -6,6 +6,7 @@ py_test( "__init__.py", "test_evergreen.py", ], + data = ["//buildscripts/tests/ciconfig:evergreen.yml"], visibility = ["//visibility:public"], deps = [ "//buildscripts/ciconfig", diff --git a/buildscripts/tests/ciconfig/test_evergreen.py b/buildscripts/tests/ciconfig/test_evergreen.py index fcb40dd46b0..bf7c1d4a5ad 100644 --- a/buildscripts/tests/ciconfig/test_evergreen.py +++ b/buildscripts/tests/ciconfig/test_evergreen.py @@ -588,3 +588,7 @@ class TestVariant(unittest.TestCase): variant_amazon = self.conf.get_variant("amazon") self.assertEqual(3, len(variant_amazon.tasks)) self.assertIn("compile", variant_amazon.task_names) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/monitor_build_status/BUILD.bazel b/buildscripts/tests/monitor_build_status/BUILD.bazel index e0d1a0e26a7..b5a0c06539a 100644 --- a/buildscripts/tests/monitor_build_status/BUILD.bazel +++ b/buildscripts/tests/monitor_build_status/BUILD.bazel @@ -1,8 +1,37 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_cli", + srcs = [ + "__init__.py", + "test_cli.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/monitor_build_status", + ], +) + +py_test( + name = "test_issue_report", + srcs = [ + "__init__.py", + "test_issue_report.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/monitor_build_status", + ], +) + +py_test( + name = "test_jira_service", + srcs = [ + "__init__.py", + "test_jira_service.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/monitor_build_status", + ], ) diff --git a/buildscripts/tests/monitor_build_status/test_cli.py b/buildscripts/tests/monitor_build_status/test_cli.py index d04a430ecbc..1b50f143dba 100644 --- a/buildscripts/tests/monitor_build_status/test_cli.py +++ b/buildscripts/tests/monitor_build_status/test_cli.py @@ -107,3 +107,7 @@ class TestSummarize(unittest.TestCase): expected_summary = f"`SUMMARY [scope]` " f"{under_test.SummaryMsg.BELOW_THRESHOLDS.value}" self.assertEqual(summary, expected_summary) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/monitor_build_status/test_issue_report.py b/buildscripts/tests/monitor_build_status/test_issue_report.py index 57faf804e8c..fcb44d8c9e1 100644 --- a/buildscripts/tests/monitor_build_status/test_issue_report.py +++ b/buildscripts/tests/monitor_build_status/test_issue_report.py @@ -65,3 +65,7 @@ class TestIssueReport(unittest.TestCase): count = report.get_issue_count(under_test.IssueCategory.HOT) self.assertEqual(count, 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/monitor_build_status/test_jira_service.py b/buildscripts/tests/monitor_build_status/test_jira_service.py index 292104b0d5d..6a5804f2520 100644 --- a/buildscripts/tests/monitor_build_status/test_jira_service.py +++ b/buildscripts/tests/monitor_build_status/test_jira_service.py @@ -71,3 +71,7 @@ class TestBfIssue(unittest.TestCase): bf_issue = under_test.IssueTuple.from_jira_issue(jira_issue) self.assertEqual(bf_issue.team_assignment_duration_hours, 3 * 24) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/patch_builds/BUILD.bazel b/buildscripts/tests/patch_builds/BUILD.bazel index e0d1a0e26a7..e18738fda7f 100644 --- a/buildscripts/tests/patch_builds/BUILD.bazel +++ b/buildscripts/tests/patch_builds/BUILD.bazel @@ -1,8 +1,18 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_change_data", + srcs = [ + "__init__.py", + "test_change_data.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/patch_builds", + dependency( + "mock", + group = "testing", + ), + ], ) diff --git a/buildscripts/tests/patch_builds/test_change_data.py b/buildscripts/tests/patch_builds/test_change_data.py index a852f872379..5f7a7784b8c 100644 --- a/buildscripts/tests/patch_builds/test_change_data.py +++ b/buildscripts/tests/patch_builds/test_change_data.py @@ -111,3 +111,7 @@ class TestFindChangedFilesAndLinesInRepos(unittest.TestCase): mock_open.assert_called_once_with("src/module/test1.cpp", "r") self.assertEqual(result, expected_result) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmoke_proxy/BUILD.bazel b/buildscripts/tests/resmoke_proxy/BUILD.bazel index e0d1a0e26a7..6fd7640120a 100644 --- a/buildscripts/tests/resmoke_proxy/BUILD.bazel +++ b/buildscripts/tests/resmoke_proxy/BUILD.bazel @@ -1,8 +1,13 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_resmoke_proxy", + srcs = [ + "__init__.py", + "test_resmoke_proxy.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmoke_proxy", + ], ) diff --git a/buildscripts/tests/resmoke_proxy/test_resmoke_proxy.py b/buildscripts/tests/resmoke_proxy/test_resmoke_proxy.py index 1f14291b436..26b5f705615 100644 --- a/buildscripts/tests/resmoke_proxy/test_resmoke_proxy.py +++ b/buildscripts/tests/resmoke_proxy/test_resmoke_proxy.py @@ -19,3 +19,7 @@ class TestResmokeProxy(unittest.TestCase): test_list = resmoke_proxy.list_tests("some suite") self.assertEqual(len(test_list), 7) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmoke_validation/BUILD.bazel b/buildscripts/tests/resmoke_validation/BUILD.bazel index 7f40734dd94..6a3a31e1900 100644 --- a/buildscripts/tests/resmoke_validation/BUILD.bazel +++ b/buildscripts/tests/resmoke_validation/BUILD.bazel @@ -1,4 +1,3 @@ -load("@poetry//:dependencies.bzl", "dependency") load("@rules_python//python:defs.bzl", "py_test") py_test( @@ -13,9 +12,13 @@ py_test( py_test( name = "test_find_suites", srcs = ["test_find_suites.py"], + data = [ + "//buildscripts/resmokeconfig:all_files", + "//jstests/core/testing:all_subpackage_javascript_files", + ], visibility = ["//visibility:public"], deps = [ - "//buildscripts/resmokelib", + "//buildscripts:resmoke", ], ) diff --git a/buildscripts/tests/resmoke_validation/tests/python_test.py b/buildscripts/tests/resmoke_validation/tests/python_test.py index e533b06caf7..81f54eca077 100644 --- a/buildscripts/tests/resmoke_validation/tests/python_test.py +++ b/buildscripts/tests/resmoke_validation/tests/python_test.py @@ -5,3 +5,7 @@ class TestAssert(unittest.TestCase): def test_pass(self): true = True self.assertTrue(true) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/BUILD.bazel b/buildscripts/tests/resmokelib/BUILD.bazel index c19ca6f62f6..ecf8c59433e 100644 --- a/buildscripts/tests/resmokelib/BUILD.bazel +++ b/buildscripts/tests/resmokelib/BUILD.bazel @@ -1,8 +1,65 @@ -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -load("@rules_python//python:defs.bzl", "py_library") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_library", "py_test") +# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets py_library( name = "all_python_files", srcs = glob(["*.py"]), visibility = ["//visibility:public"], ) + +py_test( + name = "test_multiversionconstants_location", + srcs = [ + "__init__.py", + "test_multiversionconstants_location.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_parser", + srcs = [ + "__init__.py", + "test_parser.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts:resmoke", + ], +) + +py_test( + name = "test_suite_hierarchy", + srcs = [ + "__init__.py", + "test_suite_hierarchy.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_suitesconfig", + srcs = [ + "__init__.py", + "test_suitesconfig.py", + ], + data = [ + "//buildscripts/resmokeconfig:all_files", + "//buildscripts/resmokeconfig/loggers:all_files", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) diff --git a/buildscripts/tests/resmokelib/core/BUILD.bazel b/buildscripts/tests/resmokelib/core/BUILD.bazel index e0d1a0e26a7..f0c05026d0c 100644 --- a/buildscripts/tests/resmokelib/core/BUILD.bazel +++ b/buildscripts/tests/resmokelib/core/BUILD.bazel @@ -1,8 +1,42 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_pipe", + srcs = [ + "__init__.py", + "test_pipe.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_programs", + srcs = [ + "__init__.py", + "test_programs.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_redirect", + srcs = [ + "__init__.py", + "test_redirect.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], ) diff --git a/buildscripts/tests/resmokelib/core/test_pipe.py b/buildscripts/tests/resmokelib/core/test_pipe.py index 1520b33736c..51b45e32c85 100644 --- a/buildscripts/tests/resmokelib/core/test_pipe.py +++ b/buildscripts/tests/resmokelib/core/test_pipe.py @@ -79,3 +79,7 @@ class TestFormatLineForLogging(unittest.TestCase): line_output = _pipe.LoggerPipe._format_line_for_logging(line) self.assertEqual(2, len(line_output)) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/core/test_programs.py b/buildscripts/tests/resmokelib/core/test_programs.py index 9052bf8f05d..ff40f659078 100644 --- a/buildscripts/tests/resmokelib/core/test_programs.py +++ b/buildscripts/tests/resmokelib/core/test_programs.py @@ -20,3 +20,7 @@ class ResmokeProgramsTestCase(unittest.TestCase): 'dummy_key["a"]["b"] = "c"', ] self.assertEqual(string_builder, expected) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/core/test_redirect.py b/buildscripts/tests/resmokelib/core/test_redirect.py index 0f827a96c81..10e9b72c9f4 100644 --- a/buildscripts/tests/resmokelib/core/test_redirect.py +++ b/buildscripts/tests/resmokelib/core/test_redirect.py @@ -55,3 +55,7 @@ class TestStdoutRedirect(unittest.TestCase): print("not to be captured") self.assertEqual(string + "\n", acc.getvalue().decode("utf-8")) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/discovery/test_discovery.py b/buildscripts/tests/resmokelib/discovery/test_discovery.py index afbe549e50b..de5e65a1991 100644 --- a/buildscripts/tests/resmokelib/discovery/test_discovery.py +++ b/buildscripts/tests/resmokelib/discovery/test_discovery.py @@ -30,3 +30,7 @@ class TestTestDiscoverySubCommand(unittest.TestCase): for i in range(6): self.assertIn(f"test_{i}.js", tests.tests) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/generate_fuzz_config/test_mongo_fuzzer_configs.py b/buildscripts/tests/resmokelib/generate_fuzz_config/test_mongo_fuzzer_configs.py index ecfd0682e10..f1febab9cce 100644 --- a/buildscripts/tests/resmokelib/generate_fuzz_config/test_mongo_fuzzer_configs.py +++ b/buildscripts/tests/resmokelib/generate_fuzz_config/test_mongo_fuzzer_configs.py @@ -388,3 +388,7 @@ class TestIsEnterpriseParamAvailable(unittest.TestCase): def test_modules_with_enterprise_enterprise_param(self): with mock.patch.object(config, "MODULES", ["enterprise"]): self.assertTrue(is_enterprise_param_available({"enterprise_only": True})) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/hang_analyzer/test_process_list.py b/buildscripts/tests/resmokelib/hang_analyzer/test_process_list.py index 5ece4e783a2..36ec8188369 100644 --- a/buildscripts/tests/resmokelib/hang_analyzer/test_process_list.py +++ b/buildscripts/tests/resmokelib/hang_analyzer/test_process_list.py @@ -135,3 +135,7 @@ class TestGetProcesses(unittest.TestCase): Pinfo(name="mongod", pidv=[4, 5]), ], ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/logging/BUILD.bazel b/buildscripts/tests/resmokelib/logging/BUILD.bazel index e0d1a0e26a7..d352833da79 100644 --- a/buildscripts/tests/resmokelib/logging/BUILD.bazel +++ b/buildscripts/tests/resmokelib/logging/BUILD.bazel @@ -1,8 +1,25 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_handlers", + srcs = [ + "__init__.py", + "test_handlers.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_loggers", + srcs = [ + "__init__.py", + "test_loggers.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], ) diff --git a/buildscripts/tests/resmokelib/logging/test_handlers.py b/buildscripts/tests/resmokelib/logging/test_handlers.py index 287d4bccf36..30395268844 100644 --- a/buildscripts/tests/resmokelib/logging/test_handlers.py +++ b/buildscripts/tests/resmokelib/logging/test_handlers.py @@ -190,3 +190,7 @@ class TestBufferedFileHandler(unittest.TestCase): flush_t.join(timeout=5) self.assertFalse(flush_t.is_alive(), "Flush thread did not finish in time") self.assertEqual(errors, [], f"Race condition caused errors: {errors}") + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/logging/test_loggers.py b/buildscripts/tests/resmokelib/logging/test_loggers.py index 51510065664..4db76a9f8eb 100644 --- a/buildscripts/tests/resmokelib/logging/test_loggers.py +++ b/buildscripts/tests/resmokelib/logging/test_loggers.py @@ -73,3 +73,7 @@ class TestLoggers(unittest.TestCase): for full_name, expected_short_name in transform: short_name = loggers._shorten(full_name) self.assertEqual(short_name, expected_short_name) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/multiversion/BUILD.bazel b/buildscripts/tests/resmokelib/multiversion/BUILD.bazel index e0d1a0e26a7..2bd0eb2781a 100644 --- a/buildscripts/tests/resmokelib/multiversion/BUILD.bazel +++ b/buildscripts/tests/resmokelib/multiversion/BUILD.bazel @@ -1,8 +1,13 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_multiversion_service", + srcs = [ + "__init__.py", + "test_multiversion_service.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], ) diff --git a/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py b/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py index 5838e49838c..ad553fdbe25 100644 --- a/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py +++ b/buildscripts/tests/resmokelib/multiversion/test_multiversion_service.py @@ -1,5 +1,6 @@ """Unit tests for multiversion_service.py.""" +import unittest from unittest import TestCase from packaging.version import Version @@ -156,3 +157,7 @@ class TestCalculateFcvConstants(TestCase): ] ], ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/powercycle/test_remote_operations.py b/buildscripts/tests/resmokelib/powercycle/test_remote_operations.py index 68de2c0be85..32b460361f8 100755 --- a/buildscripts/tests/resmokelib/powercycle/test_remote_operations.py +++ b/buildscripts/tests/resmokelib/powercycle/test_remote_operations.py @@ -439,3 +439,7 @@ class RemoteOperation(RemoteOperationsTestCase): def runTest(self): # Invalid operation self.assertRaises(ValueError, lambda: self.rop.operation("invalid", None)) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/run/BUILD.bazel b/buildscripts/tests/resmokelib/run/BUILD.bazel index e0d1a0e26a7..7309b4837f7 100644 --- a/buildscripts/tests/resmokelib/run/BUILD.bazel +++ b/buildscripts/tests/resmokelib/run/BUILD.bazel @@ -1,8 +1,54 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_auto_kill_rogue_process", + srcs = [ + "__init__.py", + "test_auto_kill_rogue_process.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_generate_multiversion_exclude_tags", + srcs = [ + "__init__.py", + "test_generate_multiversion_exclude_tags.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_list_tags", + srcs = [ + "__init__.py", + "test_list_tags.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_shuffle_tests", + srcs = [ + "__init__.py", + "test_shuffle_tests.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], ) diff --git a/buildscripts/tests/resmokelib/run/test_auto_kill_rogue_process.py b/buildscripts/tests/resmokelib/run/test_auto_kill_rogue_process.py index bb7705f40f2..77cef2c5c47 100644 --- a/buildscripts/tests/resmokelib/run/test_auto_kill_rogue_process.py +++ b/buildscripts/tests/resmokelib/run/test_auto_kill_rogue_process.py @@ -121,3 +121,7 @@ class TestDetectRogueProcess(unittest.TestCase): self.fail("Process was killed when it should not have been.") proc.wait() + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/run/test_generate_multiversion_exclude_tags.py b/buildscripts/tests/resmokelib/run/test_generate_multiversion_exclude_tags.py index 4650c4e7cfa..cabb4487b22 100644 --- a/buildscripts/tests/resmokelib/run/test_generate_multiversion_exclude_tags.py +++ b/buildscripts/tests/resmokelib/run/test_generate_multiversion_exclude_tags.py @@ -338,3 +338,7 @@ class TestGenerateExcludeYaml(unittest.TestCase): self.patch_and_run(latest_yaml, old_yaml, MultiversionOptions.LAST_LTS) self.assert_contents(expected) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/run/test_list_tags.py b/buildscripts/tests/resmokelib/run/test_list_tags.py index 0cced58fe9f..f623f4514c9 100644 --- a/buildscripts/tests/resmokelib/run/test_list_tags.py +++ b/buildscripts/tests/resmokelib/run/test_list_tags.py @@ -249,3 +249,7 @@ class TestGetTagDoc(unittest.TestCase): ) result = list_tags.get_tag_doc(tag_block) self.assertEqual(expected, result) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/run/test_shuffle_tests.py b/buildscripts/tests/resmokelib/run/test_shuffle_tests.py index b2a2ad03f24..368a2e6c28c 100644 --- a/buildscripts/tests/resmokelib/run/test_shuffle_tests.py +++ b/buildscripts/tests/resmokelib/run/test_shuffle_tests.py @@ -79,3 +79,7 @@ class TestShuffle(unittest.TestCase): expected = ["c", "a", "b", "d"] actual = TestRunner.LongestFirstPartialShuffle(history).shuffle(tests) self.assertListEqual(actual, expected) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/setup_multiversion/BUILD.bazel b/buildscripts/tests/resmokelib/setup_multiversion/BUILD.bazel index e0d1a0e26a7..4c5d74520f7 100644 --- a/buildscripts/tests/resmokelib/setup_multiversion/BUILD.bazel +++ b/buildscripts/tests/resmokelib/setup_multiversion/BUILD.bazel @@ -1,8 +1,21 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_setup_multiversion", + srcs = [ + "__init__.py", + "test_setup_multiversion.py", + ], + data = [ + "//buildscripts/resmokeconfig:setup_multiversion/setup_multiversion_config.yml", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], ) diff --git a/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py b/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py index 22d9424a6f7..68ff744cc76 100644 --- a/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py +++ b/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py @@ -374,3 +374,7 @@ class TestSetupMultiversionGetUrls(TestSetupMultiversionBase): urlinfo = self.setup_multiversion.get_urls("4.4.1") self.assertEqual(urlinfo.urls, {}) self.assertEqual(urlinfo.evg_version_id, None) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/test_multiversionconstants_location.py b/buildscripts/tests/resmokelib/test_multiversionconstants_location.py index 0ff38b38e50..7ced5bf8812 100644 --- a/buildscripts/tests/resmokelib/test_multiversionconstants_location.py +++ b/buildscripts/tests/resmokelib/test_multiversionconstants_location.py @@ -26,3 +26,7 @@ class TestMultiversionconstantsLocation(unittest.TestCase): f" uses this constant. If the module was changed, one-click repro tool" f" should also be updated. Please reach out in #server-testing slack channel.", ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/test_parser.py b/buildscripts/tests/resmokelib/test_parser.py index baca3d1268a..fd7b0846c96 100644 --- a/buildscripts/tests/resmokelib/test_parser.py +++ b/buildscripts/tests/resmokelib/test_parser.py @@ -424,3 +424,7 @@ class TestParseCommandLine(unittest.TestCase): with self.assertRaises(SystemExit) as cm: parse_command_line(["run", "nonexistent_file.js"], should_configure_otel=False) self.assertEqual(cm.exception.code, 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/test_selector.py b/buildscripts/tests/resmokelib/test_selector.py index 82415e438cb..9fa4cc42090 100644 --- a/buildscripts/tests/resmokelib/test_selector.py +++ b/buildscripts/tests/resmokelib/test_selector.py @@ -738,3 +738,7 @@ class TestFilterTests(unittest.TestCase): selected, excluded = selector.filter_tests("db_test", config, self.test_file_explorer) self.assertEqual(["dbtestB"], selected) self.assertEqual(["dbtestA", "dbtestC"], excluded) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/test_suite_hierarchy.py b/buildscripts/tests/resmokelib/test_suite_hierarchy.py index 9c46e364e3c..6dc9f780995 100644 --- a/buildscripts/tests/resmokelib/test_suite_hierarchy.py +++ b/buildscripts/tests/resmokelib/test_suite_hierarchy.py @@ -222,3 +222,7 @@ class TestSuiteHierarchy(unittest.TestCase): full_union, f"Min set union\n{min_set_union}\n != full union\n{full_union}", ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/test_suitesconfig.py b/buildscripts/tests/resmokelib/test_suitesconfig.py index b20b574826b..265e687b50a 100644 --- a/buildscripts/tests/resmokelib/test_suitesconfig.py +++ b/buildscripts/tests/resmokelib/test_suitesconfig.py @@ -49,3 +49,7 @@ class TestSuitesConfig(unittest.TestCase): test_kind=("fsm_workload_test", "js_test") ) self.assertEqual(membership_map, dict(test1=all_suites, test2=all_suites)) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/BUILD.bazel b/buildscripts/tests/resmokelib/testing/BUILD.bazel index e0d1a0e26a7..ed41490dd16 100644 --- a/buildscripts/tests/resmokelib/testing/BUILD.bazel +++ b/buildscripts/tests/resmokelib/testing/BUILD.bazel @@ -1,8 +1,93 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_executor", + srcs = [ + "__init__.py", + "test_executor.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_job", + srcs = [ + "__init__.py", + "test_job.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_queue_element", + srcs = [ + "__init__.py", + "test_queue_element.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_suite", + srcs = [ + "__init__.py", + "test_suite.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_symbolizer_service", + srcs = [ + "__init__.py", + "test_symbolizer_service.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_tags", + srcs = [ + "__init__.py", + "test_tags.py", + ], + data = [ + "//buildscripts/tests/resmokelib/testing:tags.yml", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], ) diff --git a/buildscripts/tests/resmokelib/testing/fixtures/test_builder.py b/buildscripts/tests/resmokelib/testing/fixtures/test_builder.py index fe23bb1c686..4e640780155 100644 --- a/buildscripts/tests/resmokelib/testing/fixtures/test_builder.py +++ b/buildscripts/tests/resmokelib/testing/fixtures/test_builder.py @@ -318,3 +318,7 @@ class TestMakeFixtureIFRExclusion(unittest.TestCase): enable_feature_flags=False, ) self.assertNotIn(ifr_flag, mongod.mongod_options[SET_PARAMS]) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/fixtures/test_fixturelib.py b/buildscripts/tests/resmokelib/testing/fixtures/test_fixturelib.py index 2229df9782a..fbf70c52fd8 100644 --- a/buildscripts/tests/resmokelib/testing/fixtures/test_fixturelib.py +++ b/buildscripts/tests/resmokelib/testing/fixtures/test_fixturelib.py @@ -76,3 +76,7 @@ class TestMergeMongoOptionDicts(unittest.TestCase): } self.assertDictEqual(original, expected) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/fixtures/test_interface.py b/buildscripts/tests/resmokelib/testing/fixtures/test_interface.py index 0a9383d7397..843fbe7af03 100644 --- a/buildscripts/tests/resmokelib/testing/fixtures/test_interface.py +++ b/buildscripts/tests/resmokelib/testing/fixtures/test_interface.py @@ -55,3 +55,7 @@ class UnitTestFixture(interface.Fixture): def _do_teardown(self, finished=False, mode=None): if self._should_raise: raise errors.ServerFailure(self.ERROR_MESSAGE) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/hooks/test_generate_and_check_perf_results.py b/buildscripts/tests/resmokelib/testing/hooks/test_generate_and_check_perf_results.py index b3c8d6ae6c4..23ba773d1f9 100755 --- a/buildscripts/tests/resmokelib/testing/hooks/test_generate_and_check_perf_results.py +++ b/buildscripts/tests/resmokelib/testing/hooks/test_generate_and_check_perf_results.py @@ -848,3 +848,7 @@ class TestCheckPerfResultTestCase(unittest.TestCase): with self.assertRaisesRegex(ServerFailure, "threshold check"): test_case.run_test() + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/hooks/test_lifecycle.py b/buildscripts/tests/resmokelib/testing/hooks/test_lifecycle.py index e7e415133b6..4ac8f04599c 100644 --- a/buildscripts/tests/resmokelib/testing/hooks/test_lifecycle.py +++ b/buildscripts/tests/resmokelib/testing/hooks/test_lifecycle.py @@ -135,3 +135,7 @@ class TestFileBasedThreadLifecycle(unittest.TestCase): self.assertFalse(lifecycle.wait_for_action_permitted()) self.assertTrue(cond.wait.called) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/hooks/test_runtime_parameter_fuzzing.py b/buildscripts/tests/resmokelib/testing/hooks/test_runtime_parameter_fuzzing.py index ff6c779cdd0..5d807cb7dfc 100644 --- a/buildscripts/tests/resmokelib/testing/hooks/test_runtime_parameter_fuzzing.py +++ b/buildscripts/tests/resmokelib/testing/hooks/test_runtime_parameter_fuzzing.py @@ -144,3 +144,7 @@ class TestRuntimeFuzzGeneration(unittest.TestCase): _runtime_fuzzer.validate_runtime_parameter_spec(bad_spec_value_no_period) # No exception for good dict _runtime_fuzzer.validate_runtime_parameter_spec(good_spec) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/hooks/test_stepdown.py b/buildscripts/tests/resmokelib/testing/hooks/test_stepdown.py index 03640883e76..6d402bcbbe8 100644 --- a/buildscripts/tests/resmokelib/testing/hooks/test_stepdown.py +++ b/buildscripts/tests/resmokelib/testing/hooks/test_stepdown.py @@ -46,3 +46,7 @@ class TestStepdownThread(unittest.TestCase): shardcluster_fixture.mongos.is_running.return_value = False with self.assertRaises(errors.ServerFailure): stepdown_thread.pause() + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/test_executor.py b/buildscripts/tests/resmokelib/testing/test_executor.py index b05dbd706e1..4909608501e 100644 --- a/buildscripts/tests/resmokelib/testing/test_executor.py +++ b/buildscripts/tests/resmokelib/testing/test_executor.py @@ -128,3 +128,7 @@ class TestTestQueueAddTestCases(unittest.TestCase): while not test_queue.empty(): element = test_queue.get() self.assertIn(element, self.test_cases) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/test_job.py b/buildscripts/tests/resmokelib/testing/test_job.py index 8f6b2eeab73..203a7006f48 100644 --- a/buildscripts/tests/resmokelib/testing/test_job.py +++ b/buildscripts/tests/resmokelib/testing/test_job.py @@ -330,3 +330,7 @@ class TestNoOpFixtureSetupAndTeardown(unittest.TestCase): def test_teardown_called_for_noop_fixture(self): self.assertTrue(self.__job_object.manager.teardown_fixture(self.logger)) self.__noop_fixture.teardown.assert_called_once_with(finished=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/test_queue_element.py b/buildscripts/tests/resmokelib/testing/test_queue_element.py index 97c1a0304d2..7ab3f62e699 100644 --- a/buildscripts/tests/resmokelib/testing/test_queue_element.py +++ b/buildscripts/tests/resmokelib/testing/test_queue_element.py @@ -90,3 +90,7 @@ class TestQueueElemRepeatTime(unittest.TestCase): queue_elem = queue_element.QueueElemRepeatTime(None, None, suite_options) job_time = 1 self.assert_elem_queues_n_times(queue_elem, job_time, 2) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/test_suite.py b/buildscripts/tests/resmokelib/testing/test_suite.py index baa0e0aecf5..c394d976390 100644 --- a/buildscripts/tests/resmokelib/testing/test_suite.py +++ b/buildscripts/tests/resmokelib/testing/test_suite.py @@ -238,3 +238,7 @@ class TestGetTestsForKind(unittest.TestCase): self.assertEqual(set(shard1), set(["1.js", "3.js"])) self.assertEqual(set(shard2), set(["2.js", "4.js"])) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/test_symbolizer_service.py b/buildscripts/tests/resmokelib/testing/test_symbolizer_service.py index a59a5d3756d..8d624fb4279 100644 --- a/buildscripts/tests/resmokelib/testing/test_symbolizer_service.py +++ b/buildscripts/tests/resmokelib/testing/test_symbolizer_service.py @@ -233,3 +233,7 @@ class TestFileService(unittest.TestCase): self.file_service.add_to_processed_files(processed_files) filtered = self.file_service.filter_out_already_processed_files(files) self.assertTrue(all(file not in processed_files for file in filtered)) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/test_tags.py b/buildscripts/tests/resmokelib/testing/test_tags.py index 810d284f78c..f906b72789a 100644 --- a/buildscripts/tests/resmokelib/testing/test_tags.py +++ b/buildscripts/tests/resmokelib/testing/test_tags.py @@ -120,3 +120,7 @@ class TestTagsConfig(unittest.TestCase): conf.add_tag(test_kind, test_pattern, "tag1|aaa") tags = conf.get_tags(test_kind, test_pattern) self.assertEqual(["ta|g2", "tag1", "tag1|aaa", "tag2", "tag3"], tags) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/testcases/test_pytest.py b/buildscripts/tests/resmokelib/testing/testcases/test_pytest.py index 79d12e35893..87a8310493a 100644 --- a/buildscripts/tests/resmokelib/testing/testcases/test_pytest.py +++ b/buildscripts/tests/resmokelib/testing/testcases/test_pytest.py @@ -59,3 +59,7 @@ class TestPyTestCase(unittest.TestCase): self.assertIn(" -m unittest", proc.as_command()) self.assertIn(pytest_case.test_name, proc.as_command()) self.assertEqual(proc.logger, logger) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/testing/testcases/test_testcase.py b/buildscripts/tests/resmokelib/testing/testcases/test_testcase.py index 9c5fda90001..751fd1f0631 100644 --- a/buildscripts/tests/resmokelib/testing/testcases/test_testcase.py +++ b/buildscripts/tests/resmokelib/testing/testcases/test_testcase.py @@ -235,3 +235,7 @@ class TestTimeouts(unittest.TestCase): timer.cancel() self.assertTrue(testcase.timed_out.is_set()) self.assertTrue(testcase.timed_out_processed.is_set()) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/utils/BUILD.bazel b/buildscripts/tests/resmokelib/utils/BUILD.bazel index e0d1a0e26a7..956b1373e8f 100644 --- a/buildscripts/tests/resmokelib/utils/BUILD.bazel +++ b/buildscripts/tests/resmokelib/utils/BUILD.bazel @@ -1,4 +1,5 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") # TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets py_library( @@ -6,3 +7,55 @@ py_library( srcs = glob(["*.py"]), visibility = ["//visibility:public"], ) + +py_test( + name = "test_evergreen_conn", + srcs = [ + "__init__.py", + "test_evergreen_conn.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_history", + srcs = [ + "__init__.py", + "test_history.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_scheduler", + srcs = [ + "__init__.py", + "test_scheduler.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) + +py_test( + name = "test_version_comparison", + srcs = [ + "__init__.py", + "test_version_comparison.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmokelib", + ], +) diff --git a/buildscripts/tests/resmokelib/utils/test_archival.py b/buildscripts/tests/resmokelib/utils/test_archival.py index c2593eadf01..49af2964e1b 100644 --- a/buildscripts/tests/resmokelib/utils/test_archival.py +++ b/buildscripts/tests/resmokelib/utils/test_archival.py @@ -245,3 +245,7 @@ class DirectoryArchivalTests(unittest.TestCase): expected = os.path.join(self.temp_dir, archive_name) self.assertTrue(os.path.exists(expected), f"Expected archive does not exist: {expected}") self.assertEqual(0, status, message) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py b/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py index bef280b0bab..9a2fcd51ae9 100644 --- a/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py +++ b/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py @@ -303,3 +303,7 @@ class TestGetCompileArtifactUrls(unittest.TestCase): urls = evergreen_conn.get_compile_artifact_urls(mock_evg_api, mock_version, "test") self.assertEqual(urls, {}) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/utils/test_history.py b/buildscripts/tests/resmokelib/utils/test_history.py index 4dce55a6216..9b3ab94da65 100644 --- a/buildscripts/tests/resmokelib/utils/test_history.py +++ b/buildscripts/tests/resmokelib/utils/test_history.py @@ -250,3 +250,7 @@ History: notify_calls, "copy() must not call notify_subscriber_write() during construction", ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/utils/test_scheduler.py b/buildscripts/tests/resmokelib/utils/test_scheduler.py index 8023cae1098..4878c3df02d 100644 --- a/buildscripts/tests/resmokelib/utils/test_scheduler.py +++ b/buildscripts/tests/resmokelib/utils/test_scheduler.py @@ -29,3 +29,7 @@ class TestBuiltinScheduler(unittest.TestCase): self.__scheduler.cancel(event2) self.assertEqual(self.__scheduler.queue, []) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/resmokelib/utils/test_version_comparison.py b/buildscripts/tests/resmokelib/utils/test_version_comparison.py index 4c92b2bb3d1..e10810b6dd4 100644 --- a/buildscripts/tests/resmokelib/utils/test_version_comparison.py +++ b/buildscripts/tests/resmokelib/utils/test_version_comparison.py @@ -56,3 +56,7 @@ class TestCompareBinVersions(unittest.TestCase): self.assertGreaterEqual(version_comparison.compare_bin_versions("8.3.0", "8.3"), 0) self.assertLess(version_comparison.compare_bin_versions("8.2", "8.3"), 0) self.assertGreater(version_comparison.compare_bin_versions("8.4", "8.3"), 0) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/sbom_linter/test_sbom.py b/buildscripts/tests/sbom_linter/test_sbom.py index 373dccf1996..049c342f4db 100644 --- a/buildscripts/tests/sbom_linter/test_sbom.py +++ b/buildscripts/tests/sbom_linter/test_sbom.py @@ -141,3 +141,7 @@ class TestSbom(unittest.TestCase): if not error_manager.zero_error(): error_manager.print_errors() self.assertTrue(error_manager.zero_error()) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_activate_task.py b/buildscripts/tests/test_activate_task.py index 989fb7634af..df33deca4b4 100644 --- a/buildscripts/tests/test_activate_task.py +++ b/buildscripts/tests/test_activate_task.py @@ -176,3 +176,7 @@ class TestActivateTask(unittest.TestCase): "Could not determine the build variant for patch activation from build build_id", ): under_test.main("archive_dist_test_debug") + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_debugsymb_mapper.py b/buildscripts/tests/test_debugsymb_mapper.py index 8e23e4e73f7..a87338bf047 100644 --- a/buildscripts/tests/test_debugsymb_mapper.py +++ b/buildscripts/tests/test_debugsymb_mapper.py @@ -120,3 +120,7 @@ class TestGetBinVersion(TestCmdOutputExtractor): bin_version_output = self.cmd_output_extractor.get_bin_version("path/to/bin") self.assertIsNone(bin_version_output.mongodb_version) self.assertEqual(bin_version_output.cmd_output, version_cmd_output) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_errorcodes.py b/buildscripts/tests/test_errorcodes.py index 6414e516810..65daf348052 100644 --- a/buildscripts/tests/test_errorcodes.py +++ b/buildscripts/tests/test_errorcodes.py @@ -67,3 +67,7 @@ class TestErrorcodes(unittest.TestCase): self.assertEqual(1234, errorcodes.coerce_to_number("server-1234")) self.assertEqual(1234, errorcodes.coerce_to_number("SERVER-1234")) self.assertEqual(-1, errorcodes.coerce_to_number("not a ticket")) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_evergreen_resmoke_job_count.py b/buildscripts/tests/test_evergreen_resmoke_job_count.py index 8e2ab75c3ea..ffe71402e48 100644 --- a/buildscripts/tests/test_evergreen_resmoke_job_count.py +++ b/buildscripts/tests/test_evergreen_resmoke_job_count.py @@ -144,3 +144,7 @@ class DetermineJobsTest(unittest.TestCase): job_count_matching = under_test.determine_jobs(task, variant, distro, jobs_max=jobs_default) self.assertEqual(jobs_default, job_count_matching) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_evergreen_task_tags.py b/buildscripts/tests/test_evergreen_task_tags.py index f9da42e80da..8279bf09a2d 100644 --- a/buildscripts/tests/test_evergreen_task_tags.py +++ b/buildscripts/tests/test_evergreen_task_tags.py @@ -126,3 +126,7 @@ class TestGetAllTasks(unittest.TestCase): task_list = ett.get_all_tasks(evg_config, variant) self.assertEqual(evg_config.get_variant.return_value.task_names, task_list) evg_config.get_variant.assert_called_with(variant) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_evergreen_task_timeout.py b/buildscripts/tests/test_evergreen_task_timeout.py index 81832669892..e6e9afffe22 100644 --- a/buildscripts/tests/test_evergreen_task_timeout.py +++ b/buildscripts/tests/test_evergreen_task_timeout.py @@ -431,3 +431,7 @@ class TestDetermineIdleTimeout(unittest.TestCase): timeout_override=3, expected_timeout=timedelta(minutes=3), ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_exception_extractor.py b/buildscripts/tests/test_exception_extractor.py index e370f1e48b1..b656f3f9164 100644 --- a/buildscripts/tests/test_exception_extractor.py +++ b/buildscripts/tests/test_exception_extractor.py @@ -251,3 +251,7 @@ class TestExceptionExtractor(unittest.TestCase): assert extractor.active is True assert extractor.exception_detected is False assert extractor.get_exception() == [] + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_feature_flag_tags_check.py b/buildscripts/tests/test_feature_flag_tags_check.py index 73ff0c7d762..47aa2c29426 100644 --- a/buildscripts/tests/test_feature_flag_tags_check.py +++ b/buildscripts/tests/test_feature_flag_tags_check.py @@ -35,3 +35,7 @@ class TestFindTestsInGitDiff(unittest.TestCase): tests = ["some/non/existent/jstest_file.js"] result = feature_flag_tags_check.get_tests_missing_fcv_tag(tests) self.assertCountEqual([], result) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_feature_flags.py b/buildscripts/tests/test_feature_flags.py index 4dcaf741778..82601dc3ff2 100644 --- a/buildscripts/tests/test_feature_flags.py +++ b/buildscripts/tests/test_feature_flags.py @@ -22,3 +22,7 @@ class TestFeatureFlags(unittest.TestCase): fully_disabled_flags, f"Feature flag {flag} defaults to true but is listed as fully disabled.", ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_jepsen_report.py b/buildscripts/tests/test_jepsen_report.py index 63a7a3745ad..187755c1068 100644 --- a/buildscripts/tests/test_jepsen_report.py +++ b/buildscripts/tests/test_jepsen_report.py @@ -202,3 +202,7 @@ Everything looks good! ヽ(‘ー`)ノ self.assertEqual(result.exit_code, 1) else: self.assertEqual(result.exit_code, 0) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_legacy_commands_check.py b/buildscripts/tests/test_legacy_commands_check.py index 812f272b8b2..9c5d1b3659e 100644 --- a/buildscripts/tests/test_legacy_commands_check.py +++ b/buildscripts/tests/test_legacy_commands_check.py @@ -66,3 +66,7 @@ class TestCheckFileForLegacyType(unittest.TestCase): modified_lines = [(0, ""), (1, "class AddShardCmd : public CommandInvocationHooks")] self.assertEqual(check_file_for_legacy_type(modified_lines), False) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_mongosymb.py b/buildscripts/tests/test_mongosymb.py index cdbb601e30e..d832de7bd3b 100644 --- a/buildscripts/tests/test_mongosymb.py +++ b/buildscripts/tests/test_mongosymb.py @@ -66,3 +66,7 @@ class TestHasHighNotFoundPathsRatio(unittest.TestCase): frames = [] ret = under_test.has_high_not_found_paths_ratio(frames) self.assertEqual(ret, False) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_packager.py b/buildscripts/tests/test_packager.py index b34c0a7ba34..6b184c4db04 100644 --- a/buildscripts/tests/test_packager.py +++ b/buildscripts/tests/test_packager.py @@ -1,5 +1,6 @@ """Unit tests for the packager script.""" +import unittest from dataclasses import dataclass from unittest import TestCase @@ -89,3 +90,7 @@ class TestPackager(TestCase): with self.subTest(name=case.name): spec = Spec(ver=case.version) self.assertEqual(spec.suffix(), case.want) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_powercycle_sentinel.py b/buildscripts/tests/test_powercycle_sentinel.py index 568c8b9aa8f..24a05929734 100644 --- a/buildscripts/tests/test_powercycle_sentinel.py +++ b/buildscripts/tests/test_powercycle_sentinel.py @@ -58,3 +58,7 @@ class TestWatchTasks(unittest.TestCase): ) long_running_task_ids = watch_tasks(task_ids, evg_api, 0) self.assertEqual([task_2.task_id], long_running_task_ids) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_simple_report.py b/buildscripts/tests/test_simple_report.py index 8c3c323a351..5ae41024c57 100644 --- a/buildscripts/tests/test_simple_report.py +++ b/buildscripts/tests/test_simple_report.py @@ -54,3 +54,7 @@ class TestSimpleReport(unittest.TestCase): self.assertEqual(results[0]["status"], "fail") self.assertEqual(report["failures"], 1) self.assertEqual(result.exit_code, 0) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_todo_check.py b/buildscripts/tests/test_todo_check.py index cc678a3806a..d31398b3054 100644 --- a/buildscripts/tests/test_todo_check.py +++ b/buildscripts/tests/test_todo_check.py @@ -262,3 +262,7 @@ class TestWalkFs(unittest.TestCase): under_test.walk_fs(tmpdir, visit_file) self.assertDictEqual(expected_files, seen_files) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_todo_linter.py b/buildscripts/tests/test_todo_linter.py index 2a71f5d3e65..f65caecf399 100644 --- a/buildscripts/tests/test_todo_linter.py +++ b/buildscripts/tests/test_todo_linter.py @@ -67,3 +67,7 @@ class TestLintFiles(unittest.TestCase): under_test._lint_files(["buildscripts/todo_linter.py"]) self.assertEqual(context.exception.code, 1) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_validate_commit_message.py b/buildscripts/tests/test_validate_commit_message.py index 64ec98fa69f..a28fb1c584f 100644 --- a/buildscripts/tests/test_validate_commit_message.py +++ b/buildscripts/tests/test_validate_commit_message.py @@ -234,3 +234,7 @@ class ValidateCommitMessageTest(unittest.TestCase): commits[0].message, "SERVER-1234 Add a ton of great support (#32823)\nThis PR adds back support for a lot of things\nMany great things!", ) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_validate_evg_project_config.py b/buildscripts/tests/test_validate_evg_project_config.py index 792d98e0379..ed614c88d60 100644 --- a/buildscripts/tests/test_validate_evg_project_config.py +++ b/buildscripts/tests/test_validate_evg_project_config.py @@ -66,3 +66,6 @@ class TestMessagesToReport(unittest.TestCase): # 'foo' optional comma + whitespace + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/test_validate_mongocryptd.py b/buildscripts/tests/test_validate_mongocryptd.py index 07727bc7b36..2960fd5da92 100644 --- a/buildscripts/tests/test_validate_mongocryptd.py +++ b/buildscripts/tests/test_validate_mongocryptd.py @@ -59,3 +59,7 @@ class TestReadVariableFromYml(unittest.TestCase): yaml_mock.safe_load.return_value = mock_nodes self.assertEqual(expected_value, under_test.read_variable_from_yml("filename", search_key)) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/timeouts/BUILD.bazel b/buildscripts/tests/timeouts/BUILD.bazel index e0d1a0e26a7..c06a9c6d082 100644 --- a/buildscripts/tests/timeouts/BUILD.bazel +++ b/buildscripts/tests/timeouts/BUILD.bazel @@ -1,8 +1,32 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_timeout", + srcs = [ + "__init__.py", + "test_timeout.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/timeouts:timeout", + ], +) + +py_test( + name = "test_timeout_service", + srcs = [ + "__init__.py", + "test_timeout_service.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/resmoke_proxy", + "//buildscripts/timeouts:timeout_service", + "//buildscripts/util", + dependency( + "requests", + group = "core", + ), + ], ) diff --git a/buildscripts/tests/timeouts/test_timeout.py b/buildscripts/tests/timeouts/test_timeout.py index 1ea4890e0a4..f2045709218 100644 --- a/buildscripts/tests/timeouts/test_timeout.py +++ b/buildscripts/tests/timeouts/test_timeout.py @@ -109,3 +109,7 @@ class TestTimeoutInfo(unittest.TestCase): def test_override_with_no_values(self): with self.assertRaises(ValueError): under_test.TimeoutInfo.overridden() + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/timeouts/test_timeout_service.py b/buildscripts/tests/timeouts/test_timeout_service.py index 8aace381353..ce7ac42d040 100644 --- a/buildscripts/tests/timeouts/test_timeout_service.py +++ b/buildscripts/tests/timeouts/test_timeout_service.py @@ -391,3 +391,7 @@ class TestHaveEnoughHistoricStats(unittest.TestCase): timeout_service._have_enough_historic_stats(num_tests=-1, num_tests_missing_data=0) with self.assertRaises(ValueError): timeout_service._have_enough_historic_stats(num_tests=-100, num_tests_missing_data=0) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/util/BUILD.bazel b/buildscripts/tests/util/BUILD.bazel index e0d1a0e26a7..a0f65d723f1 100644 --- a/buildscripts/tests/util/BUILD.bazel +++ b/buildscripts/tests/util/BUILD.bazel @@ -1,8 +1,86 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@poetry//:dependencies.bzl", "dependency") +load("@rules_python//python:defs.bzl", "py_test") -# TODO(SERVER-105817): The following library is autogenerated, please split these out into individual python targets -py_library( - name = "all_python_files", - srcs = glob(["*.py"]), +py_test( + name = "test_fileops", + srcs = [ + "__init__.py", + "test_fileops.py", + ], visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + ], +) + +py_test( + name = "test_read_config", + srcs = [ + "__init__.py", + "test_read_config.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + dependency( + "mock", + group = "testing", + ), + ], +) + +py_test( + name = "test_taskname", + srcs = [ + "__init__.py", + "test_taskname.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + ], +) + +py_test( + name = "test_testname", + srcs = [ + "__init__.py", + "test_testname.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + ], +) + +py_test( + name = "test_teststats", + srcs = [ + "__init__.py", + "test_teststats.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + dependency( + "mock", + group = "testing", + ), + dependency( + "requests", + group = "core", + ), + ], +) + +py_test( + name = "test_time", + srcs = [ + "__init__.py", + "test_time.py", + ], + visibility = ["//visibility:public"], + deps = [ + "//buildscripts/util", + ], ) diff --git a/buildscripts/tests/util/test_fileops.py b/buildscripts/tests/util/test_fileops.py index 743ae8e2359..1fbf8d69bad 100644 --- a/buildscripts/tests/util/test_fileops.py +++ b/buildscripts/tests/util/test_fileops.py @@ -25,3 +25,7 @@ class TestWriteFileToDir(unittest.TestCase): under_test.write_file_to_dir("dir", "file", "contents", overwrite=False) mock_write_file.assert_not_called() + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/util/test_read_config.py b/buildscripts/tests/util/test_read_config.py index 89e4d4f4984..0bef0683506 100644 --- a/buildscripts/tests/util/test_read_config.py +++ b/buildscripts/tests/util/test_read_config.py @@ -35,3 +35,7 @@ class TestGetConfigValue(unittest.TestCase): ) self.assertEqual("cmdline value", value) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/util/test_taskname.py b/buildscripts/tests/util/test_taskname.py index 7873bfa1da2..2147bdc033f 100644 --- a/buildscripts/tests/util/test_taskname.py +++ b/buildscripts/tests/util/test_taskname.py @@ -50,3 +50,7 @@ class TestDetermineTaskBaseName(unittest.TestCase): base_task_name = under_test.determine_task_base_name(task_name, bv) self.assertEqual("auth", base_task_name) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/util/test_testname.py b/buildscripts/tests/util/test_testname.py index 3c814acd332..66b3e29ab56 100644 --- a/buildscripts/tests/util/test_testname.py +++ b/buildscripts/tests/util/test_testname.py @@ -80,3 +80,7 @@ class DenormalizeTestFileTest(unittest.TestCase): unix_file = "test/found/under/unix.sh" expected = [unix_file, "test\\found\\under\\unix.sh"] self.assertEqual(expected, testname_utils.denormalize_test_file(unix_file)) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/util/test_teststats.py b/buildscripts/tests/util/test_teststats.py index c963c476fef..e78d926caa5 100644 --- a/buildscripts/tests/util/test_teststats.py +++ b/buildscripts/tests/util/test_teststats.py @@ -199,3 +199,7 @@ class TestHistoricTaskData(unittest.TestCase): result = under_test.HistoricTaskData.get_stats_from_s3("project", "task", "variant") self.assertEqual(result, []) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/tests/util/test_time.py b/buildscripts/tests/util/test_time.py index 813c4e9684e..72cb7fdec2b 100644 --- a/buildscripts/tests/util/test_time.py +++ b/buildscripts/tests/util/test_time.py @@ -8,3 +8,7 @@ from buildscripts.util import time as time_utils class Ns2SecTest(unittest.TestCase): def test_ns_converted_to_seconds(self): self.assertEqual(time_utils.ns2sec(10**9), 1) + + +if __name__ == "__main__": + unittest.main() diff --git a/buildscripts/timeouts/BUILD.bazel b/buildscripts/timeouts/BUILD.bazel index c7c0b5b5f21..40046ac9403 100644 --- a/buildscripts/timeouts/BUILD.bazel +++ b/buildscripts/timeouts/BUILD.bazel @@ -10,6 +10,10 @@ py_library( "shrub-py", group = "testing", ), + dependency( + "structlog", + group = "evergreen", + ), ], ) diff --git a/buildscripts/util/BUILD.bazel b/buildscripts/util/BUILD.bazel index 4eb231893ec..d067c9a0bdc 100644 --- a/buildscripts/util/BUILD.bazel +++ b/buildscripts/util/BUILD.bazel @@ -38,6 +38,10 @@ py_library( "pkce", group = "testing", ), + dependency( + "pydantic", + group = "evergreen", + ), dependency( "requests-oauthlib", group = "testing",