diff options
author | Lydia Stepanek <lydia.stepanek@mongodb.com> | 2019-05-17 17:17:03 -0400 |
---|---|---|
committer | Lydia Stepanek <lydia.stepanek@mongodb.com> | 2019-05-17 17:17:03 -0400 |
commit | 278e1936f837c260e037ce7e56ac93586247fa61 (patch) | |
tree | 1eb4919d3393b47d6930a033a6caaea2df98fac7 /buildscripts | |
parent | 006c92c7eef1c316b7ebef29d3e03e0ba6897c4a (diff) | |
download | mongo-278e1936f837c260e037ce7e56ac93586247fa61.tar.gz |
SERVER-41003 when generating suites, don't set repeat-suites if options is 1
Diffstat (limited to 'buildscripts')
-rwxr-xr-x | buildscripts/evergreen_generate_resmoke_tasks.py | 14 | ||||
-rw-r--r-- | buildscripts/tests/test_evergreen_generate_resmoke_tasks.py | 39 |
2 files changed, 50 insertions, 3 deletions
diff --git a/buildscripts/evergreen_generate_resmoke_tasks.py b/buildscripts/evergreen_generate_resmoke_tasks.py index b26495612bc..59adc23a458 100755 --- a/buildscripts/evergreen_generate_resmoke_tasks.py +++ b/buildscripts/evergreen_generate_resmoke_tasks.py @@ -97,6 +97,17 @@ def remove_gen_suffix(task_name): return task_name +def string_contains_any_of_args(string, args): + """ + Return whether array contains any of a group of args. + + :param string: String being checked. + :param args: Args being analyzed. + :return: True if any args are found in the string. + """ + return any(arg in string for arg in args) + + def get_config_options(cmd_line_options, config_file): """ Get the configuration to use for generated tests. @@ -326,7 +337,8 @@ class EvergreenConfigGenerator(object): def _generate_resmoke_args(self, suite_file): resmoke_args = "--suite={0}.yml --originSuite={1} {2}".format( suite_file, self.options.suite, self.options.resmoke_args) - if self.options.repeat_suites and "repeatSuites" not in resmoke_args: + if self.options.repeat_suites and not string_contains_any_of_args( + resmoke_args, ["repeatSuites", "repeat"]): resmoke_args += " --repeatSuites={0} ".format(self.options.repeat_suites) return resmoke_args diff --git a/buildscripts/tests/test_evergreen_generate_resmoke_tasks.py b/buildscripts/tests/test_evergreen_generate_resmoke_tasks.py index fcf708d3fd0..5537a15637d 100644 --- a/buildscripts/tests/test_evergreen_generate_resmoke_tasks.py +++ b/buildscripts/tests/test_evergreen_generate_resmoke_tasks.py @@ -11,8 +11,8 @@ import yaml from mock import patch, mock_open, call, Mock, MagicMock from buildscripts import evergreen_generate_resmoke_tasks as grt -from buildscripts.evergreen_generate_resmoke_tasks import render_suite, render_misc_suite, \ - prepare_directory_for_suite, remove_gen_suffix +from buildscripts.evergreen_generate_resmoke_tasks import string_contains_any_of_args, \ + prepare_directory_for_suite, remove_gen_suffix, render_suite, render_misc_suite # pylint: disable=missing-docstring,invalid-name,unused-argument,no-self-use,protected-access @@ -36,6 +36,21 @@ class TestHelperMethods(unittest.TestCase): self.assertEqual("sharded_multi_stmt_txn_jscore_passthroug", remove_gen_suffix(input_task_name)) + def test_string_contains_any_of_args(self): + args = ["repeatSuites", "repeat"] + string = "--suite=suite 0.yml --originSuite=suite resmoke_args --repeat=5" + self.assertEqual(True, string_contains_any_of_args(string, args)) + + def test_string_contains_any_of_args_for_empty_args(self): + args = [] + string = "--suite=suite 0.yml --originSuite=suite resmoke_args --repeat=5" + self.assertEqual(False, string_contains_any_of_args(string, args)) + + def test_string_contains_any_of_args_for_non_matching_args(self): + args = ["random_string_1", "random_string_2", "random_string_3"] + string = "--suite=suite 0.yml --originSuite=suite resmoke_args --repeat=5" + self.assertEqual(False, string_contains_any_of_args(string, args)) + class TestTestStats(unittest.TestCase): def test_no_hooks(self): @@ -487,6 +502,26 @@ class EvergreenConfigGeneratorTest(unittest.TestCase): expected_exec_timeout = grt.calculate_timeout(suites[0].get_runtime(), 3) * 5 self.assertEqual(expected_exec_timeout, timeout_cmd["params"]["exec_timeout_secs"]) + def test_evg_config_does_not_overwrite_repeatSuites_resmoke_arg_with_repeatSuites_default(self): + options = self.generate_mock_options() + options.resmoke_args = "resmoke_args --repeatSuites=5" + suites = self.generate_mock_suites(1) + + config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map() + command1 = config["tasks"][0]["commands"][2] + self.assertIn("--repeatSuites=5", command1["vars"]["resmoke_args"]) + self.assertNotIn("--repeatSuites=1", command1["vars"]["resmoke_args"]) + + def test_evg_config_does_not_overwrite_repeat_resmoke_arg_with_repeatSuites_default(self): + options = self.generate_mock_options() + options.resmoke_args = "resmoke_args --repeat=5" + suites = self.generate_mock_suites(1) + + config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map() + command1 = config["tasks"][0]["commands"][2] + self.assertIn("--repeat=5", command1["vars"]["resmoke_args"]) + self.assertNotIn("--repeatSuites=1", command1["vars"]["resmoke_args"]) + def test_suites_without_enough_info_should_not_include_timeouts(self): suite_without_timing_info = 1 options = self.generate_mock_options() |