Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: tools/chrome_proxy/webdriver/bypass.py

Issue 2741263002: Added Data Saver ChromeDriver test for via header fallback logic. (Closed)
Patch Set: fixed comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/chrome_proxy/webdriver/bypass.py
diff --git a/tools/chrome_proxy/webdriver/bypass.py b/tools/chrome_proxy/webdriver/bypass.py
index 3b7798ae6c16c719aacbf11045b8b13656ca37da..ef5ecde4b4ebc1729b297a4336822d171cf47b7a 100644
--- a/tools/chrome_proxy/webdriver/bypass.py
+++ b/tools/chrome_proxy/webdriver/bypass.py
@@ -102,6 +102,68 @@ class Bypass(IntegrationTest):
for response in responses:
self.assertHasChromeProxyViaHeader(response)
+ # Verify that when Chrome receives a 4xx response through a Data Reduction
+ # Proxy that doesn't set a proper via header, Chrome bypasses all proxies and
+ # retries the request over direct.
+ def testMissingViaHeader4xxBypass(self):
megjablon 2017/03/11 00:51:47 Isn't this the ChromeProxyHTTPToDirectFallback tel
sclittle 2017/03/11 01:29:03 The non-4xx test below is the counterpart for the
+ with TestDriver() as test_driver:
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+
+ # Set the primary Data Reduction Proxy to be the test server, which does
+ # not add any Via headers.
+ test_driver.AddChromeArg('--data-reduction-proxy-http-proxies='
+ 'http://chromeproxy-test.appspot.com;'
+ 'http://compress.googlezip.net')
+
+ # Load a page that will come back with a 4xx response code and without the
+ # proper via header. Chrome should bypass all proxies and retry the
+ # request.
+ test_driver.LoadURL(
+ 'http://chromeproxy-test.appspot.com/default?respStatus=414')
+ responses = test_driver.GetHTTPResponses()
+ self.assertNotEqual(0, len(responses))
+ for response in responses:
+ self.assertNotHasChromeProxyViaHeader(response)
+
+ # Check that the BlockTypePrimary histogram has a single entry in the
+ # MissingViaHeader4xx category (which is enum value 4), to make sure that
+ # the bypass was caused by the missing via header logic and not something
+ # else.
+ histogram = test_driver.GetHistogram(
+ "DataReductionProxy.BlockTypePrimary")
+ self.assertEqual(1, histogram['count'])
+ self.assertIn({'count': 1, 'high': 5, 'low': 4}, histogram['buckets'])
+
+ # Verify that when Chrome receives a non-4xx response through a Data Reduction
+ # Proxy that doesn't set a proper via header, Chrome falls back to the next
+ # available proxy.
+ def testMissingViaHeaderNon4xxFallback(self):
megjablon 2017/03/11 00:51:47 The telemetry tests check the remote port, should
sclittle 2017/03/11 01:29:03 Done.
+ with TestDriver() as test_driver:
+ test_driver.AddChromeArg('--enable-spdy-proxy-auth')
+
+ # Set the primary Data Reduction Proxy to be the test server, which does
+ # not add any Via headers. The fallback Data Reduction Proxy is set to the
+ # canonical Data Reduction Proxy target.
+ test_driver.AddChromeArg('--data-reduction-proxy-http-proxies='
+ 'http://chromeproxy-test.appspot.com;'
+ 'http://compress.googlezip.net')
+
+ # Load a page that should fall back off of the test server proxy, and onto
+ # the canonical proxy that will set the correct Via header.
+ test_driver.LoadURL('http://chromeproxy-test.appspot.com/default')
+ responses = test_driver.GetHTTPResponses()
+ self.assertNotEqual(0, len(responses))
+ for response in responses:
+ self.assertHasChromeProxyViaHeader(response)
+
+ # Check that the BypassTypePrimary histogram has a single entry in the
+ # MissingViaHeaderOther category (which is enum value 5), to make sure
+ # that the bypass was caused by the missing via header logic and not
+ # something else.
+ histogram = test_driver.GetHistogram(
+ "DataReductionProxy.BypassTypePrimary")
+ self.assertEqual(1, histogram['count'])
+ self.assertIn({'count': 1, 'high': 6, 'low': 5}, histogram['buckets'])
if __name__ == '__main__':
IntegrationTest.RunAllTests()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698