← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Aaron Bentley has proposed merging lp:~abentley/lazr.jobrunner/rollback-29 into lp:lazr.jobrunner.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~abentley/lazr.jobrunner/rollback-29/+merge/105335

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.
-- 
https://code.launchpad.net/~abentley/lazr.jobrunner/rollback-29/+merge/105335
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/lazr.jobrunner/rollback-29 into lp:lazr.jobrunner.
=== 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 @@
     oops
     oops_amqp
     oops_datedir_repo
-    rabbitfixture
-    testresources
     zope.testing
 
 [python]

=== 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 @@
-import os
-BROKER_PORT = os.environ['BROKER_PORT']
+#BROKER_PORT = 5672
 #BROKER_USER = "guest"
 #BROKER_PASSWORD = "guest"
 

=== 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 @@
-# Copyright 2012 Canonical Ltd. All rights reserved.
+ # Copyright 2012 Canonical Ltd. All rights reserved.
 #
 # This file is part of lazr.jobrunner
 #
@@ -33,23 +33,9 @@
 from unittest import TestCase
 import urllib2
 
-from rabbitfixture.server import (
-    allocate_ports,
-    RabbitServer,
-    RabbitServerResources,
-    )
-
-rabbit_port = allocate_ports(1)[0]
-rabbit_config = RabbitServerResources(port=rabbit_port)
-os.environ.setdefault('BROKER_PORT', str(rabbit_port))
-
 os.environ.setdefault('CELERY_CONFIG_MODULE', 'lazr.jobrunner.celeryconfig')
 
 from celery.exceptions import SoftTimeLimitExceeded
-from testresources import (
-    FixtureResource,
-    ResourcedTestCase,
-    )
 
 from lazr.jobrunner.celerytask import RunJob
 from lazr.jobrunner.jobrunner import (
@@ -79,12 +65,8 @@
         proc.wait()
 
 
-def celeryd(config_module, file_job_dir, queue='celery', app=None):
+def celeryd(config_module, file_job_dir, queue='celery'):
     cmd_args = ('--config', config_module, '--queue', queue)
-    if app is not None:
-        with app.broker_connection() as connection:
-            broker_uri = connection.as_uri(include_password=True)
-        cmd_args = cmd_args + ('--broker', broker_uri)
     environ = dict(os.environ)
     environ['FILE_JOB_DIR'] = file_job_dir
     return running('bin/celeryd', cmd_args, environ, cwd=get_root())
@@ -294,10 +276,7 @@
         self.assertTrue(js.jobs[10].unrun)
 
 
-class TestCeleryD(ResourcedTestCase):
-
-    resources = [
-        ('rabbitmq', FixtureResource(RabbitServer(rabbit_config)))]
+class TestCeleryD(TestCase):
 
     def getQueueInfo(self):
         auth_handler = urllib2.HTTPBasicAuthHandler()
@@ -359,8 +338,7 @@
             result = RunFileJob.delay(10)
             self.assertIs(None, js.get_output(job))
             self.assertEqual(JobStatus.WAITING, job.status)
-            with celeryd(
-                'lazr.jobrunner.tests.config1', temp_dir, app=RunFileJob.app):
+            with celeryd('lazr.jobrunner.tests.config1', temp_dir):
                 result.wait(10)
             job = js.get(job.job_id)
             self.assertEqual('my_output', js.get_output(job))
@@ -372,7 +350,7 @@
         job = FileJob(js, 10, **kwargs)
         job.save()
         result = RunFileJob.apply_async(args=(10, ), queue=queue)
-        with celeryd(config, temp_dir, queue, app=RunFileJob.app) as proc:
+        with celeryd(config, temp_dir, queue) as proc:
             try:
                 result.wait(10)
             except SoftTimeLimitExceeded:
@@ -391,7 +369,7 @@
         job = FileJob(js, 10, **kwargs)
         job.save()
         RunFileJobNoResult.apply_async(args=(10, ), queue=queue)
-        with celeryd(config, temp_dir, queue, app=RunFileJob.app) as proc:
+        with celeryd(config, temp_dir, queue) as proc:
             sleep(wait_time)
         job = js.get(job.job_id)
         return job, js, proc
@@ -425,7 +403,7 @@
         with tempdir() as temp_dir:
             with celeryd(
                 'lazr.jobrunner.tests.time_limit_config_slow_lane',
-                temp_dir, queue='standard_slow', app=RunFileJob.app):
+                temp_dir, queue='standard_slow'):
                 # The fast lane times out after one second; the job
                 # is then queued again in the slow lane, where it runs
                 # three seconds. Wait five seconds to check the result.
@@ -447,7 +425,7 @@
         with tempdir() as temp_dir:
             with celeryd(
                 'lazr.jobrunner.tests.time_limit_config_slow_lane',
-                temp_dir, queue='standard_slow', app=RunFileJob.app):
+                temp_dir, queue='standard_slow'):
                 # The fast lane times out after one second; the job
                 # is then queued again in the slow lane, where it times
                 # out again after five seconds. Wait seven seconds to