parameters: (old_bin_version: str, output: str, logger: logging.Logger)
docstring: Create a tag file associating multiversion tests to tags for exclusion.
  
      Compares the BACKPORTS_REQUIRED_FILE on the current branch with the same file on the
      last-lts and/or last-continuous branch to determine which tests should be denylisted.
docstring_summary: Create a tag file associating multiversion tests to tags for exclusion.
docstring_tokens: Create a tag file associating multiversion tests to tags for exclusion .
function: def generate_exclude_yaml(old_bin_version: str, output: str, logger: logging.Logger) -> None:
      """
      Create a tag file associating multiversion tests to tags for exclusion.
  
      Compares the BACKPORTS_REQUIRED_FILE on the current branch with the same file on the
      last-lts and/or last-continuous branch to determine which tests should be denylisted.
      """
  
      output = os.path.abspath(output)
      location, _ = os.path.split(output)
      if not os.path.isdir(location):
          logger.info(f"Cannot write to {output}. Not generating tag file.")
          return
  
      backports_required_latest = read_yaml_file(os.path.join(ETC_DIR, BACKPORTS_REQUIRED_FILE))
  
      # Get the state of the backports_required_for_multiversion_tests.yml file for the old
      # binary we are running tests against. We do this by using the commit hash from the old
      # mongo shell executable.
      from buildscripts.resmokelib import multiversionconstants
  
      shell_version = {
          MultiversionOptions.LAST_LTS: multiversionconstants.LAST_LTS_MONGO_BINARY,
          MultiversionOptions.LAST_CONTINUOUS: multiversionconstants.LAST_CONTINUOUS_MONGO_BINARY,
      }[old_bin_version]
  
      old_version_commit_hash = get_backports_required_hash_for_shell_version(
          mongo_shell_path=shell_version)
  
      # Get the yaml contents from the old commit.
      logger.info(f"Downloading file from commit hash of old branch {old_version_commit_hash}")
      backports_required_old = get_old_yaml(old_version_commit_hash)
  
      def diff(list1, list2):
          return [elem for elem in (list1 or []) if elem not in (list2 or [])]
  
      def get_suite_exclusions(version_key):
  
          _suites_latest = backports_required_latest[version_key]["suites"] or {}
          # Check if the changed syntax for etc/backports_required_for_multiversion_tests.yml has been
          # backported.
          # This variable and all branches where it's not set can be deleted after backporting the change.
          change_backported = version_key in backports_required_old.keys()
          if change_backported:
              _always_exclude = diff(backports_required_latest[version_key]["all"],
                                     backports_required_old[version_key]["all"])
              _suites_old: defaultdict = defaultdict(
                  list, backports_required_old[version_key]["suites"] or {})
          else:
              _always_exclude = diff(backports_required_latest[version_key]["all"],
                                     backports_required_old["all"])
              _suites_old: defaultdict = defaultdict(list, backports_required_old["suites"] or {})
  
          return _suites_latest, _suites_old, _always_exclude
  
      suites_latest, suites_old, always_exclude = get_suite_exclusions(
          old_bin_version.replace("_", "-"))
  
      tags = _tags.TagsConfig()
  
      # Tag tests that are excluded from every suite.
      for elem in always_exclude:
          tags.add_tag("js_test", elem["test_file"], BACKPORT_REQUIRED_TAG)
  
      # Tag tests that are excluded on a suite-by-suite basis.
      for suite in suites_latest.keys():
          test_set = set()
          for elem in diff(suites_latest[suite], suites_old[suite]):
              test_set.add(elem["test_file"])
          for test in test_set:
              tags.add_tag("js_test", test, f"{suite}_{BACKPORT_REQUIRED_TAG}")
  
      logger.info(f"Writing exclude tags to {output}.")
      tags.write_file(filename=output,
                      preamble="Tag file that specifies exclusions from multiversion suites.")
function_tokens: def generate_exclude_yaml ( old_bin_version : str , output : str , logger : logging . Logger ) -> None : output = os . path . abspath ( output ) location , _ = os . path . split ( output ) if not os . path . isdir ( location ) : logger . info ( f"Cannot write to {output}. Not generating tag file." ) return backports_required_latest = read_yaml_file ( os . path . join ( ETC_DIR , BACKPORTS_REQUIRED_FILE ) ) # Get the state of the backports_required_for_multiversion_tests.yml file for the old # binary we are running tests against. We do this by using the commit hash from the old # mongo shell executable. from buildscripts . resmokelib import multiversionconstants shell_version = { MultiversionOptions . LAST_LTS : multiversionconstants . LAST_LTS_MONGO_BINARY , MultiversionOptions . LAST_CONTINUOUS : multiversionconstants . LAST_CONTINUOUS_MONGO_BINARY , } [ old_bin_version ] old_version_commit_hash = get_backports_required_hash_for_shell_version ( mongo_shell_path = shell_version ) # Get the yaml contents from the old commit. logger . info ( f"Downloading file from commit hash of old branch {old_version_commit_hash}" ) backports_required_old = get_old_yaml ( old_version_commit_hash ) def diff ( list1 , list2 ) : return [ elem for elem in ( list1 or [ ] ) if elem not in ( list2 or [ ] ) ] def get_suite_exclusions ( version_key ) : _suites_latest = backports_required_latest [ version_key ] [ "suites" ] or { } # Check if the changed syntax for etc/backports_required_for_multiversion_tests.yml has been # backported. # This variable and all branches where it's not set can be deleted after backporting the change. change_backported = version_key in backports_required_old . keys ( ) if change_backported : _always_exclude = diff ( backports_required_latest [ version_key ] [ "all" ] , backports_required_old [ version_key ] [ "all" ] ) _suites_old : defaultdict = defaultdict ( list , backports_required_old [ version_key ] [ "suites" ] or { } ) else : _always_exclude = diff ( backports_required_latest [ version_key ] [ "all" ] , backports_required_old [ "all" ] ) _suites_old : defaultdict = defaultdict ( list , backports_required_old [ "suites" ] or { } ) return _suites_latest , _suites_old , _always_exclude suites_latest , suites_old , always_exclude = get_suite_exclusions ( old_bin_version . replace ( "_" , "-" ) ) tags = _tags . TagsConfig ( ) # Tag tests that are excluded from every suite. for elem in always_exclude : tags . add_tag ( "js_test" , elem [ "test_file" ] , BACKPORT_REQUIRED_TAG ) # Tag tests that are excluded on a suite-by-suite basis. for suite in suites_latest . keys ( ) : test_set = set ( ) for elem in diff ( suites_latest [ suite ] , suites_old [ suite ] ) : test_set . add ( elem [ "test_file" ] ) for test in test_set : tags . add_tag ( "js_test" , test , f"{suite}_{BACKPORT_REQUIRED_TAG}" ) logger . info ( f"Writing exclude tags to {output}." ) tags . write_file ( filename = output , preamble = "Tag file that specifies exclusions from multiversion suites." )