SERVER-126361 Enforce sorting of etc/backports_required_for_multiversion_tests.yml (#54061)
GitOrigin-RevId: 7ad06d02d9d53c5d6098c6cfa61725527d1ed7ba
This commit is contained in:
parent
84e5faf941
commit
ebfca3c2a0
@ -26,6 +26,7 @@ py_binary(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//buildscripts:bazel_custom_formatter",
|
||||
"//buildscripts:sort_backport_multiversion",
|
||||
"@bazel_rules_mongo//utils:evergreen_git",
|
||||
dependency(
|
||||
"gitpython",
|
||||
|
||||
@ -13,6 +13,7 @@ from buildscripts.bazel_custom_formatter import (
|
||||
validate_idl_naming,
|
||||
validate_private_headers,
|
||||
)
|
||||
from buildscripts.sort_backport_multiversion import sort_backport_multiversion
|
||||
|
||||
|
||||
def _git_distance(args: list) -> int:
|
||||
@ -253,9 +254,25 @@ def main() -> int:
|
||||
if files_to_format != "all":
|
||||
files_to_format = [str(file) for file in files_to_format if os.path.isfile(file)]
|
||||
|
||||
def files_to_format_contain_backports(files: Union[list[str], str]) -> bool:
|
||||
if files == "all":
|
||||
return True
|
||||
return any("backports_required_for_multiversion_tests" in f for f in files)
|
||||
|
||||
backports_ok = True
|
||||
if files_to_format_contain_backports(files_to_format):
|
||||
print("Sorting etc/backports_required_for_multiversion_tests.yml")
|
||||
backports_ok = sort_backport_multiversion(
|
||||
check=args.check,
|
||||
path=pathlib.Path(default_dir)
|
||||
/ "etc"
|
||||
/ "backports_required_for_multiversion_tests.yml",
|
||||
)
|
||||
|
||||
return (
|
||||
0
|
||||
if run_prettier(prettier_path, args.check, files_to_format)
|
||||
if backports_ok
|
||||
and run_prettier(prettier_path, args.check, files_to_format)
|
||||
and run_rules_lint(
|
||||
args.rules_lint_format, args.rules_lint_format_check, args.check, files_to_format
|
||||
)
|
||||
|
||||
@ -50,6 +50,33 @@ def _sort_all_entries(yml_data: dict) -> None:
|
||||
entries.sort(key=lambda e: (e["test_file"], e["ticket"]))
|
||||
|
||||
|
||||
def sort_backport_multiversion(check: bool = False, path: Path = BACKPORTS_FILE) -> bool:
|
||||
"""Sort (or check) the backports file. Returns True if successful."""
|
||||
backports_file_str = path.read_text()
|
||||
header = _extract_header(backports_file_str)
|
||||
data = yaml.safe_load(backports_file_str)
|
||||
_sort_all_entries(data)
|
||||
sorted_content = header + yaml.dump(
|
||||
data,
|
||||
Dumper=_IndentedDumper,
|
||||
default_flow_style=False,
|
||||
sort_keys=False,
|
||||
indent=2,
|
||||
allow_unicode=True,
|
||||
)
|
||||
if check:
|
||||
if backports_file_str != sorted_content:
|
||||
print(
|
||||
"etc/backports_required_for_multiversion_tests.yml is not sorted.\n"
|
||||
"Run 'bazel run //:format' to fix it."
|
||||
)
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
path.write_text(sorted_content)
|
||||
return True
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
@ -69,28 +96,8 @@ def main() -> None:
|
||||
if args.fix and args.check:
|
||||
parser.error("--fix and --check are mutually exclusive.")
|
||||
|
||||
backports_file_str = BACKPORTS_FILE.read_text()
|
||||
header = _extract_header(backports_file_str)
|
||||
data = yaml.safe_load(backports_file_str)
|
||||
_sort_all_entries(data)
|
||||
sorted_content = header + yaml.dump(
|
||||
data,
|
||||
Dumper=_IndentedDumper,
|
||||
default_flow_style=False,
|
||||
sort_keys=False,
|
||||
indent=2,
|
||||
allow_unicode=True,
|
||||
)
|
||||
|
||||
if args.check:
|
||||
if backports_file_str != sorted_content:
|
||||
print(
|
||||
"etc/backports_required_for_multiversion_tests.yml is not sorted.\n"
|
||||
"Run buildscripts/sort_backport_multiversion.py --fix to fix it."
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
BACKPORTS_FILE.write_text(sorted_content)
|
||||
if not sort_backport_multiversion(check=args.check):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -47,22 +47,22 @@ last-continuous:
|
||||
ticket: SERVER-125661
|
||||
- test_file: jstests/noPassthrough/sharded_cluster_topology/shard_registry_rsm_removal_race.js
|
||||
ticket: SERVER-123567
|
||||
- test_file: jstests/replsets/initial_sync_check_initiating_set_oplog_entry.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_commit_prepared_transaction.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_replSetGetStatus.js
|
||||
ticket: SERVER-121218
|
||||
- test_file: jstests/replsets/initial_sync_test_fixture_test.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/server_status_metrics.js
|
||||
ticket: SERVER-120318
|
||||
- test_file: jstests/sharding/chunk_migration_maxkey_boundary.js
|
||||
ticket: SERVER-121533
|
||||
- test_file: jstests/replsets/initial_sync_test_fixture_test.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_check_initiating_set_oplog_entry.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_commit_prepared_transaction.js
|
||||
ticket: SERVER-113184
|
||||
suites: null
|
||||
last-lts:
|
||||
all:
|
||||
@ -458,16 +458,28 @@ last-lts:
|
||||
ticket: SERVER-106165
|
||||
- test_file: jstests/replsets/election_term_over_int_max.js
|
||||
ticket: SERVER-119413
|
||||
- test_file: jstests/replsets/index_builds/rollback_index_build_start_abort.js
|
||||
ticket: SERVER-103955
|
||||
- test_file: jstests/replsets/initial_sync_check_initiating_set_oplog_entry.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_collStats_resumes_after_network_error.js
|
||||
ticket: SERVER-94259
|
||||
- test_file: jstests/replsets/initial_sync_commit_prepared_transaction.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_during_stepdown.js
|
||||
ticket: SERVER-89664
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_index_conflict_recreate.js
|
||||
ticket: SERVER-93141
|
||||
- test_file: jstests/replsets/initial_sync_replSetGetStatus.js
|
||||
ticket: SERVER-121218
|
||||
- test_file: jstests/replsets/initial_sync_survives_restart.js
|
||||
ticket: SERVER-88447
|
||||
- test_file: jstests/replsets/initial_sync_test_fixture_test.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/large_dockey_succeeds_on_secondary.js
|
||||
ticket: SERVER-104405
|
||||
- test_file: jstests/replsets/log_unprepared_abort_txns.js
|
||||
@ -490,8 +502,6 @@ last-lts:
|
||||
ticket: SERVER-89618
|
||||
- test_file: jstests/replsets/retryable_write_interrupted_on_stepdown.js
|
||||
ticket: SERVER-110728
|
||||
- test_file: jstests/replsets/index_builds/rollback_index_build_start_abort.js
|
||||
ticket: SERVER-103955
|
||||
- test_file: jstests/replsets/rollback_with_coalesced_txn_table_updates_during_oplog_application_inserts.js
|
||||
ticket: SERVER-99185
|
||||
- test_file: jstests/replsets/server_status_metrics.js
|
||||
@ -564,6 +574,8 @@ last-lts:
|
||||
ticket: SERVER-89630
|
||||
- test_file: jstests/sharding/flush_resharding_state_change_errors.js
|
||||
ticket: SERVER-107952
|
||||
- test_file: jstests/sharding/index_builds/resharding_index_builds_repl_lag.js
|
||||
ticket: SERVER-103566
|
||||
- test_file: jstests/sharding/index_not_cloned_on_non_owner_shards.js
|
||||
ticket: SERVER-102165
|
||||
- test_file: jstests/sharding/invalid_shard_identity_doc.js
|
||||
@ -646,8 +658,6 @@ last-lts:
|
||||
ticket: SERVER-89744
|
||||
- test_file: jstests/sharding/resharding_error_during_critical_section.js
|
||||
ticket: SERVER-114005
|
||||
- test_file: jstests/sharding/index_builds/resharding_index_builds_repl_lag.js
|
||||
ticket: SERVER-103566
|
||||
- test_file: jstests/sharding/resharding_oplog_fetcher_repl_lag.js
|
||||
ticket: SERVER-103554
|
||||
- test_file: jstests/sharding/resharding_skip_cloning_and_applying.js
|
||||
@ -754,14 +764,4 @@ last-lts:
|
||||
ticket: SERVER-91075
|
||||
- test_file: src/mongo/db/modules/enterprise/jstests/fle2/query/range/two_sided_find.js
|
||||
ticket: SERVER-91075
|
||||
- test_file: jstests/replsets/initial_sync_test_fixture_test.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_check_initiating_set_oplog_entry.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp_no_oplog_application.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_fetch_from_oldest_active_transaction_timestamp.js
|
||||
ticket: SERVER-113184
|
||||
- test_file: jstests/replsets/initial_sync_commit_prepared_transaction.js
|
||||
ticket: SERVER-113184
|
||||
suites: null
|
||||
|
||||
Loading…
Reference in New Issue
Block a user