From 82ad279e794b4d2dba86cf902b7c2de112b1609a Mon Sep 17 00:00:00 2001 From: Ash Berlin-Taylor Date: Fri, 28 Sep 2018 23:39:04 +0100 Subject: [PATCH] [AIRFLOW-XXX] Don't spam test logs with "bad cron expression" messages 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. --- tests/dags/.airflowignore | 1 + tests/jobs.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 tests/dags/.airflowignore diff --git a/tests/dags/.airflowignore b/tests/dags/.airflowignore new file mode 100644 index 0000000000000..93361c17e24d8 --- /dev/null +++ b/tests/dags/.airflowignore @@ -0,0 +1 @@ +.*_invalid.* diff --git a/tests/jobs.py b/tests/jobs.py index e18a87e6cf12d..bb714bd201602 100644 --- a/tests/jobs.py +++ b/tests/jobs.py @@ -3285,16 +3285,22 @@ def test_list_py_file_paths(self): [JIRA-1357] Test the 'list_py_file_paths' function used by the scheduler to list and load DAGs. """ - detected_files = [] - expected_files = [] + detected_files = set() + expected_files = set() + # No_dags is empty, _invalid_ is ignored by .airflowignore + ignored_files = [ + 'no_dags.py', + 'test_invalid_cron.py', + 'test_zip_invalid_cron.zip', + ] for file_name in os.listdir(TEST_DAGS_FOLDER): if file_name.endswith('.py') or file_name.endswith('.zip'): - if file_name not in ['no_dags.py']: - expected_files.append( + if file_name not in ignored_files: + expected_files.add( '{}/{}'.format(TEST_DAGS_FOLDER, file_name)) for file_path in list_py_file_paths(TEST_DAGS_FOLDER): - detected_files.append(file_path) - self.assertEqual(sorted(detected_files), sorted(expected_files)) + detected_files.add(file_path) + self.assertEqual(detected_files, expected_files) def test_reset_orphaned_tasks_nothing(self): """Try with nothing. """