mik-laj commented on a change in pull request #7602: [AIRFLOW-6967] Add tests
to avoid performance regression in DagFileProcessor
URL: https://github.com/apache/airflow/pull/7602#discussion_r389257705
##########
File path: tests/jobs/test_scheduler_job.py
##########
@@ -1059,6 +1067,113 @@ def test_process_file_should_failure_callback(self):
os.remove(callback_file.name)
+class DagFileProcessorQueriesCount(unittest.TestCase):
+ """
+ These tests are designed to detect changes in the number of queries for
different DAG files.
+
+ Each test has saved queries count in the table/spreadsheets. If you make a
change that affected the number
+ of queries, please update the tables.
+
+ These tests allow easy detection when a change is made that affects the
performance of the
+ DagFileProcessor.
+ """
+ def setUp(self) -> None:
+ clear_db_runs()
+ clear_db_pools()
+ clear_db_dags()
+ clear_db_sla_miss()
+ clear_db_errors()
+
+ @parameterized.expand(
+ [
+ # pylint: disable=bad-whitespace
+ # expected, dag_count, task_count, start_ago, schedule_interval,
shape
+ # One DAG with one task per DAG file
+ ( 1, 1, 1, "1d", "None", "no_structure"), # noqa
+ ( 1, 1, 1, "1d", "None", "linear"), # noqa
+ ( 3, 1, 1, "1d", "@once", "no_structure"), # noqa
+ ( 3, 1, 1, "1d", "@once", "linear"), # noqa
+ ( 3, 1, 1, "1d", "30m", "no_structure"), # noqa
+ ( 3, 1, 1, "1d", "30m", "linear"), # noqa
+ # One DAG with five tasks per DAG file
+ ( 1, 1, 5, "1d", "None", "no_structure"), # noqa
+ ( 1, 1, 5, "1d", "None", "linear"), # noqa
+ ( 3, 1, 5, "1d", "@once", "no_structure"), # noqa
+ ( 3, 1, 5, "1d", "@once", "linear"), # noqa
+ ( 3, 1, 5, "1d", "30m", "no_structure"), # noqa
+ ( 3, 1, 5, "1d", "30m", "linear"), # noqa
+ # 10 DAGs with 10 tasks per DAG file
+ ( 1, 10, 10, "1d", "None", "no_structure"), # noqa
+ ( 1, 10, 10, "1d", "None", "linear"), # noqa
+ (21, 10, 10, "1d", "@once", "no_structure"), # noqa
+ (21, 10, 10, "1d", "@once", "linear"), # noqa
+ (21, 10, 10, "1d", "30m", "no_structure"), # noqa
+ (21, 10, 10, "1d", "30m", "linear"), # noqa
+ # pylint: enable=bad-whitespace
+ ]
+ )
+ def test_process_dags_queries_count(
+ self, expected_query_count, dag_count, task_count, start_ago,
schedule_interval, shape
+ ):
+ with mock.patch.dict("os.environ", {
+ "PERF_DAGS_COUNT": str(dag_count),
+ "PERF_TASKS_COUNT": str(task_count),
+ "PERF_START_AGO": start_ago,
+ "PERF_SCHEDULE_INTERVAL": schedule_interval,
+ "PERF_SHAPE": shape,
+ }), conf_vars({
+ ('scheduler', 'use_job_schedule'): 'True',
+ }):
+
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services