SameerMesiah97 commented on code in PR #70935:
URL: https://github.com/apache/airflow/pull/70935#discussion_r3700242267
##########
airflow-core/tests/unit/models/test_dagbag.py:
##########
@@ -242,6 +243,36 @@ def make_lazy(task_ids):
db.clear_db_serialized_dags()
db.clear_db_dag_bundles()
+ def test_iter_all_latest_version_dags_yields_only_the_latest_version(self,
dag_maker):
+ dag_id = "versioned_dag"
+ db.clear_db_runs()
+ db.clear_db_dags()
+ db.clear_db_serialized_dags()
+ db.clear_db_dag_bundles()
+
+ with dag_maker(dag_id, schedule=None):
+ EmptyOperator(task_id="a")
+ # A version with task instances is kept rather than updated in place,
so the next
+ # write adds a second version instead of overwriting the first.
+ dag_maker.create_dagrun()
+
+ with DAG(dag_id, schedule=None) as dag:
+ EmptyOperator(task_id="a")
+ EmptyOperator(task_id="b")
+ sync_dag_to_db(dag)
+
+ with create_session() as session:
+ assert DagVersion.get_latest_version(dag_id,
session=session).version_number == 2
+ dags =
list(DBDagBag().iter_all_latest_version_dags(session=session))
+
+ assert [dag.dag_id for dag in dags] == [dag_id]
+ assert set(dags[0].task_ids) == {"a", "b"}
+
+ db.clear_db_runs()
+ db.clear_db_dags()
+ db.clear_db_serialized_dags()
+ db.clear_db_dag_bundles()
Review Comment:
Should we also add a regression covering multiple DAG IDs with multiple
versions, to explicitly verify we return the latest version per DAG rather than
just the latest serialized row overall?
--
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]