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

Side by Side Diff: tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py

Issue 998163005: LoFi integration test should use HasChromeProxyLoFi (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove variables Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import time 6 import time
7 7
8 from integration_tests import network_metrics 8 from integration_tests import network_metrics
9 from telemetry.page import page_test 9 from telemetry.page import page_test
10 from telemetry.value import scalar 10 from telemetry.value import scalar
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 results.AddValue(scalar.ScalarValue( 208 results.AddValue(scalar.ScalarValue(
209 results.current_page, 'via', 'count', via_count)) 209 results.current_page, 'via', 'count', via_count))
210 results.AddValue(scalar.ScalarValue( 210 results.AddValue(scalar.ScalarValue(
211 results.current_page, 'bypass', 'count', bypass_count)) 211 results.current_page, 'bypass', 'count', bypass_count))
212 212
213 def AddResultsForLoFi(self, tab, results): 213 def AddResultsForLoFi(self, tab, results):
214 lo_fi_count = 0 214 lo_fi_count = 0
215 215
216 for resp in self.IterResponses(tab): 216 for resp in self.IterResponses(tab):
217 if resp.HasChromeProxyViaHeader(): 217 if resp.HasChromeProxyLoFi():
218 lo_fi_count += 1 218 lo_fi_count += 1
219 else: 219 else:
220 r = resp.response
221 raise ChromeProxyMetricException, ( 220 raise ChromeProxyMetricException, (
222 '%s: LoFi not in request header.' % (r.url)) 221 '%s: LoFi not in request header.' % (resp.response.url))
223 222
224 cl = resp.content_length 223 if resp.content_length > 100:
225 resource = resp.response.url 224 raise ChromeProxyMetricException, (
225 'Image %s is %d bytes. Expecting less than 100 bytes.' %
226 (resp.response.url, resp.content_length))
227
228 if lo_fi_count == 0:
229 raise ChromeProxyMetricException, (
230 'Expected at least one LoFi response, but zero such responses were '
231 'received.')
232
226 results.AddValue(scalar.ScalarValue( 233 results.AddValue(scalar.ScalarValue(
227 results.current_page, 'lo_fi', 'count', lo_fi_count)) 234 results.current_page, 'lo_fi', 'count', lo_fi_count))
228 235 super(ChromeProxyMetric, self).AddResults(tab, results)
229 for resp in self.IterResponses(tab):
230 r = resp.response
231 cl = resp.content_length
232 ocl = resp.original_content_length
233 saving = resp.data_saving_rate * 100
234 if cl > 100:
235 raise ChromeProxyMetricException, (
236 'Image %s is %d bytes. Expecting less than 100 bytes.' %
237 (resource, cl))
238
239 results.AddValue(scalar.ScalarValue(
240 results.current_page, 'content_length', 'bytes', cl))
241 results.AddValue(scalar.ScalarValue(
242 results.current_page, 'original_content_length', 'bytes', ocl))
243 results.AddValue(scalar.ScalarValue(
244 results.current_page, 'data_saving', 'percent', saving))
245 236
246 def AddResultsForBypass(self, tab, results): 237 def AddResultsForBypass(self, tab, results):
247 bypass_count = 0 238 bypass_count = 0
248 239
249 for resp in self.IterResponses(tab): 240 for resp in self.IterResponses(tab):
250 if resp.HasChromeProxyViaHeader(): 241 if resp.HasChromeProxyViaHeader():
251 r = resp.response 242 r = resp.response
252 raise ChromeProxyMetricException, ( 243 raise ChromeProxyMetricException, (
253 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % ( 244 '%s: Should not have Via header (%s) (refer=%s, status=%d)' % (
254 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) 245 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status))
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 via_count += 1 483 via_count += 1
493 if via_count == 0: 484 if via_count == 0:
494 raise ChromeProxyMetricException, ( 485 raise ChromeProxyMetricException, (
495 'Expected at least one response through the proxy after the bypass ' 486 'Expected at least one response through the proxy after the bypass '
496 'expired, but zero such responses were received.') 487 'expired, but zero such responses were received.')
497 488
498 results.AddValue(scalar.ScalarValue( 489 results.AddValue(scalar.ScalarValue(
499 results.current_page, 'bypass', 'count', bypass_count)) 490 results.current_page, 'bypass', 'count', bypass_count))
500 results.AddValue(scalar.ScalarValue( 491 results.AddValue(scalar.ScalarValue(
501 results.current_page, 'via', 'count', via_count)) 492 results.current_page, 'via', 'count', via_count))
OLDNEW
« 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