Merge lp:~abentley/lazr.jobrunner/rollback-29 into lp:lazr.jobrunner

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 33
Proposed branch: lp:~abentley/lazr.jobrunner/rollback-29
Merge into: lp:lazr.jobrunner
Diff against target: 129 lines (+9/-34)
3 files modified
buildout.cfg (+0/-2)
src/lazr/jobrunner/celeryconfig.py (+1/-2)
src/lazr/jobrunner/tests/test_celerytask.py (+8/-30)
To merge this branch: bzr merge lp:~abentley/lazr.jobrunner/rollback-29
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+105335@code.launchpad.net

Commit message

Rollback r29

Description of the change

I was wrong, and ResourcedTestCase does in fact set up and tear down the resource repeatedly. What's worse, this is incompatible with the tests for add-missing-jobs, because RabbitMQ uses connection caching which I've been unable to defeat.

So this branch just rolls the changes back.

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'buildout.cfg'
--- buildout.cfg 2012-05-03 16:32:13 +0000
+++ buildout.cfg 2012-05-10 14:51:19 +0000
@@ -8,8 +8,6 @@
8 oops8 oops
9 oops_amqp9 oops_amqp
10 oops_datedir_repo10 oops_datedir_repo
11 rabbitfixture
12 testresources
13 zope.testing11 zope.testing
1412
15[python]13[python]
1614
=== modified file 'src/lazr/jobrunner/celeryconfig.py'
--- src/lazr/jobrunner/celeryconfig.py 2012-05-03 16:32:13 +0000
+++ src/lazr/jobrunner/celeryconfig.py 2012-05-10 14:51:19 +0000
@@ -1,5 +1,4 @@
1import os1#BROKER_PORT = 5672
2BROKER_PORT = os.environ['BROKER_PORT']
3#BROKER_USER = "guest"2#BROKER_USER = "guest"
4#BROKER_PASSWORD = "guest"3#BROKER_PASSWORD = "guest"
54
65
=== modified file 'src/lazr/jobrunner/tests/test_celerytask.py'
--- src/lazr/jobrunner/tests/test_celerytask.py 2012-05-03 16:37:08 +0000
+++ src/lazr/jobrunner/tests/test_celerytask.py 2012-05-10 14:51:19 +0000
@@ -1,4 +1,4 @@
1# Copyright 2012 Canonical Ltd. All rights reserved.1 # Copyright 2012 Canonical Ltd. All rights reserved.
2#2#
3# This file is part of lazr.jobrunner3# This file is part of lazr.jobrunner
4#4#
@@ -33,23 +33,9 @@
33from unittest import TestCase33from unittest import TestCase
34import urllib234import urllib2
3535
36from rabbitfixture.server import (
37 allocate_ports,
38 RabbitServer,
39 RabbitServerResources,
40 )
41
42rabbit_port = allocate_ports(1)[0]
43rabbit_config = RabbitServerResources(port=rabbit_port)
44os.environ.setdefault('BROKER_PORT', str(rabbit_port))
45
46os.environ.setdefault('CELERY_CONFIG_MODULE', 'lazr.jobrunner.celeryconfig')36os.environ.setdefault('CELERY_CONFIG_MODULE', 'lazr.jobrunner.celeryconfig')
4737
48from celery.exceptions import SoftTimeLimitExceeded38from celery.exceptions import SoftTimeLimitExceeded
49from testresources import (
50 FixtureResource,
51 ResourcedTestCase,
52 )
5339
54from lazr.jobrunner.celerytask import RunJob40from lazr.jobrunner.celerytask import RunJob
55from lazr.jobrunner.jobrunner import (41from lazr.jobrunner.jobrunner import (
@@ -79,12 +65,8 @@
79 proc.wait()65 proc.wait()
8066
8167
82def celeryd(config_module, file_job_dir, queue='celery', app=None):68def celeryd(config_module, file_job_dir, queue='celery'):
83 cmd_args = ('--config', config_module, '--queue', queue)69 cmd_args = ('--config', config_module, '--queue', queue)
84 if app is not None:
85 with app.broker_connection() as connection:
86 broker_uri = connection.as_uri(include_password=True)
87 cmd_args = cmd_args + ('--broker', broker_uri)
88 environ = dict(os.environ)70 environ = dict(os.environ)
89 environ['FILE_JOB_DIR'] = file_job_dir71 environ['FILE_JOB_DIR'] = file_job_dir
90 return running('bin/celeryd', cmd_args, environ, cwd=get_root())72 return running('bin/celeryd', cmd_args, environ, cwd=get_root())
@@ -294,10 +276,7 @@
294 self.assertTrue(js.jobs[10].unrun)276 self.assertTrue(js.jobs[10].unrun)
295277
296278
297class TestCeleryD(ResourcedTestCase):279class TestCeleryD(TestCase):
298
299 resources = [
300 ('rabbitmq', FixtureResource(RabbitServer(rabbit_config)))]
301280
302 def getQueueInfo(self):281 def getQueueInfo(self):
303 auth_handler = urllib2.HTTPBasicAuthHandler()282 auth_handler = urllib2.HTTPBasicAuthHandler()
@@ -359,8 +338,7 @@
359 result = RunFileJob.delay(10)338 result = RunFileJob.delay(10)
360 self.assertIs(None, js.get_output(job))339 self.assertIs(None, js.get_output(job))
361 self.assertEqual(JobStatus.WAITING, job.status)340 self.assertEqual(JobStatus.WAITING, job.status)
362 with celeryd(341 with celeryd('lazr.jobrunner.tests.config1', temp_dir):
363 'lazr.jobrunner.tests.config1', temp_dir, app=RunFileJob.app):
364 result.wait(10)342 result.wait(10)
365 job = js.get(job.job_id)343 job = js.get(job.job_id)
366 self.assertEqual('my_output', js.get_output(job))344 self.assertEqual('my_output', js.get_output(job))
@@ -372,7 +350,7 @@
372 job = FileJob(js, 10, **kwargs)350 job = FileJob(js, 10, **kwargs)
373 job.save()351 job.save()
374 result = RunFileJob.apply_async(args=(10, ), queue=queue)352 result = RunFileJob.apply_async(args=(10, ), queue=queue)
375 with celeryd(config, temp_dir, queue, app=RunFileJob.app) as proc:353 with celeryd(config, temp_dir, queue) as proc:
376 try:354 try:
377 result.wait(10)355 result.wait(10)
378 except SoftTimeLimitExceeded:356 except SoftTimeLimitExceeded:
@@ -391,7 +369,7 @@
391 job = FileJob(js, 10, **kwargs)369 job = FileJob(js, 10, **kwargs)
392 job.save()370 job.save()
393 RunFileJobNoResult.apply_async(args=(10, ), queue=queue)371 RunFileJobNoResult.apply_async(args=(10, ), queue=queue)
394 with celeryd(config, temp_dir, queue, app=RunFileJob.app) as proc:372 with celeryd(config, temp_dir, queue) as proc:
395 sleep(wait_time)373 sleep(wait_time)
396 job = js.get(job.job_id)374 job = js.get(job.job_id)
397 return job, js, proc375 return job, js, proc
@@ -425,7 +403,7 @@
425 with tempdir() as temp_dir:403 with tempdir() as temp_dir:
426 with celeryd(404 with celeryd(
427 'lazr.jobrunner.tests.time_limit_config_slow_lane',405 'lazr.jobrunner.tests.time_limit_config_slow_lane',
428 temp_dir, queue='standard_slow', app=RunFileJob.app):406 temp_dir, queue='standard_slow'):
429 # The fast lane times out after one second; the job407 # The fast lane times out after one second; the job
430 # is then queued again in the slow lane, where it runs408 # is then queued again in the slow lane, where it runs
431 # three seconds. Wait five seconds to check the result.409 # three seconds. Wait five seconds to check the result.
@@ -447,7 +425,7 @@
447 with tempdir() as temp_dir:425 with tempdir() as temp_dir:
448 with celeryd(426 with celeryd(
449 'lazr.jobrunner.tests.time_limit_config_slow_lane',427 'lazr.jobrunner.tests.time_limit_config_slow_lane',
450 temp_dir, queue='standard_slow', app=RunFileJob.app):428 temp_dir, queue='standard_slow'):
451 # The fast lane times out after one second; the job429 # The fast lane times out after one second; the job
452 # is then queued again in the slow lane, where it times430 # is then queued again in the slow lane, where it times
453 # out again after five seconds. Wait seven seconds to431 # out again after five seconds. Wait seven seconds to

Subscribers

People subscribed via source and target branches

to all changes: