SERVER-67405: Fix is_patch lookup for build_variant_gen

(cherry picked from commit 1260ae9d64)
This commit is contained in:
David Bradford 2022-06-21 14:33:43 -04:00 committed by Evergreen Agent
parent 4f9e10bb30
commit 08077e4d70
2 changed files with 70 additions and 5 deletions

View File

@ -59,7 +59,7 @@ class EvgExpansions(BaseModel):
build_id: str
build_variant: str
exec_timeout_secs: Optional[int] = None
is_patch: Optional[bool]
is_patch: Optional[str]
project: str
max_tests_per_suite: Optional[int] = 100
max_sub_suites: Optional[int] = 5
@ -83,10 +83,21 @@ class EvgExpansions(BaseModel):
def get_max_sub_suites(self) -> int:
"""Get the max_sub_suites to use."""
if not self.is_patch:
if not self.determine_is_patch():
return self.mainline_max_sub_suites
return self.max_sub_suites
def determine_is_patch(self) -> bool:
"""
Determine if expansions indicate whether the script is being run in a patch build.
In a patch build, the `is_patch` expansion will be the string value of "true". In a
non-patch setting, it will not exist, or be an empty string.
:return: True if task is being run in a patch build.
"""
return self.is_patch is not None and self.is_patch.lower() == "true"
def build_suite_split_config(self, start_date: datetime,
end_date: datetime) -> SuiteSplitConfig:
"""
@ -113,7 +124,7 @@ class EvgExpansions(BaseModel):
"""
return GenTaskOptions(
create_misc_suite=True,
is_patch=self.is_patch,
is_patch=self.determine_is_patch(),
generated_config_dir=GENERATED_CONFIG_DIR,
use_default_timeouts=False,
timeout_secs=self.timeout_secs,

View File

@ -87,7 +87,7 @@ def build_mock_orchestrator(build_expansions=None, task_def_list=None, build_tas
class TestEvgExpansions(unittest.TestCase):
def test_get_max_sub_suites_should_use_patch_value_in_patches(self):
evg_expansions = under_test.EvgExpansions(
is_patch=True,
is_patch="true",
max_sub_suites=5,
mainline_max_sub_suites=1,
build_id="build_id",
@ -102,7 +102,7 @@ class TestEvgExpansions(unittest.TestCase):
def test_get_max_sub_suites_should_use_mainline_value_in_non_patches(self):
evg_expansions = under_test.EvgExpansions(
is_patch=False,
is_patch="false",
max_sub_suites=5,
mainline_max_sub_suites=1,
build_id="build_id",
@ -133,6 +133,60 @@ class TestEvgExpansions(unittest.TestCase):
evg_expansions.mainline_max_sub_suites)
class TestDetermineIsPatch(unittest.TestCase):
def test_is_patch_is_none_should_return_false(self):
evg_expansions = under_test.EvgExpansions(
is_patch=None,
build_id="build_id",
build_variant="build variant",
project="project",
revision="abc123",
task_name="task name",
task_id="task_314",
)
self.assertFalse(evg_expansions.determine_is_patch())
def test_is_patch_is_false_should_return_false(self):
evg_expansions = under_test.EvgExpansions(
is_patch="false",
build_id="build_id",
build_variant="build variant",
project="project",
revision="abc123",
task_name="task name",
task_id="task_314",
)
self.assertFalse(evg_expansions.determine_is_patch())
def test_is_patch_is_empty_string_should_return_false(self):
evg_expansions = under_test.EvgExpansions(
is_patch="",
build_id="build_id",
build_variant="build variant",
project="project",
revision="abc123",
task_name="task name",
task_id="task_314",
)
self.assertFalse(evg_expansions.determine_is_patch())
def test_is_patch_is_true_should_return_true(self):
evg_expansions = under_test.EvgExpansions(
is_patch="true",
build_id="build_id",
build_variant="build variant",
project="project",
revision="abc123",
task_name="task name",
task_id="task_314",
)
self.assertTrue(evg_expansions.determine_is_patch())
class TestTranslateRunVar(unittest.TestCase):
def test_normal_value_should_be_returned(self):
run_var = "some value"