ceph/qa/tasks/mgr/dashboard/test_requests.py
Zack Cerza 03de8f9557 mgr/dashboard: Enable gzip compression
This is related to http://tracker.ceph.com/issues/36453. It is far from
a complete solution, but seems like a positive move.

I tested this change by first disabling my browser cache, and then used
the /docs endpoint to query /api/dashboard/health. Before compression:
  Content-Length: 60748
  Time: 615ms
After:
  Content-Length: 7505
  Time: 92ms

Then, I logged into the dashboard as normal and reloaded the page once I
was in. Some values for the reload operation before compression:
  Total page load time: 58.48s
  vendor.js Content-Length: 6486025
  vendor.js time: 48.09s
After:
  Total page load time: 14.55s
  vendor.js Content-Length: 1143178
  vendor.js time: 4.50s

Signed-off-by: Zack Cerza <zack@redhat.com>
2018-10-24 16:04:37 -06:00

24 lines
629 B
Python

# -*- coding: utf-8 -*-
from __future__ import absolute_import
from .helper import DashboardTestCase
class RequestsTest(DashboardTestCase):
def test_gzip(self):
self._get('/api/summary')
self.assertHeaders({
'Content-Encoding': 'gzip',
'Content-Type': 'application/json',
})
def test_force_no_gzip(self):
self._get('/api/summary', params=dict(
headers={'Accept-Encoding': 'identity'}
))
self.assertNotIn('Content-Encoding', self._resp.headers)
self.assertHeaders({
'Content-Type': 'application/json',
})