Stop gzipping zuul status json in zuul

It is expensive for zuul to do gzipping of data in zuul. Stop gzipping
here and have apache (or some other proxy) do it for you in cases where
smaller json is helpful. This offloads the work from zuul so that it can
focus on scheduling tests.

partial-bug: 1326170
Change-Id: Ieef0a19b4b36b28118a6a93ebd595a5287848034
This commit is contained in:
Clark Boylan 2014-06-03 16:39:10 -07:00
parent 3f07003e6b
commit a5edbe494c
2 changed files with 1 additions and 14 deletions

View File

@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from cStringIO import StringIO
import gzip
import json
import logging
import os
@ -1927,7 +1925,7 @@ class TestScheduler(ZuulTestCase):
self.assertEqual(self.history[4].pipeline, 'check')
self.assertEqual(self.history[5].pipeline, 'check')
def test_json_status(self, compressed=False):
def test_json_status(self):
"Test that we can retrieve JSON status info"
self.worker.hold_jobs_in_build = True
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
@ -1938,13 +1936,8 @@ class TestScheduler(ZuulTestCase):
port = self.webapp.server.socket.getsockname()[1]
req = urllib2.Request("http://localhost:%s/status.json" % port)
if compressed:
req.add_header("accept-encoding", "gzip")
f = urllib2.urlopen(req)
data = f.read()
if compressed:
gz = gzip.GzipFile(fileobj=StringIO(data))
data = gz.read()
self.worker.hold_jobs_in_build = False
self.worker.release()
@ -1968,9 +1961,6 @@ class TestScheduler(ZuulTestCase):
self.assertIn('project-test1', status_jobs)
self.assertIn('project-test2', status_jobs)
def test_json_status_gzip(self):
self.test_json_status(True)
def test_merging_queues(self):
"Test that transitively-connected change queues are merged"
self.config.set('zuul', 'layout_config',

View File

@ -47,7 +47,4 @@ class WebApp(threading.Thread):
raise
response = webob.Response(body=ret, content_type='application/json')
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Vary'] = 'Accept-Encoding'
if 'gzip' in request.headers.get('accept-encoding', ()):
response.encode_content('gzip')
return response