dzhigimont commented on code in PR #34579:
URL: https://github.com/apache/airflow/pull/34579#discussion_r1339736214
##########
tests/providers/cncf/kubernetes/triggers/test_pod.py:
##########
@@ -334,3 +335,37 @@ def
test_define_container_state_should_execute_successfully(
)
assert expected_state == trigger.define_container_state(pod)
+
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize("container_state", [ContainerState.WAITING,
ContainerState.UNDEFINED])
+ @mock.patch(f"{TRIGGER_PATH}.define_container_state")
+ @mock.patch(f"{TRIGGER_PATH}._get_async_hook")
+ async def test_run_loop_return_timeout_event(
+ self, mock_hook, mock_method, trigger, caplog, container_state
+ ):
+ trigger.trigger_start_time = TRIGGER_START_TIME -
datetime.timedelta(minutes=2)
+ mock_hook.return_value.get_pod.return_value = self._mock_pod_result(
+ mock.MagicMock(
+ status=mock.MagicMock(
+ phase=PodPhase.PENDING,
+ )
+ )
+ )
+ mock_method.return_value = container_state
+
+ caplog.set_level(logging.INFO)
+
+ generator = trigger.run()
+ actual = await generator.asend(None)
+ assert (
+ TriggerEvent(
+ {
+ "name": POD_NAME,
+ "namespace": NAMESPACE,
+ "status": "timeout",
+ "message": f"Pod took longer than {STARTUP_TIMEOUT_SECS}
seconds to start."
+ f" Check the pod events in kubernetes to determine why.",
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]