diff --git a/redash/settings/__init__.py b/redash/settings/__init__.py index 5dd7611a78..8adeb19f9f 100644 --- a/redash/settings/__init__.py +++ b/redash/settings/__init__.py @@ -47,6 +47,7 @@ def all_settings(): QUERY_RESULTS_CLEANUP_MAX_AGE = int(os.environ.get("REDASH_QUERY_RESULTS_CLEANUP_MAX_AGE", "7")) SCHEMAS_REFRESH_SCHEDULE = int(os.environ.get("REDASH_SCHEMAS_REFRESH_SCHEDULE", 30)) +SCHEMAS_REFRESH_QUEUE = os.environ.get("REDASH_SCHEMAS_REFRESH_QUEUE", "celery") AUTH_TYPE = os.environ.get("REDASH_AUTH_TYPE", "api_key") ENFORCE_HTTPS = parse_boolean(os.environ.get("REDASH_ENFORCE_HTTPS", "false")) diff --git a/redash/tasks/queries.py b/redash/tasks/queries.py index 1fc2c50e08..2bed9b6710 100644 --- a/redash/tasks/queries.py +++ b/redash/tasks/queries.py @@ -409,7 +409,7 @@ def refresh_schemas(): elif ds.org.is_disabled: logger.info(u"task=refresh_schema state=skip ds_id=%s reason=org_disabled", ds.id) else: - refresh_schema.apply_async(args=(ds.id,), queue="schemas") + refresh_schema.apply_async(args=(ds.id,), queue=settings.SCHEMAS_REFRESH_QUEUE) logger.info(u"task=refresh_schemas state=finish total_runtime=%.2f", time.time() - global_start_time) diff --git a/tests/tasks/test_refresh_schemas.py b/tests/tasks/test_refresh_schemas.py index 809ecd5e5f..df29f5f207 100644 --- a/tests/tasks/test_refresh_schemas.py +++ b/tests/tasks/test_refresh_schemas.py @@ -1,6 +1,4 @@ -import datetime - -from mock import ANY, call, patch +from mock import patch from tests import BaseTestCase from redash.tasks import refresh_schemas @@ -8,7 +6,7 @@ class TestRefreshSchemas(BaseTestCase): def test_calls_refresh_of_all_data_sources(self): - self.factory.data_source # trigger creation + self.factory.data_source # trigger creation with patch('redash.tasks.queries.refresh_schema.apply_async') as refresh_job: refresh_schemas() refresh_job.assert_called()