ashb closed pull request #4255: [AIRFLOW-3239] Fix/refine tests in api/common/experimental/ URL: https://github.com/apache/incubator-airflow/pull/4255
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/tests/api/common/experimental/mark_tasks.py b/tests/api/common/experimental/test_mark_tasks.py similarity index 97% rename from tests/api/common/experimental/mark_tasks.py rename to tests/api/common/experimental/test_mark_tasks.py index 304e261b98..9afe31c951 100644 --- a/tests/api/common/experimental/mark_tasks.py +++ b/tests/api/common/experimental/test_mark_tasks.py @@ -20,7 +20,7 @@ import unittest from datetime import datetime -from airflow import models +from airflow import configuration, models from airflow.api.common.experimental.mark_tasks import ( set_state, _create_dagruns, set_dag_run_state_to_success, set_dag_run_state_to_failed, set_dag_run_state_to_running) @@ -31,12 +31,14 @@ DEV_NULL = "/dev/null" +configuration.load_test_config() + class TestMarkTasks(unittest.TestCase): def setUp(self): self.dagbag = models.DagBag(include_examples=True) - self.dag1 = self.dagbag.dags['test_example_bash_operator'] + self.dag1 = self.dagbag.dags['example_bash_operator'] self.dag2 = self.dagbag.dags['example_subdag_operator'] self.execution_dates = [days_ago(2), days_ago(1)] @@ -195,6 +197,11 @@ def test_mark_tasks_past(self): self.verify_state(self.dag1, [task.task_id], self.execution_dates, State.SUCCESS, snapshot) + # TODO: this skipIf should be removed once a fixing solution is found later + # We skip it here because this test case is working with Postgres & SQLite + # but not with MySQL + @unittest.skipIf('mysql' in configuration.conf.get('core', 'sql_alchemy_conn'), + "Flaky with MySQL") def test_mark_tasks_subdag(self): # set one task to success towards end of scheduled dag runs task = self.dag2.get_task("section-1") @@ -217,15 +224,15 @@ def test_mark_tasks_subdag(self): class TestMarkDAGRun(unittest.TestCase): def setUp(self): self.dagbag = models.DagBag(include_examples=True) - self.dag1 = self.dagbag.dags['test_example_bash_operator'] + self.dag1 = self.dagbag.dags['example_bash_operator'] self.dag2 = self.dagbag.dags['example_subdag_operator'] - self.execution_dates = [days_ago(3), days_ago(2), days_ago(1)] + self.execution_dates = [days_ago(2), days_ago(1), days_ago(0)] self.session = Session() def _set_default_task_instance_states(self, dr): - if dr.dag_id != 'test_example_bash_operator': + if dr.dag_id != 'example_bash_operator': return # success task dr.get_task_instance('runme_0').set_state(State.SUCCESS, self.session) @@ -510,6 +517,7 @@ def tearDown(self): self.session.query(models.TaskInstance).delete() self.session.query(models.DagStat).delete() self.session.commit() + self.session.close() if __name__ == '__main__': diff --git a/tests/api/common/experimental/test_pool.py b/tests/api/common/experimental/test_pool.py index e5efa2c676..fac1e2e71b 100644 --- a/tests/api/common/experimental/test_pool.py +++ b/tests/api/common/experimental/test_pool.py @@ -28,7 +28,6 @@ class TestPool(unittest.TestCase): def setUp(self): - super(TestPool, self).setUp() self.session = settings.Session() self.pools = [] for i in range(2): @@ -46,7 +45,6 @@ def tearDown(self): self.session.query(models.Pool).delete() self.session.commit() self.session.close() - super(TestPool, self).tearDown() def test_get_pool(self): pool = pool_api.get_pool(name=self.pools[0].pool, session=self.session) diff --git a/tests/api/common/experimental/trigger_dag_tests.py b/tests/api/common/experimental/test_trigger_dag.py similarity index 100% rename from tests/api/common/experimental/trigger_dag_tests.py rename to tests/api/common/experimental/test_trigger_dag.py ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services