Esempio n. 1
0
    def test_all_tests_with_runtime_history_should_use_custom_timeout(self):
        mock_evg_api = MagicMock(spec_set=EvergreenApi)
        n_tests = 30
        test_runtime = 600
        test_stats = [
            tst_stat_mock(f"test_{i}.js", test_runtime, 1)
            for i in range(n_tests)
        ]
        mock_evg_api.test_stats_by_project.return_value = test_stats
        mock_resmoke_proxy = MagicMock(spec_set=ResmokeProxyService)
        mock_resmoke_proxy.list_tests.return_value = [
            ts.test_file for ts in test_stats
        ]
        timeout_service = build_mock_service(evg_api=mock_evg_api,
                                             resmoke_proxy=mock_resmoke_proxy)
        timeout_params = under_test.TimeoutParams(
            evg_project="my project",
            build_variant="bv",
            task_name="my task",
            suite_name="my suite",
            is_asan=False,
        )

        timeout = timeout_service.get_timeout_estimate(timeout_params)

        self.assertTrue(timeout.is_specified())
        self.assertEqual(1860, timeout.calculate_test_timeout(1))
        self.assertEqual(54180, timeout.calculate_task_timeout(1))
Esempio n. 2
0
    def test_no_stats_should_return_default_timeout(self):
        mock_evg_api = MagicMock(spec_set=EvergreenApi)
        mock_evg_api.test_stats_by_project.return_value = []
        timeout_service = build_mock_service(evg_api=mock_evg_api)
        timeout_params = under_test.TimeoutParams(
            evg_project="my project",
            build_variant="bv",
            task_name="my task",
            suite_name="my suite",
            is_asan=False,
        )

        timeout = timeout_service.get_timeout_estimate(timeout_params)

        self.assertFalse(timeout.is_specified())
Esempio n. 3
0
    def test_no_stats_from_evergreen_should_return_none(self):
        mock_evg_api = MagicMock(spec_set=EvergreenApi)
        mock_evg_api.test_stats_by_project.return_value = []
        timeout_service = build_mock_service(evg_api=mock_evg_api)
        timeout_params = under_test.TimeoutParams(
            evg_project="my project",
            build_variant="bv",
            task_name="my task",
            suite_name="my suite",
            is_asan=False,
        )

        stats = timeout_service.lookup_historic_stats(timeout_params)

        self.assertIsNone(stats)
Esempio n. 4
0
    def test_stats_from_evergreen_should_return_the_stats(self):
        mock_evg_api = MagicMock(spec_set=EvergreenApi)
        test_stats = [tst_stat_mock(f"test_{i}.js", 60, 1) for i in range(100)]
        mock_evg_api.test_stats_by_project.return_value = test_stats
        timeout_service = build_mock_service(evg_api=mock_evg_api)
        timeout_params = under_test.TimeoutParams(
            evg_project="my project",
            build_variant="bv",
            task_name="my task",
            suite_name="my suite",
            is_asan=False,
        )

        stats = timeout_service.lookup_historic_stats(timeout_params)

        self.assertIsNotNone(stats)
        self.assertEqual(len(test_stats), len(stats.historic_test_results))
Esempio n. 5
0
    def test_a_test_with_missing_history_should_cause_a_default_timeout(self):
        mock_evg_api = MagicMock(spec_set=EvergreenApi)
        test_stats = [tst_stat_mock(f"test_{i}.js", 60, 1) for i in range(30)]
        mock_evg_api.test_stats_by_project.return_value = test_stats
        mock_resmoke_proxy = MagicMock(spec_set=ResmokeProxyService)
        mock_resmoke_proxy.list_tests.return_value = ["test_with_no_stats.js"]
        timeout_service = build_mock_service(evg_api=mock_evg_api, resmoke_proxy=mock_resmoke_proxy)
        timeout_params = under_test.TimeoutParams(
            evg_project="my project",
            build_variant="bv",
            task_name="my task",
            suite_name="my suite",
            is_asan=False,
        )

        timeout = timeout_service.get_timeout_estimate(timeout_params)

        self.assertFalse(timeout.is_specified())