launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06704
[Merge] lp:~rvb/maas/maas-longpoll-fix into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/maas-longpoll-fix into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/maas-longpoll-fix/+merge/97582
This branch fixes the dynamic inclusion of the view that acts as a proxy to a txongpoll server. This view should only be served by MaaS if both settings.LONGPOLL_SERVER_URL and settings.LONGPOLL_URL and defined (i.e. if longpoll is enabled (LONGPOLL_URL) and if the url to a txlongpoll is configured (LONGPOLL_SERVER_URL).
--
https://code.launchpad.net/~rvb/maas/maas-longpoll-fix/+merge/97582
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-longpoll-fix into lp:maas.
=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py 2012-03-14 15:56:49 +0000
+++ src/maasserver/tests/test_views.py 2012-03-15 08:25:27 +0000
@@ -20,6 +20,7 @@
from lxml.html import fromstring
from maasserver import views
from maasserver.messages import get_messaging
+from maasserver.urls import get_proxy_longpoll_enabled
from maasserver.models import (
Config,
NODE_AFTER_COMMISSIONING_ACTION,
@@ -103,6 +104,24 @@
'select#id_after_commissioning_action')
+class TestGetLongpollenabled(TestCase):
+
+ def test_longpoll_not_included_if_LONGPOLL_SERVER_URL_None(self):
+ self.patch(settings, 'LONGPOLL_URL', factory.getRandomString())
+ self.patch(settings, 'LONGPOLL_SERVER_URL', None)
+ self.assertFalse(get_proxy_longpoll_enabled())
+
+ def test_longpoll_not_included_if_LONGPOLL_URL_None(self):
+ self.patch(settings, 'LONGPOLL_URL', None)
+ self.patch(settings, 'LONGPOLL_SERVER_URL', factory.getRandomString())
+ self.assertFalse(get_proxy_longpoll_enabled())
+
+ def test_longpoll_included_if_LONGPOLL_URL_and_LONGPOLL_SERVER_URL(self):
+ self.patch(settings, 'LONGPOLL_URL', factory.getRandomString())
+ self.patch(settings, 'LONGPOLL_SERVER_URL', factory.getRandomString())
+ self.assertTrue(get_proxy_longpoll_enabled())
+
+
class TestComboLoaderView(TestCase):
"""Test combo loader view."""
@@ -146,11 +165,6 @@
class TestUtilities(TestCase):
- def patch_settings(self, name, value):
- old_value = getattr(settings, name)
- setattr(settings, name, value)
- self.addCleanup(setattr, settings, name, old_value)
-
def test_get_longpoll_context_empty_if_rabbitmq_publish_is_none(self):
self.patch(settings, 'RABBITMQ_PUBLISH', None)
self.patch(views, 'messaging', get_messaging())
=== modified file 'src/maasserver/urls.py'
--- src/maasserver/urls.py 2012-03-14 22:52:50 +0000
+++ src/maasserver/urls.py 2012-03-15 08:25:27 +0000
@@ -77,10 +77,22 @@
r'^nodes/create/$', NodesCreateView.as_view(), name='node-create'),
)
-if django_settings.LONGPOLL_SERVER_URL is not None:
+
+def get_proxy_longpoll_enabled():
+ """Should MaaS act as a proxy to a txlongpoll server?
+
+ This should only be true if longpoll is enabled (LONGPOLL_URL) and
+ if the url to a txlongpoll is configured (LONGPOLL_SERVER_URL).
+ """
+ return (
+ django_settings.LONGPOLL_SERVER_URL is not None and
+ django_settings.LONGPOLL_URL is not None)
+
+
+if get_proxy_longpoll_enabled():
urlpatterns += patterns('maasserver.views',
url(
- r'^%s$' % re.escape(django_settings.LONGPOLL_SERVER_URL),
+ r'^%s$' % re.escape(django_settings.LONGPOLL_URL),
proxy_to_longpoll, name='proxy-to-longpoll'),
)