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
1=== modified file 'buildout.cfg'
2--- buildout.cfg 2012-05-03 16:32:13 +0000
3+++ buildout.cfg 2012-05-10 14:51:19 +0000
4@@ -8,8 +8,6 @@
5 oops
6 oops_amqp
7 oops_datedir_repo
8- rabbitfixture
9- testresources
10 zope.testing
11
12 [python]
13
14=== modified file 'src/lazr/jobrunner/celeryconfig.py'
15--- src/lazr/jobrunner/celeryconfig.py 2012-05-03 16:32:13 +0000
16+++ src/lazr/jobrunner/celeryconfig.py 2012-05-10 14:51:19 +0000
17@@ -1,5 +1,4 @@
18-import os
19-BROKER_PORT = os.environ['BROKER_PORT']
20+#BROKER_PORT = 5672
21 #BROKER_USER = "guest"
22 #BROKER_PASSWORD = "guest"
23
24
25=== modified file 'src/lazr/jobrunner/tests/test_celerytask.py'
26--- src/lazr/jobrunner/tests/test_celerytask.py 2012-05-03 16:37:08 +0000
27+++ src/lazr/jobrunner/tests/test_celerytask.py 2012-05-10 14:51:19 +0000
28@@ -1,4 +1,4 @@
29-# Copyright 2012 Canonical Ltd. All rights reserved.
30+ # Copyright 2012 Canonical Ltd. All rights reserved.
31 #
32 # This file is part of lazr.jobrunner
33 #
34@@ -33,23 +33,9 @@
35 from unittest import TestCase
36 import urllib2
37
38-from rabbitfixture.server import (
39- allocate_ports,
40- RabbitServer,
41- RabbitServerResources,
42- )
43-
44-rabbit_port = allocate_ports(1)[0]
45-rabbit_config = RabbitServerResources(port=rabbit_port)
46-os.environ.setdefault('BROKER_PORT', str(rabbit_port))
47-
48 os.environ.setdefault('CELERY_CONFIG_MODULE', 'lazr.jobrunner.celeryconfig')
49
50 from celery.exceptions import SoftTimeLimitExceeded
51-from testresources import (
52- FixtureResource,
53- ResourcedTestCase,
54- )
55
56 from lazr.jobrunner.celerytask import RunJob
57 from lazr.jobrunner.jobrunner import (
58@@ -79,12 +65,8 @@
59 proc.wait()
60
61
62-def celeryd(config_module, file_job_dir, queue='celery', app=None):
63+def celeryd(config_module, file_job_dir, queue='celery'):
64 cmd_args = ('--config', config_module, '--queue', queue)
65- if app is not None:
66- with app.broker_connection() as connection:
67- broker_uri = connection.as_uri(include_password=True)
68- cmd_args = cmd_args + ('--broker', broker_uri)
69 environ = dict(os.environ)
70 environ['FILE_JOB_DIR'] = file_job_dir
71 return running('bin/celeryd', cmd_args, environ, cwd=get_root())
72@@ -294,10 +276,7 @@
73 self.assertTrue(js.jobs[10].unrun)
74
75
76-class TestCeleryD(ResourcedTestCase):
77-
78- resources = [
79- ('rabbitmq', FixtureResource(RabbitServer(rabbit_config)))]
80+class TestCeleryD(TestCase):
81
82 def getQueueInfo(self):
83 auth_handler = urllib2.HTTPBasicAuthHandler()
84@@ -359,8 +338,7 @@
85 result = RunFileJob.delay(10)
86 self.assertIs(None, js.get_output(job))
87 self.assertEqual(JobStatus.WAITING, job.status)
88- with celeryd(
89- 'lazr.jobrunner.tests.config1', temp_dir, app=RunFileJob.app):
90+ with celeryd('lazr.jobrunner.tests.config1', temp_dir):
91 result.wait(10)
92 job = js.get(job.job_id)
93 self.assertEqual('my_output', js.get_output(job))
94@@ -372,7 +350,7 @@
95 job = FileJob(js, 10, **kwargs)
96 job.save()
97 result = RunFileJob.apply_async(args=(10, ), queue=queue)
98- with celeryd(config, temp_dir, queue, app=RunFileJob.app) as proc:
99+ with celeryd(config, temp_dir, queue) as proc:
100 try:
101 result.wait(10)
102 except SoftTimeLimitExceeded:
103@@ -391,7 +369,7 @@
104 job = FileJob(js, 10, **kwargs)
105 job.save()
106 RunFileJobNoResult.apply_async(args=(10, ), queue=queue)
107- with celeryd(config, temp_dir, queue, app=RunFileJob.app) as proc:
108+ with celeryd(config, temp_dir, queue) as proc:
109 sleep(wait_time)
110 job = js.get(job.job_id)
111 return job, js, proc
112@@ -425,7 +403,7 @@
113 with tempdir() as temp_dir:
114 with celeryd(
115 'lazr.jobrunner.tests.time_limit_config_slow_lane',
116- temp_dir, queue='standard_slow', app=RunFileJob.app):
117+ temp_dir, queue='standard_slow'):
118 # The fast lane times out after one second; the job
119 # is then queued again in the slow lane, where it runs
120 # three seconds. Wait five seconds to check the result.
121@@ -447,7 +425,7 @@
122 with tempdir() as temp_dir:
123 with celeryd(
124 'lazr.jobrunner.tests.time_limit_config_slow_lane',
125- temp_dir, queue='standard_slow', app=RunFileJob.app):
126+ temp_dir, queue='standard_slow'):
127 # The fast lane times out after one second; the job
128 # is then queued again in the slow lane, where it times
129 # out again after five seconds. Wait seven seconds to

Subscribers

People subscribed via source and target branches

to all changes: