launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19715
[Merge] lp:~cjwatson/turnip/revision-header into lp:turnip
Colin Watson has proposed merging lp:~cjwatson/turnip/revision-header into lp:turnip.
Commit message:
Add an X-Turnip-Revision HTTP header to the root resource.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/turnip/revision-header/+merge/277262
Add an X-Turnip-Revision HTTP header to the root resource. Among other things, this will let us discover from CI what code revision is currently running on qastaging, which lets us stop hardcoding that revision.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/turnip/revision-header into lp:turnip.
=== modified file '.bzrignore'
--- .bzrignore 2015-10-19 10:39:41 +0000
+++ .bzrignore 2015-11-11 15:18:48 +0000
@@ -13,3 +13,4 @@
parts
tags
TAGS
+turnip/version_info.py
=== modified file 'Makefile'
--- Makefile 2015-10-29 10:59:20 +0000
+++ Makefile 2015-11-11 15:18:48 +0000
@@ -23,7 +23,10 @@
build: $(ENV)
-$(ENV):
+turnip/version_info.py:
+ bzr version-info --format=python >$@
+
+$(ENV): turnip/version_info.py
ifeq ($(PIP_SOURCE_DIR),)
@echo "Set PIP_SOURCE_DIR to the path of a checkout of" >&2
@echo "lp:~canonical-launchpad-branches/turnip/dependencies." >&2
@@ -49,6 +52,7 @@
clean:
find turnip -name '*.py[co]' -exec rm '{}' \;
rm -rf $(ENV) $(PIP_CACHE)
+ rm -f turnip/version_info.py
dist:
python ./setup.py sdist
@@ -60,7 +64,7 @@
ctags -R turnip
lint: $(ENV)
- @$(FLAKE8) turnip
+ @$(FLAKE8) --exclude=__pycache__,version_info.py turnip
run-api: $(ENV)
$(PSERVE) api.ini --reload
=== modified file 'turnip/pack/http.py'
--- turnip/pack/http.py 2015-06-19 06:04:02 +0000
+++ turnip/pack/http.py 2015-11-11 15:18:48 +0000
@@ -56,6 +56,7 @@
encode_packet,
encode_request,
)
+from turnip.version_info import version_info
# twisted.web.xmlrpc doesn't exist for Python 3 yet, but the non-XML-RPC
# bits of this module work.
if sys.version_info.major < 3:
@@ -337,6 +338,8 @@
self.root = root
def render_GET(self, request):
+ request.setHeader(
+ b'X-Turnip-Revision', version_info['revno'].encode('UTF-8'))
request.redirect(self.root.main_site_root)
return b''
=== modified file 'turnip/pack/tests/test_functional.py'
--- turnip/pack/tests/test_functional.py 2015-06-18 00:05:01 +0000
+++ turnip/pack/tests/test_functional.py 2015-11-11 15:18:48 +0000
@@ -21,7 +21,10 @@
from lazr.sshserver.auth import NoSuchPersonWithName
from testtools import TestCase
from testtools.content import text_content
-from testtools.deferredruntest import AsynchronousDeferredRunTest
+from testtools.deferredruntest import (
+ assert_fails_with,
+ AsynchronousDeferredRunTest,
+ )
from testtools.matchers import StartsWith
from twisted.internet import (
defer,
@@ -29,6 +32,8 @@
utils,
)
from twisted.web import (
+ client,
+ error,
server,
xmlrpc,
)
@@ -44,6 +49,7 @@
)
from turnip.pack.http import SmartHTTPFrontendResource
from turnip.pack.ssh import SmartSSHService
+from turnip.version_info import version_info
class FakeAuthServerService(xmlrpc.XMLRPC):
@@ -363,6 +369,17 @@
yield super(TestSmartHTTPFrontendFunctional, self).tearDown()
yield self.frontend_listener.stopListening()
+ @defer.inlineCallbacks
+ def test_root_revision_header(self):
+ factory = client.HTTPClientFactory(
+ b'http://localhost:%d/' % self.port, method=b'HEAD',
+ followRedirect=False)
+ reactor.connectTCP(b'localhost', self.port, factory)
+ yield assert_fails_with(factory.deferred, error.PageRedirect)
+ self.assertEqual(
+ [version_info['revno']],
+ factory.response_headers[b'x-turnip-revision'])
+
class TestSmartSSHServiceFunctional(FrontendFunctionalTestMixin, TestCase):
Follow ups