diff options
author | David Bradford <david.bradford@mongodb.com> | 2022-03-17 18:09:41 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-02 13:48:01 +0000 |
commit | d03ca3eebefaca35c6d6f1238034f9a964679e79 (patch) | |
tree | 210477f9ac228d012f0601407752039c2b0c83c6 | |
parent | 0cd9f85a25b2edd2da55917c91f7428b05730361 (diff) | |
download | mongo-d03ca3eebefaca35c6d6f1238034f9a964679e79.tar.gz |
SERVER-61853: Sync get_named_suites lookups in resmoke
(cherry picked from commit ca7a22da6fb96561f0520c0b5084d32fc2bac67f)
-rw-r--r-- | buildscripts/resmokelib/suitesconfig.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/buildscripts/resmokelib/suitesconfig.py b/buildscripts/resmokelib/suitesconfig.py index e82cd697e8b..18fbc138611 100644 --- a/buildscripts/resmokelib/suitesconfig.py +++ b/buildscripts/resmokelib/suitesconfig.py @@ -1,13 +1,12 @@ """Module for retrieving the configuration of resmoke.py test suites.""" import collections import os - -from typing import List, Dict +from threading import Lock +from typing import Dict, List import buildscripts.resmokelib.utils.filesystem as fs from buildscripts.resmokelib import config as _config -from buildscripts.resmokelib import errors -from buildscripts.resmokelib import utils +from buildscripts.resmokelib import errors, utils from buildscripts.resmokelib.testing import suite as _suite from buildscripts.resmokelib.utils import load_yaml_file from buildscripts.resmokelib.utils.dictionary import merge_dicts @@ -141,6 +140,7 @@ class SuiteConfigInterface: class ExplicitSuiteConfig(SuiteConfigInterface): """Class for storing the resmoke.py suite YAML configuration.""" + _name_suites_lock = Lock() _named_suites = {} @classmethod @@ -164,17 +164,18 @@ class ExplicitSuiteConfig(SuiteConfigInterface): @classmethod def get_named_suites(cls) -> Dict[str, str]: """Populate the named suites by scanning config_dir/suites.""" - if not cls._named_suites: - suites_dir = os.path.join(_config.CONFIG_DIR, "suites") - root = os.path.abspath(suites_dir) - files = os.listdir(root) - for filename in files: - (short_name, ext) = os.path.splitext(filename) - if ext in (".yml", ".yaml"): - pathname = os.path.join(root, filename) - cls._named_suites[short_name] = pathname - - return cls._named_suites + with cls._name_suites_lock: + if not cls._named_suites: + suites_dir = os.path.join(_config.CONFIG_DIR, "suites") + root = os.path.abspath(suites_dir) + files = os.listdir(root) + for filename in files: + (short_name, ext) = os.path.splitext(filename) + if ext in (".yml", ".yaml"): + pathname = os.path.join(root, filename) + cls._named_suites[short_name] = pathname + + return cls._named_suites @classmethod def get_suite_files(cls): |