kaxil commented on code in PR #44954:
URL: https://github.com/apache/airflow/pull/44954#discussion_r1888519254
##########
tests/api_fastapi/execution_api/routes/test_task_instances.py:
##########
@@ -455,6 +455,36 @@ def test_ti_heartbeat_update(self, client, session,
create_task_instance, time_m
session.refresh(ti)
assert ti.last_heartbeat_at == time_now.add(minutes=10)
+ def test_ti_update_state_to_failed_table_check(self, client, session,
create_task_instance):
+ from math import ceil
+
+ ti = create_task_instance(
+ task_id="test_ti_update_state_to_terminal",
+ start_date=DEFAULT_START_DATE,
+ state=State.RUNNING,
+ )
+ ti.start_date = DEFAULT_START_DATE
+ session.commit()
+
+ response = client.patch(
+ f"/execution/task-instances/{ti.id}/state",
+ json={
+ "state": State.FAILED,
+ "end_date": DEFAULT_END_DATE.isoformat(),
+ },
+ )
+
+ assert response.status_code == 204
+ assert response.text == ""
+
+ session.expire_all()
+
+ ti = session.get(TaskInstance, ti.id)
+ assert ti.state == State.FAILED
+ assert ti.next_method is None
+ assert ti.next_kwargs is None
+ assert ceil(ti.duration) == 3600.00
Review Comment:
Why do we need `ceil`?
--
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]