Merge lp:~adeuring/lazr.jobrunner/bug1015667-2 into lp:lazr.jobrunner
Status: | Merged |
---|---|
Approved by: | Aaron Bentley |
Approved revision: | 44 |
Merged at revision: | 43 |
Proposed branch: | lp:~adeuring/lazr.jobrunner/bug1015667-2 |
Merge into: | lp:lazr.jobrunner |
Diff against target: |
199 lines (+61/-37) 5 files modified
src/lazr/jobrunner/celerytask.py (+4/-3) src/lazr/jobrunner/tests/config1.py (+1/-4) src/lazr/jobrunner/tests/config_do_not_create_missing_queues.py (+2/-0) src/lazr/jobrunner/tests/simple_config.py (+4/-0) src/lazr/jobrunner/tests/test_celerytask.py (+50/-30) |
To merge this branch: | bzr merge lp:~adeuring/lazr.jobrunner/bug1015667-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aaron Bentley (community) | Approve | ||
Review via email: mp+113962@code.launchpad.net |
Description of the change
This branch makes the lazr.jobrunner script usable with the Celery
configuration used by Launchpad.
The problem: LP's Celery configuration sets CELERY_
to False to avoid the creation of arbitrary queues. With this setting,
an attempt to create an instance of app.amqp.Router in the function
drain_queues() fails with the error "queue not found in CELERY_QUEUES".
This error can be avoid by calling app.amqp.
Attempts to write a test for this change revealed a test isolation problem
in the existing tests of clear_queues(): The est modules simply imported
the function clear_queues() from the module bin.clear_queues, and
clear_queues() does a "late import" of lazr.jobrunner.
in turn imports indirectly a Celery config module.
This meant that the Celery configuration of the first test was used
in all subsequent tests.
I changed the tests so that the tests now invoke the real script in a
subprocess.
This is done via the context manager running(), which tried to call
proc.terminate(). This failed with an exception for the clear-queues
script because the script is already terminated when proc.terminate()
is called. The call of proc.terminate() is now optional in running().
Finally, I refactored to Celery test configurations a bit: We should
always parameters like BROKER_VHOST or CELERY_
overall quite simple the configuration "config1" needs an environment
variable FILE_JOB_DIR, which is unnecessary for the tests of
clear-queues, so I added a quite basic configuration "simple_config",
which is imported by config1 and by the second new configuration
config_
test: make check
no lint