Skip to content

Commit 0fa1c93

Browse files
ashbkaxil
authored andcommitted
[AIRFLOW-XXX] Don't spam test logs with "bad cron expression" messages (#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 c0057d0 commit 0fa1c93

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
@@ -3319,16 +3319,22 @@ def test_list_py_file_paths(self):
33193319
[JIRA-1357] Test the 'list_py_file_paths' function used by the
33203320
scheduler to list and load DAGs.
33213321
"""
3322-
detected_files = []
3323-
expected_files = []
3322+
detected_files = set()
3323+
expected_files = set()
3324+
# No_dags is empty, _invalid_ is ignored by .airflowignore
3325+
ignored_files = [
3326+
'no_dags.py',
3327+
'test_invalid_cron.py',
3328+
'test_zip_invalid_cron.zip',
3329+
]
33243330
for file_name in os.listdir(TEST_DAGS_FOLDER):
33253331
if file_name.endswith('.py') or file_name.endswith('.zip'):
3326-
if file_name not in ['no_dags.py']:
3327-
expected_files.append(
3332+
if file_name not in ignored_files:
3333+
expected_files.add(
33283334
'{}/{}'.format(TEST_DAGS_FOLDER, file_name))
33293335
for file_path in list_py_file_paths(TEST_DAGS_FOLDER):
3330-
detected_files.append(file_path)
3331-
self.assertEqual(sorted(detected_files), sorted(expected_files))
3336+
detected_files.add(file_path)
3337+
self.assertEqual(detected_files, expected_files)
33323338

33333339
def test_reset_orphaned_tasks_nothing(self):
33343340
"""Try with nothing. """

0 commit comments

Comments
 (0)