compatibility_version.py: "this" branch incorrectly rejected due to if/else instead of if/elif

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Test Compatibility
    • Storage Engines - Foundations
    • 384.043
    • None
    • None

      Summary

      The branch handling in test/compatibility/common/compatibility_version.py (WTVersion.{}init{}) is incorrect. It uses two separate if statements instead of an if/elif chain, and the else clause is attached only to the second if. As a result the "this" branch, one of the valid options, is rejected.

      if name == "this":
          self.group = 2
      if name == "develop":          # should be elif
          self.group = 1
      else:
          # Match patterns like mongodb-8.0
          match = re.match(r'^mongodb-(\d+)\.(\d+)$', name)
          if match:
              self.major = int(match.group(1))
              self.minor = int(match.group(2))
          else:
              self.is_valid = False
      

      When name == "this":

      • The first if correctly sets group = 2.
      • The second if name == "develop" is False, so it falls into its else, which runs the mongodb-X.Y regex against "this".
      • The regex fails to match, so is_valid = False.

      This makes the WT version "this" falsy (via bool) and rejects the this branch, which was supposed to be a valid option (it represents the code in the current folder, for which git checkout is skipped).

      Fix

      Change the second if to elif so the three cases (this, develop, mongodb-X.Y) are handled correctly:

      if name == "this":
          self.group = 2
      elif name == "develop":
          self.group = 1
      else:
          match = re.match(r'^mongodb-(\d+)\.(\d+)$', name)
          ...
      

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Jasmine Bi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: