phanikumv commented on code in PR #69688:
URL: https://github.com/apache/airflow/pull/69688#discussion_r3603591185
##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:
##########
@@ -1030,6 +1033,41 @@ def test_ti_run_populates_team_name(
assert response.status_code == 200
assert response.json()["dag_run"]["team_name"] == (team_name if
expect_team else None)
+ def test_ti_run_populates_log_id_template(
+ self, client, session, create_task_instance, create_log_template,
time_machine
+ ):
+ """``log_id_template`` echoes the LogTemplate row pinned to the Dag
run."""
+ instant = timezone.parse("2024-09-30T12:00:00Z")
+ time_machine.move_to(instant, tick=False)
+
+ custom_elasticsearch_id =
"{dag_id}-{task_id}-{logical_date}-{try_number}"
+ create_log_template("{{ ti.dag_id }}.log", custom_elasticsearch_id)
+
+ # The Dag run pins the newest LogTemplate row at creation time.
+ ti = create_task_instance(
+ task_id="test_ti_run_populates_log_id_template",
+ state=State.QUEUED,
+ dagrun_state=DagRunState.RUNNING,
+ session=session,
+ start_date=instant,
+ dag_id=str(uuid4()),
+ )
+ session.commit()
Review Comment:
```suggestion
session.commit()
# A newer LogTemplate lands after the run is created; the run must
keep its
# pinned row, not switch to the latest one.
create_log_template("{{ ti.dag_id }}.log",
"{dag_id}-{task_id}-{run_id}-{map_index}-{try_number}")
```
--
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]