You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2018/08/07 14:43:56 UTC

[GitHub] bolkedebruin closed pull request #3710: [AIRFLOW-2860] Update tests for druid hook

bolkedebruin closed pull request #3710: [AIRFLOW-2860] Update tests for druid hook
URL: https://github.com/apache/incubator-airflow/pull/3710
 
 
   

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/airflow/hooks/druid_hook.py b/airflow/hooks/druid_hook.py
index e5fb6a7a26..fbd74e8e47 100644
--- a/airflow/hooks/druid_hook.py
+++ b/airflow/hooks/druid_hook.py
@@ -37,7 +37,8 @@ class DruidHook(BaseHook):
                                  which accepts index jobs
     :type druid_ingest_conn_id: string
     :param timeout: The interval between polling
-                    the Druid job for the status of the ingestion job
+                    the Druid job for the status of the ingestion job.
+                    Must be greater than or equal to 1
     :type timeout: int
     :param max_ingestion_time: The maximum ingestion time before assuming the job failed
     :type max_ingestion_time: int
@@ -53,6 +54,9 @@ def __init__(
         self.max_ingestion_time = max_ingestion_time
         self.header = {'content-type': 'application/json'}
 
+        if self.timeout < 1:
+            raise ValueError("Druid timeout should be equal or greater than 1")
+
     def get_conn_url(self):
         conn = self.get_connection(self.druid_ingest_conn_id)
         host = conn.host
diff --git a/tests/hooks/test_druid_hook.py b/tests/hooks/test_druid_hook.py
index 6fd7b3cc76..4243343b88 100644
--- a/tests/hooks/test_druid_hook.py
+++ b/tests/hooks/test_druid_hook.py
@@ -98,7 +98,7 @@ def test_submit_unknown_response(self, m):
 
     @requests_mock.mock()
     def test_submit_timeout(self, m):
-        self.db_hook.timeout = 0
+        self.db_hook.timeout = 1
         self.db_hook.max_ingestion_time = 5
         task_post = m.post(
             'http://druid-overlord:8081/druid/indexer/v1/task',
@@ -131,7 +131,7 @@ def test_get_conn_url(self, mock_get_connection):
         get_conn_value.port = '1'
         get_conn_value.extra_dejson = {'endpoint': 'ingest'}
         mock_get_connection.return_value = get_conn_value
-        hook = DruidHook(timeout=0, max_ingestion_time=5)
+        hook = DruidHook(timeout=1, max_ingestion_time=5)
         self.assertEquals(hook.get_conn_url(), 'https://test_host:1/ingest')
 
 


 

----------------------------------------------------------------
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


With regards,
Apache Git Services