ashb commented on a change in pull request #4207: [AIRFLOW-3367] Run celery
integration test with redis broker.
URL: https://github.com/apache/incubator-airflow/pull/4207#discussion_r236309769
##########
File path: tests/executors/test_celery_executor.py
##########
@@ -33,14 +40,36 @@
import celery.contrib.testing.tasks # noqa: F401
+def _prepare_test_bodies():
+ if 'CELERY_BROKER_URLS' in os.environ:
+ return [
+ (url, )
+ for url in os.environ['CELERY_BROKER_URLS'].split(',')
+ ]
+ return [(configuration.conf.get('celery', 'BROKER_URL'))]
+
+
class CeleryExecutorTest(unittest.TestCase):
+
+ @parameterized.expand(_prepare_test_bodies())
@unittest.skipIf('sqlite' in configuration.conf.get('core',
'sql_alchemy_conn'),
"sqlite is configured with SequentialExecutor")
- def test_celery_integration(self):
+ def test_celery_integration(self, broker_url):
+ test_config = dict(celery_configuration)
+ test_config.update({'broker_url': broker_url})
+ test_app = Celery(
+ broker_url,
+ config_source=test_config)
+ test_execute_command = test_app.task(execute_command.__wrapped__)
+ patch_execute_command = mock.patch(
+ 'airflow.executors.celery_executor.execute_command',
+ test_execute_command)
Review comment:
Could all this be packaged/encapsulated in a helper function so that the
"core" bit of the test (i.e. the bits you haven't changed) remains clear?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services