Skip to content

Commit

Permalink
[AIRFLOW-6638] Remove flakiness test from test_serialized_db remove (#…
Browse files Browse the repository at this point in the history
…7258)

The test was failing randomly because it returned the DAGs in random order and
sometimes it failed because test_serialized_dag was removing only one file
from the list of files but the file could be repeated in
case a dag file had more than one DAG defined.
  • Loading branch information
potiuk committed Jan 25, 2020
1 parent 8325dd5 commit 9346bf0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/models/test_serialized_dag.py
Expand Up @@ -84,7 +84,7 @@ def test_read_dags(self):
self.assertTrue(serialized_dag.dag_id == dag.dag_id)
self.assertTrue(set(serialized_dag.task_dict) == set(dag.task_dict))

def test_remove_dags(self):
def test_remove_dags_by_id(self):
"""DAGs can be removed from database."""
example_dags_list = list(self._write_example_dags().values())
# Remove SubDags from the list as they are not stored in DB in a separate row
Expand All @@ -95,9 +95,16 @@ def test_remove_dags(self):
SDM.remove_dag(dag_removed_by_id.dag_id)
self.assertFalse(SDM.has_dag(dag_removed_by_id.dag_id))

def test_remove_dags_by_filepath(self):
"""DAGs can be removed from database."""
example_dags_list = list(self._write_example_dags().values())
# Remove SubDags from the list as they are not stored in DB in a separate row
# and are directly added in Json blob of the main DAG
filtered_example_dags_list = [dag for dag in example_dags_list if not dag.is_subdag]
# Tests removing by file path.
dag_removed_by_file = filtered_example_dags_list[1]
example_dag_files = [dag.full_filepath for dag in filtered_example_dags_list]
dag_removed_by_file = filtered_example_dags_list[0]
# remove repeated files for those DAGs that define multiple dags in the same file (set comprehension)
example_dag_files = list({dag.full_filepath for dag in filtered_example_dags_list})
example_dag_files.remove(dag_removed_by_file.full_filepath)
SDM.remove_deleted_dags(example_dag_files)
self.assertFalse(SDM.has_dag(dag_removed_by_file.dag_id))

0 comments on commit 9346bf0

Please sign in to comment.