airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRFLOW-3287) Core tests DB clean up to be run in the right moment
Date Fri, 02 Nov 2018 10:45:00 GMT

    [ https://issues.apache.org/jira/browse/AIRFLOW-3287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16672913#comment-16672913
] 

ASF GitHub Bot commented on AIRFLOW-3287:
-----------------------------------------

ashb closed pull request #4122: [AIRFLOW-3287] Moving DB clean-up code into the CoreTest.tearDown()
URL: https://github.com/apache/incubator-airflow/pull/4122
 
 
   

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/core.py b/tests/core.py
index 679ddbc125..64195b6349 100644
--- a/tests/core.py
+++ b/tests/core.py
@@ -89,19 +89,6 @@
     import pickle
 
 
-def reset(dag_id=TEST_DAG_ID):
-    session = Session()
-    tis = session.query(models.TaskInstance).filter_by(dag_id=dag_id)
-    tis.delete()
-    session.commit()
-    session.close()
-
-
-configuration.conf.load_test_config()
-if os.environ.get('KUBERNETES_VERSION') is None:
-    reset()
-
-
 class OperatorSubclass(BaseOperator):
     """
     An operator to test template substitution
@@ -130,6 +117,16 @@ def setUp(self):
         self.run_after_loop = self.dag_bash.get_task('run_after_loop')
         self.run_this_last = self.dag_bash.get_task('run_this_last')
 
+    def tearDown(self):
+        if os.environ.get('KUBERNETES_VERSION') is None:
+            session = Session()
+            session.query(models.TaskInstance).filter_by(
+                dag_id=TEST_DAG_ID).delete()
+            session.query(models.TaskFail).filter_by(
+                dag_id=TEST_DAG_ID).delete()
+            session.commit()
+            session.close()
+
     def test_schedule_dag_no_previous_runs(self):
         """
         Tests scheduling a dag with no previous runs


 

----------------------------------------------------------------
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:
users@infra.apache.org


> Core tests DB clean up to be run in the right moment
> ----------------------------------------------------
>
>                 Key: AIRFLOW-3287
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-3287
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: core
>            Reporter: Jarosław Śmietanka
>            Assignee: Jarosław Śmietanka
>            Priority: Minor
>
> While running a single unit test of some Dataproc operator, I've spotted that database
clean-up code in `tests.core` module is triggered, which should not take place since I run
unit test in a completely different place.  
> A proposed solution is to move this database clean-up code inside the CoreTest as `tearDown`



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message