Skip to content

Commit 7031a64

Browse files
ashbAlice Berard
authored and
Alice Berard
committed
[AIRFLOW-XXX] Don't spam test logs with "bad cron expression" messages (apache#3973)
We needed these test dags to check the behaviour of invalid cron expressions, but by default we were loading them every time we create a DagBag (which many, many tests to). Instead we ignore these known-bad dags by default, and the test checking those (tests/models.py:DagBagTest.test_process_file_cron_validity_check) is already explicitly processing those DAGs directly, so it remains tested.
1 parent a14d489 commit 7031a64

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tests/dags/.airflowignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.*_invalid.*

tests/jobs.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -3285,16 +3285,22 @@ def test_list_py_file_paths(self):
32853285
[JIRA-1357] Test the 'list_py_file_paths' function used by the
32863286
scheduler to list and load DAGs.
32873287
"""
3288-
detected_files = []
3289-
expected_files = []
3288+
detected_files = set()
3289+
expected_files = set()
3290+
# No_dags is empty, _invalid_ is ignored by .airflowignore
3291+
ignored_files = [
3292+
'no_dags.py',
3293+
'test_invalid_cron.py',
3294+
'test_zip_invalid_cron.zip',
3295+
]
32903296
for file_name in os.listdir(TEST_DAGS_FOLDER):
32913297
if file_name.endswith('.py') or file_name.endswith('.zip'):
3292-
if file_name not in ['no_dags.py']:
3293-
expected_files.append(
3298+
if file_name not in ignored_files:
3299+
expected_files.add(
32943300
'{}/{}'.format(TEST_DAGS_FOLDER, file_name))
32953301
for file_path in list_py_file_paths(TEST_DAGS_FOLDER):
3296-
detected_files.append(file_path)
3297-
self.assertEqual(sorted(detected_files), sorted(expected_files))
3302+
detected_files.add(file_path)
3303+
self.assertEqual(detected_files, expected_files)
32983304

32993305
def test_reset_orphaned_tasks_nothing(self):
33003306
"""Try with nothing. """

0 commit comments

Comments
 (0)