Commit b2c2b478 authored by rajendrant's avatar rajendrant Committed by Commit Bot

Add integration test for new ofcl directive

ofcl directive in chrome-proxy header indicates the original full content
length of the responses. This should be used as an alternative to XOCL to
calculate compression ratio, especially for range responses.

Bug: 745989
Change-Id: Id7050736e2c7c7a4f8f1de36e909441122181331
Reviewed-on: https://chromium-review.googlesource.com/747683Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: rajendrant <rajendrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512985}
parent 7305ba9e
...@@ -9,11 +9,19 @@ from common import TestDriver ...@@ -9,11 +9,19 @@ from common import TestDriver
from common import IntegrationTest from common import IntegrationTest
from common import ParseFlags from common import ParseFlags
from decorators import Slow from decorators import Slow
from decorators import ChromeVersionEqualOrAfterM
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
class Video(IntegrationTest): class Video(IntegrationTest):
# Returns the ofcl value in chrome-proxy header.
def getChromeProxyOFCL(self, response):
self.assertIn('chrome-proxy', response.response_headers)
chrome_proxy_header = response.response_headers['chrome-proxy']
self.assertIn('ofcl=', chrome_proxy_header)
return chrome_proxy_header.split('ofcl=', 1)[1].split(',', 1)[0]
# Check videos are proxied. # Check videos are proxied.
def testCheckVideoHasViaHeader(self): def testCheckVideoHasViaHeader(self):
with TestDriver() as t: with TestDriver() as t:
...@@ -47,6 +55,70 @@ class Video(IntegrationTest): ...@@ -47,6 +55,70 @@ class Video(IntegrationTest):
self.assertHasChromeProxyViaHeader(response) self.assertHasChromeProxyViaHeader(response)
self.assertTrue(saw_video_response, 'No video request seen in test!') self.assertTrue(saw_video_response, 'No video request seen in test!')
@ChromeVersionEqualOrAfterM(64)
def testRangeRequest(self):
with TestDriver() as t:
t.AddChromeArg('--enable-spdy-proxy-auth')
t.LoadURL('http://check.googlezip.net/connect')
time.sleep(2) # wait for page load
initial_ocl_histogram_count = t.GetHistogram(
'Net.HttpOriginalContentLengthWithValidOCL')['count']
initial_ocl_histogram_sum = t.GetHistogram(
'Net.HttpOriginalContentLengthWithValidOCL')['sum']
t.ExecuteJavascript(
'var xhr = new XMLHttpRequest();'
'xhr.open("GET", "/metrics/local.png", false);'
'xhr.setRequestHeader("Range", "bytes=0-200");'
'xhr.send();'
'return;'
)
saw_range_response = False
for response in t.GetHTTPResponses():
self.assertHasChromeProxyViaHeader(response)
if response.response_headers['status']=='206':
saw_range_response = True
self.assertEqual('201', response.response_headers['content-length'])
content_range = response.response_headers['content-range']
self.assertTrue(content_range.startswith('bytes 0-200/'))
compressed_full_content_length = int(content_range.split('/')[1])
ofcl = int(self.getChromeProxyOFCL(response))
# ofcl should be same as compressed full content length, since no
# compression for XHR.
self.assertEqual(ofcl, compressed_full_content_length)
# One new entry should be added to HttpOriginalContentLengthWithValidOCL
# histogram and that should match expected OCL which is
# compression_ratio * 201 bytes.
self.assertEqual(1, t.GetHistogram(
'Net.HttpOriginalContentLengthWithValidOCL')['count']
- initial_ocl_histogram_count)
self.assertEqual(t.GetHistogram(
'Net.HttpOriginalContentLengthWithValidOCL')['sum']
- initial_ocl_histogram_sum,
ofcl/compressed_full_content_length*201)
self.assertTrue(saw_range_response, 'No range request was seen in test!')
@ChromeVersionEqualOrAfterM(64)
def testRangeRequestInVideo(self):
with TestDriver() as t:
t.AddChromeArg('--enable-spdy-proxy-auth')
t.LoadURL(
'http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html')
# Wait for the video to finish playing, plus some headroom.
time.sleep(5)
responses = t.GetHTTPResponses()
self.assertEquals(2, len(responses))
saw_range_response = False
for response in responses:
self.assertHasChromeProxyViaHeader(response)
if response.response_headers['status']=='206':
saw_range_response = True
content_range = response.response_headers['content-range']
compressed_full_content_length = int(content_range.split('/')[1])
ofcl = int(self.getChromeProxyOFCL(response))
# ofcl should be greater than the compressed full content length.
self.assertTrue(ofcl > compressed_full_content_length)
self.assertTrue(saw_range_response, 'No range request was seen in test!')
# Check the compressed video has the same frame count, width, height, and # Check the compressed video has the same frame count, width, height, and
# duration as uncompressed. # duration as uncompressed.
@Slow @Slow
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment