kaxil commented on a change in pull request #9851:
URL: https://github.com/apache/airflow/pull/9851#discussion_r455937662
##########
File path: tests/models/test_dagbag.py
##########
@@ -657,3 +659,35 @@ def test_serialized_dags_are_written_to_db_on_sync(self):
new_serialized_dags_count =
session.query(func.count(SerializedDagModel.dag_id)).scalar()
self.assertEqual(new_serialized_dags_count, 1)
+
+ @patch("airflow.models.dagbag.settings.STORE_SERIALIZED_DAGS", True)
+
@patch("airflow.models.dagbag.settings.MIN_SERIALIZED_DAG_UPDATE_INTERVAL", 5)
+ def test_get_dag_with_dag_serialization(self):
+ """
+ Test that Serialized DAG is updated in DagBag when it is updated in
+ Serialized DAG table after MIN_SERIALIZED_DAG_UPDATE_INTERVAL seconds
are passed.
+ """
+
+ with freeze_time(tz.datetime(2020, 1, 5, 0, 0, 0)):
+ example_bash_op_dag =
DagBag(include_examples=True).dags.get("example_bash_operator")
+ SerializedDagModel.write_dag(dag=example_bash_op_dag)
+
+ dag_bag = DagBag(read_dags_from_db=True)
+ ser_dag_1 = dag_bag.get_dag("example_bash_operator")
+ ser_dag_1_update_time =
dag_bag.dags_last_changed["example_bash_operator"]
+ self.assertEqual(example_bash_op_dag.tags, ser_dag_1.tags)
+ self.assertEqual(ser_dag_1_update_time, tz.datetime(2020, 1, 5, 0, 0,
0))
+
+ with freeze_time(tz.datetime(2020, 1, 5, 0, 0, 6)):
+ example_bash_op_dag.tags += ["new_tag"]
+ SerializedDagModel.write_dag(dag=example_bash_op_dag)
+
+ with freeze_time(tz.datetime(2020, 1, 5, 0, 0, 4)):
+ self.assertEqual(dag_bag.get_dag("example_bash_operator").tags,
["example"])
Review comment:
Updated in
https://github.com/apache/airflow/pull/9851/commits/40427e57ab84ca77e2ec60fec4c27001bec7086b
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]