예제 #1
0
 def test_default_is_returned_with_no_timeout(self):
     mock_timeout_overrides = under_test.TimeoutOverrides(overrides={})
     orchestrator = under_test.TaskTimeoutOrchestrator(
         timeout_service=MagicMock(spec_set=TimeoutService),
         timeout_overrides=mock_timeout_overrides,
         evg_project_config=MagicMock(spec_set=EvergreenProjectConfig))
     self.assertIsNone(
         orchestrator.determine_idle_timeout("task_name", "variant"))
예제 #2
0
 def test_commit_queue_items_use_commit_queue_timeout(self):
     mock_timeout_overrides = under_test.TimeoutOverrides(overrides={})
     orchestrator = under_test.TaskTimeoutOrchestrator(
         timeout_service=MagicMock(spec_set=TimeoutService),
         timeout_overrides=mock_timeout_overrides,
         evg_project_config=MagicMock(spec_set=EvergreenProjectConfig))
     timeout = orchestrator.determine_exec_timeout(
         "auth", "variant", evg_alias=under_test.COMMIT_QUEUE_ALIAS)
     self.assertEqual(timeout, under_test.COMMIT_QUEUE_TIMEOUT)
예제 #3
0
 def test_default_is_returned_with_no_timeout(self):
     mock_timeout_overrides = under_test.TimeoutOverrides(overrides={})
     orchestrator = under_test.TaskTimeoutOrchestrator(
         timeout_service=MagicMock(spec_set=TimeoutService),
         timeout_overrides=mock_timeout_overrides,
         evg_project_config=MagicMock(spec_set=EvergreenProjectConfig))
     self.assertEqual(
         orchestrator.determine_exec_timeout("task_name", "variant"),
         under_test.DEFAULT_NON_REQUIRED_BUILD_TIMEOUT)
예제 #4
0
 def test_timeout_used_if_specified(self):
     mock_timeout_overrides = under_test.TimeoutOverrides(overrides={})
     orchestrator = under_test.TaskTimeoutOrchestrator(
         timeout_service=MagicMock(spec_set=TimeoutService),
         timeout_overrides=mock_timeout_overrides,
         evg_project_config=MagicMock(spec_set=EvergreenProjectConfig))
     timeout = timedelta(seconds=42)
     self.assertEqual(
         orchestrator.determine_idle_timeout("task_name", "variant",
                                             timeout), timeout)
예제 #5
0
 def test_task_specific_timeout(self):
     mock_timeout_overrides = under_test.TimeoutOverrides(overrides={
         "linux-64-debug": [{
             "task": "auth",
             "idle_timeout": 60
         }]
     })
     orchestrator = under_test.TaskTimeoutOrchestrator(
         timeout_service=MagicMock(spec_set=TimeoutService),
         timeout_overrides=mock_timeout_overrides,
         evg_project_config=MagicMock(spec_set=EvergreenProjectConfig))
     self.assertEqual(
         orchestrator.determine_idle_timeout("auth", "linux-64-debug"),
         timedelta(minutes=60))
예제 #6
0
    def test_use_idle_timeout_if_greater_than_exec_timeout(self):
        mock_timeout_overrides = under_test.TimeoutOverrides(overrides={})
        orchestrator = under_test.TaskTimeoutOrchestrator(
            timeout_service=MagicMock(spec_set=TimeoutService),
            timeout_overrides=mock_timeout_overrides,
            evg_project_config=MagicMock(spec_set=EvergreenProjectConfig))
        idle_timeout = timedelta(hours=2)
        exec_timeout = timedelta(minutes=10)
        timeout = orchestrator.determine_exec_timeout(
            "task_name",
            "variant",
            idle_timeout=idle_timeout,
            exec_timeout=exec_timeout)

        self.assertEqual(timeout, idle_timeout)
예제 #7
0
    def _validate_idle_timeout(self, idle_timeout, historic_timeout, build_variant,
                               timeout_override, expected_timeout):
        task_name = "task_name"
        overrides = {}
        if timeout_override is not None:
            overrides[build_variant] = [{"task": task_name, "idle_timeout": timeout_override}]

        mock_timeout_overrides = under_test.TimeoutOverrides(overrides=overrides)

        orchestrator = under_test.TaskTimeoutOrchestrator(
            timeout_service=MagicMock(spec_set=TimeoutService),
            timeout_overrides=mock_timeout_overrides,
            evg_project_config=MagicMock(spec_set=EvergreenProjectConfig))

        actual_timeout = orchestrator.determine_idle_timeout(task_name, build_variant, idle_timeout,
                                                             historic_timeout)

        self.assertEqual(actual_timeout, expected_timeout)