def test_no_tests_run_if_none_changed(self, write_json_mock): """ Given a git repository with no changes, When burn_in_tests is run, Then no tests are discovered to run. """ variant = "build_variant" repos = [mock_changed_git_files([])] repeat_config = under_test.RepeatConfig() gen_config = under_test.GenerateConfig( variant, "project", ) # yapf: disable evg_conf_mock = MagicMock() evg_conf_mock.get_task_names_by_tag.return_value = set() under_test.burn_in(repeat_config, gen_config, "", "testfile.json", False, evg_conf_mock, repos, None) write_json_mock.assert_called_once() written_config = json.loads(write_json_mock.call_args[0][1]) display_task = written_config["buildvariants"][0]["display_tasks"][0] self.assertEqual(1, len(display_task["execution_tasks"])) self.assertEqual(under_test.BURN_IN_TESTS_GEN_TASK, display_task["execution_tasks"][0])
def test_no_tests_run_if_none_changed(self, write_json_mock): """ Given a git repository with no changes, When burn_in_tests is run, Then no tests are discovered to run. """ variant = "build_variant" repos = [mock_changed_git_files([])] repeat_config = under_test.RepeatConfig() gen_config = under_test.GenerateConfig( variant, "project", use_multiversion=False ) # yapf: disable under_test.burn_in(repeat_config, gen_config, "", "testfile.json", False, None, repos, None) write_json_mock.assert_called_once() written_config = write_json_mock.call_args[0][0] display_task = written_config["buildvariants"][0]["display_tasks"][0] self.assertEqual(1, len(display_task["execution_tasks"])) self.assertEqual(under_test.BURN_IN_TESTS_GEN_TASK, display_task["execution_tasks"][0])
def test_tests_generated_if_a_file_changed(self, write_json_mock): """ Given a git repository with no changes, When burn_in_tests is run, Then no tests are discovered to run. """ # Note: this test is using actual tests and suites. So changes to those suites could # introduce failures and require this test to be updated. # You can see the test file it is using below. This test is used in the 'auth' and # 'auth_audit' test suites. It needs to be in at least one of those for the test to pass. _config.NAMED_SUITES = None variant = "enterprise-rhel-62-64-bit" repo = mock_changed_git_files(["jstests/auth/auth1.js"]) repeat_config = under_test.RepeatConfig() gen_config = under_test.GenerateConfig( variant, "project", use_multiversion=False ) # yapf: disable evg_config = get_evergreen_config("etc/evergreen.yml") under_test.burn_in(repeat_config, gen_config, "", "testfile.json", False, evg_config, repo, None) write_json_mock.assert_called_once() written_config = write_json_mock.call_args[0][0] n_tasks = len(written_config["tasks"]) # Ensure we are generating at least one task for the test. self.assertGreaterEqual(n_tasks, 1) written_build_variant = written_config["buildvariants"][0] self.assertEqual(variant, written_build_variant["name"]) self.assertEqual(n_tasks, len(written_build_variant["tasks"])) display_task = written_build_variant["display_tasks"][0] # The display task should contain all the generated tasks as well as 1 extra task for # the burn_in_test_gen task. self.assertEqual(n_tasks + 1, len(display_task["execution_tasks"]))