Python tests can error out with a very esoteric error, improve it.

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Engines, Storage Engines - Foundations
    • None
    • 1
    • 0

      If a test file has a bug in it, and we run with batching, sometimes the following error is produced:

      Traceback (most recent call last):
        File "/home/ubuntu/skunk/build/../test/suite/run.py", line 603, in get_sort_keys
          name = test.simpleName()
      AttributeError: 'ModuleImportFailure' object has no attribute 'simpleName'
      

      This error can be very hard to track down, it originates from:

              def get_sort_keys(test):
                  s = 0
                  name = test.simpleName()
                  if hasattr(test, 'scenario_number'):
                      s = test.scenario_number
                      if s > 1000:
                          hugetests.add(name)    # warn for too many scenarios
                  return (s, test.simpleName())  # sort by scenario number first 

      The simpleName function may just not work, now I didn't figure out exactly why but I determined that if there is a bug in the test file itself (e.g. test_rollback_to_stable99.py), then sometimes the simpleName function won't be registered. To improve the dev experience if this error occurs again in the future we can simply try/except the code:

              def get_sort_keys(test):
                  s = 0
                  try:
                      name = test.simpleName()
                  except:
                      print("Failed to find the name of a test, likely there is a bug in this test file: " + str(test))
                      exit(1)
                  if hasattr(test, 'scenario_number'):
                      s = test.scenario_number
                      if s > 1000:
                          hugetests.add(name)    # warn for too many scenarios
                  return (s, test.simpleName())  # sort by scenario number first
       

      This way the error goes from:

       Traceback (most recent call last):
        File "/home/ubuntu/skunk/build/../test/suite/run.py", line 603, in get_sort_keys
          name = test.simpleName()
      AttributeError: 'ModuleImportFailure' object has no attribute 'simpleName'

      To:

      $ python3 ../test/suite/run.py  -b 1/2
      Failed to find the name of a test, likely there is a bug in this test file: test_rollback_to_stable23 (discover.ModuleImportFailure) 

      This is much easier to track down.

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Luke Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: