OLD | NEW |
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 base64 | 5 import base64 |
6 import logging | 6 import logging |
7 import urlparse | 7 import urlparse |
8 | 8 |
9 from common import chrome_proxy_measurements as measurements | 9 from common import chrome_proxy_measurements as measurements |
10 from common.chrome_proxy_measurements import ChromeProxyValidation | 10 from common.chrome_proxy_measurements import ChromeProxyValidation |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 class ChromeProxyClientType(ChromeProxyValidation): | 273 class ChromeProxyClientType(ChromeProxyValidation): |
274 """Correctness measurement for Chrome-Proxy header client type directives.""" | 274 """Correctness measurement for Chrome-Proxy header client type directives.""" |
275 | 275 |
276 def __init__(self): | 276 def __init__(self): |
277 super(ChromeProxyClientType, self).__init__( | 277 super(ChromeProxyClientType, self).__init__( |
278 restart_after_each_page=True, | 278 restart_after_each_page=True, |
279 metrics=metrics.ChromeProxyMetric()) | 279 metrics=metrics.ChromeProxyMetric()) |
280 self._chrome_proxy_client_type = None | 280 self._chrome_proxy_client_type = None |
281 | 281 |
| 282 def CustomizeBrowserOptions(self, options): |
| 283 super(ChromeProxyClientType, self).CustomizeBrowserOptions(options) |
| 284 options.AppendExtraBrowserArgs('--disable-quic') |
| 285 |
282 def AddResults(self, tab, results): | 286 def AddResults(self, tab, results): |
283 # Get the Chrome-Proxy client type from the first page in the page set, so | 287 # Get the Chrome-Proxy client type from the first page in the page set, so |
284 # that the client type value can be used to determine which of the later | 288 # that the client type value can be used to determine which of the later |
285 # pages in the page set should be bypassed. | 289 # pages in the page set should be bypassed. |
286 if not self._chrome_proxy_client_type: | 290 if not self._chrome_proxy_client_type: |
287 client_type = self._metrics.GetClientTypeFromRequests(tab) | 291 client_type = self._metrics.GetClientTypeFromRequests(tab) |
288 if client_type: | 292 if client_type: |
289 self._chrome_proxy_client_type = client_type | 293 self._chrome_proxy_client_type = client_type |
290 | 294 |
291 self._metrics.AddResultsForClientType(tab, | 295 self._metrics.AddResultsForClientType(tab, |
292 results, | 296 results, |
293 self._chrome_proxy_client_type, | 297 self._chrome_proxy_client_type, |
294 self._page.bypass_for_client_type) | 298 self._page.bypass_for_client_type) |
295 | 299 |
296 | 300 |
297 class ChromeProxyLoFi(ChromeProxyValidation): | 301 class ChromeProxyLoFi(ChromeProxyValidation): |
298 """Correctness measurement for Lo-Fi in Chrome-Proxy header.""" | 302 """Correctness measurement for Lo-Fi in Chrome-Proxy header.""" |
299 | 303 |
300 def __init__(self): | 304 def __init__(self): |
301 super(ChromeProxyLoFi, self).__init__(restart_after_each_page=True, | 305 super(ChromeProxyLoFi, self).__init__(restart_after_each_page=True, |
302 metrics=metrics.ChromeProxyMetric()) | 306 metrics=metrics.ChromeProxyMetric()) |
303 | 307 |
304 def CustomizeBrowserOptions(self, options): | 308 def CustomizeBrowserOptions(self, options): |
305 super(ChromeProxyLoFi, self).CustomizeBrowserOptions(options) | 309 super(ChromeProxyLoFi, self).CustomizeBrowserOptions(options) |
306 options.AppendExtraBrowserArgs('--data-reduction-proxy-lo-fi=always-on') | 310 options.AppendExtraBrowserArgs('--data-reduction-proxy-lo-fi=always-on') |
307 # Disable server experiments such as tamper detection. | 311 # Disable server experiments such as tamper detection. |
308 options.AppendExtraBrowserArgs( | 312 options.AppendExtraBrowserArgs( |
309 '--data-reduction-proxy-server-experiments-disabled') | 313 '--data-reduction-proxy-server-experiments-disabled') |
| 314 options.AppendExtraBrowserArgs('--disable-quic') |
310 | 315 |
311 def AddResults(self, tab, results): | 316 def AddResults(self, tab, results): |
312 self._metrics.AddResultsForLoFi(tab, results) | 317 self._metrics.AddResultsForLoFi(tab, results) |
313 | 318 |
314 class ChromeProxyCacheLoFiDisabled(ChromeProxyValidation): | 319 class ChromeProxyCacheLoFiDisabled(ChromeProxyValidation): |
315 """ | 320 """ |
316 Correctness measurement for Lo-Fi placeholder is not loaded from cache when a | 321 Correctness measurement for Lo-Fi placeholder is not loaded from cache when a |
317 page is reloaded with LoFi disabled. First a test page is opened with LoFi and | 322 page is reloaded with LoFi disabled. First a test page is opened with LoFi and |
318 chrome proxy enabled. This allows Chrome to cache the LoFi placeholder image. | 323 chrome proxy enabled. This allows Chrome to cache the LoFi placeholder image. |
319 The browser is restarted with LoFi disabled and the same test page is loaded. | 324 The browser is restarted with LoFi disabled and the same test page is loaded. |
320 This second page load should not pick the LoFi placeholder from cache and | 325 This second page load should not pick the LoFi placeholder from cache and |
321 original image should be loaded. This test should be run with | 326 original image should be loaded. This test should be run with |
322 --profile-type=default command line for the same user profile and cache to be | 327 --profile-type=default command line for the same user profile and cache to be |
323 used across the two page loads. | 328 used across the two page loads. |
324 """ | 329 """ |
325 | 330 |
326 def __init__(self): | 331 def __init__(self): |
327 super(ChromeProxyCacheLoFiDisabled, self).__init__( | 332 super(ChromeProxyCacheLoFiDisabled, self).__init__( |
328 restart_after_each_page=True, | 333 restart_after_each_page=True, |
329 metrics=metrics.ChromeProxyMetric(), | 334 metrics=metrics.ChromeProxyMetric(), |
330 clear_cache_before_each_run=False) | 335 clear_cache_before_each_run=False) |
331 | 336 |
332 def AddResults(self, tab, results): | 337 def AddResults(self, tab, results): |
333 self._metrics.AddResultsForLoFiCache(tab, results, self._is_lo_fi_enabled) | 338 self._metrics.AddResultsForLoFiCache(tab, results, self._is_lo_fi_enabled) |
334 | 339 |
335 def WillStartBrowser(self, platform): | 340 def WillStartBrowser(self, platform): |
336 super(ChromeProxyCacheLoFiDisabled, self).WillStartBrowser(platform) | 341 super(ChromeProxyCacheLoFiDisabled, self).WillStartBrowser(platform) |
| 342 self.options.AppendExtraBrowserArgs('--disable-quic') |
337 if not self._page: | 343 if not self._page: |
338 # First page load, enable LoFi and chrome proxy. Disable server | 344 # First page load, enable LoFi and chrome proxy. Disable server |
339 # experiments such as tamper detection. | 345 # experiments such as tamper detection. |
340 self.options.AppendExtraBrowserArgs( | 346 self.options.AppendExtraBrowserArgs( |
341 '--data-reduction-proxy-lo-fi=always-on') | 347 '--data-reduction-proxy-lo-fi=always-on') |
342 self.options.AppendExtraBrowserArgs( | 348 self.options.AppendExtraBrowserArgs( |
343 '--data-reduction-proxy-server-experiments-disabled') | 349 '--data-reduction-proxy-server-experiments-disabled') |
344 self._is_lo_fi_enabled = True | 350 self._is_lo_fi_enabled = True |
345 else: | 351 else: |
346 # Second page load, disable LoFi. Chrome proxy is still enabled. Disable | 352 # Second page load, disable LoFi. Chrome proxy is still enabled. Disable |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 restart_after_each_page=True, | 385 restart_after_each_page=True, |
380 metrics=metrics.ChromeProxyMetric(), | 386 metrics=metrics.ChromeProxyMetric(), |
381 clear_cache_before_each_run=False) | 387 clear_cache_before_each_run=False) |
382 | 388 |
383 def AddResults(self, tab, results): | 389 def AddResults(self, tab, results): |
384 self._metrics.AddResultsForLoFiCache(tab, results, | 390 self._metrics.AddResultsForLoFiCache(tab, results, |
385 self._is_chrome_proxy_enabled) | 391 self._is_chrome_proxy_enabled) |
386 | 392 |
387 def WillStartBrowser(self, platform): | 393 def WillStartBrowser(self, platform): |
388 super(ChromeProxyCacheProxyDisabled, self).WillStartBrowser(platform) | 394 super(ChromeProxyCacheProxyDisabled, self).WillStartBrowser(platform) |
| 395 self.options.AppendExtraBrowserArgs('--disable-quic') |
389 if not self._page: | 396 if not self._page: |
390 # First page load, enable LoFi and chrome proxy. Disable server | 397 # First page load, enable LoFi and chrome proxy. Disable server |
391 # experiments such as tamper detection. | 398 # experiments such as tamper detection. |
392 self.options.AppendExtraBrowserArgs( | 399 self.options.AppendExtraBrowserArgs( |
393 '--data-reduction-proxy-lo-fi=always-on') | 400 '--data-reduction-proxy-lo-fi=always-on') |
394 self.options.AppendExtraBrowserArgs( | 401 self.options.AppendExtraBrowserArgs( |
395 '--data-reduction-proxy-server-experiments-disabled') | 402 '--data-reduction-proxy-server-experiments-disabled') |
396 else: | 403 else: |
397 # Second page load, disable chrome proxy. LoFi is still enabled. | 404 # Second page load, disable chrome proxy. LoFi is still enabled. |
398 self.DisableChromeProxy() | 405 self.DisableChromeProxy() |
(...skipping 16 matching lines...) Expand all Loading... |
415 super(ChromeProxyLoFiPreview, self).__init__( | 422 super(ChromeProxyLoFiPreview, self).__init__( |
416 restart_after_each_page=True, | 423 restart_after_each_page=True, |
417 metrics=metrics.ChromeProxyMetric()) | 424 metrics=metrics.ChromeProxyMetric()) |
418 | 425 |
419 def CustomizeBrowserOptions(self, options): | 426 def CustomizeBrowserOptions(self, options): |
420 super(ChromeProxyLoFiPreview, self).CustomizeBrowserOptions(options) | 427 super(ChromeProxyLoFiPreview, self).CustomizeBrowserOptions(options) |
421 options.AppendExtraBrowserArgs( | 428 options.AppendExtraBrowserArgs( |
422 '--data-reduction-proxy-lo-fi=always-on') | 429 '--data-reduction-proxy-lo-fi=always-on') |
423 options.AppendExtraBrowserArgs( | 430 options.AppendExtraBrowserArgs( |
424 '--enable-data-reduction-proxy-lo-fi-preview') | 431 '--enable-data-reduction-proxy-lo-fi-preview') |
| 432 options.AppendExtraBrowserArgs('--disable-quic') |
425 | 433 |
426 def AddResults(self, tab, results): | 434 def AddResults(self, tab, results): |
427 self._metrics.AddResultsForLoFiPreview(tab, results) | 435 self._metrics.AddResultsForLoFiPreview(tab, results) |
428 | 436 |
429 class ChromeProxyExpDirective(ChromeProxyValidation): | 437 class ChromeProxyExpDirective(ChromeProxyValidation): |
430 """Correctness measurement for experiment directives in Chrome-Proxy header. | 438 """Correctness measurement for experiment directives in Chrome-Proxy header. |
431 | 439 |
432 This test verifies that "exp=test" in the Chrome-Proxy request header | 440 This test verifies that "exp=test" in the Chrome-Proxy request header |
433 causes a bypass on the experiment test page. | 441 causes a bypass on the experiment test page. |
434 """ | 442 """ |
(...skipping 17 matching lines...) Expand all Loading... |
452 causes a resource to be loaded without Data Reduction Proxy transformations. | 460 causes a resource to be loaded without Data Reduction Proxy transformations. |
453 """ | 461 """ |
454 | 462 |
455 def __init__(self): | 463 def __init__(self): |
456 super(ChromeProxyPassThrough, self).__init__( | 464 super(ChromeProxyPassThrough, self).__init__( |
457 restart_after_each_page=True, | 465 restart_after_each_page=True, |
458 metrics=metrics.ChromeProxyMetric()) | 466 metrics=metrics.ChromeProxyMetric()) |
459 | 467 |
460 def CustomizeBrowserOptions(self, options): | 468 def CustomizeBrowserOptions(self, options): |
461 super(ChromeProxyPassThrough, self).CustomizeBrowserOptions(options) | 469 super(ChromeProxyPassThrough, self).CustomizeBrowserOptions(options) |
| 470 options.AppendExtraBrowserArgs('--disable-quic') |
462 | 471 |
463 def AddResults(self, tab, results): | 472 def AddResults(self, tab, results): |
464 self._metrics.AddResultsForPassThrough(tab, results) | 473 self._metrics.AddResultsForPassThrough(tab, results) |
465 | 474 |
466 class ChromeProxyHTTPToDirectFallback(ChromeProxyValidation): | 475 class ChromeProxyHTTPToDirectFallback(ChromeProxyValidation): |
467 """Correctness measurement for HTTP proxy fallback to direct.""" | 476 """Correctness measurement for HTTP proxy fallback to direct.""" |
468 | 477 |
469 def __init__(self): | 478 def __init__(self): |
470 super(ChromeProxyHTTPToDirectFallback, self).__init__( | 479 super(ChromeProxyHTTPToDirectFallback, self).__init__( |
471 restart_after_each_page=True, | 480 restart_after_each_page=True, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 ], | 566 ], |
558 'bypass': [self._metrics.AddResultsForBypass], | 567 'bypass': [self._metrics.AddResultsForBypass], |
559 } | 568 } |
560 if not self._page.name in page_to_metrics: | 569 if not self._page.name in page_to_metrics: |
561 raise page_test.MeasurementFailure( | 570 raise page_test.MeasurementFailure( |
562 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( | 571 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( |
563 self._page.name, page_to_metrics.keys())) | 572 self._page.name, page_to_metrics.keys())) |
564 for add_result in page_to_metrics[self._page.name]: | 573 for add_result in page_to_metrics[self._page.name]: |
565 add_result(tab, results) | 574 add_result(tab, results) |
566 | 575 |
| 576 class ChromeProxyQuicSmoke(page_test.PageTest): |
| 577 """Smoke measurement for basic chrome proxy correctness when using a |
| 578 proxy that supports QUIC.""" |
| 579 |
| 580 def __init__(self, *args, **kwargs): |
| 581 super(ChromeProxyQuicSmoke, self).__init__(*args, **kwargs) |
| 582 self._metrics = metrics.ChromeProxyMetric() |
| 583 self._enable_proxy = True |
| 584 |
| 585 def CustomizeBrowserOptions(self, options): |
| 586 super(ChromeProxyQuicSmoke, self).CustomizeBrowserOptions(options) |
| 587 options.AppendExtraBrowserArgs( |
| 588 '--enable-quic') |
| 589 options.AppendExtraBrowserArgs( |
| 590 '--data-reduction-proxy-http-proxies=https://proxy.googlezip.net:443') |
| 591 options.AppendExtraBrowserArgs( |
| 592 '--force-fieldtrials=DataReductionProxyUseQuic/Enabled') |
| 593 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') |
| 594 |
| 595 def WillNavigateToPage(self, page, tab): |
| 596 if self._enable_proxy: |
| 597 measurements.WaitForViaHeader(tab) |
| 598 tab.ClearCache(force=True) |
| 599 self._metrics.Start(page, tab) |
| 600 |
| 601 def ValidateAndMeasurePage(self, page, tab, results): |
| 602 # Wait for the load event. |
| 603 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) |
| 604 self._metrics.Stop(page, tab) |
| 605 page_to_metrics = { |
| 606 'header validation': [self._metrics.AddResultsForHeaderValidation], |
| 607 'compression: image': [ |
| 608 self._metrics.AddResultsForHeaderValidation, |
| 609 self._metrics.AddResultsForDataSaving, |
| 610 ], |
| 611 'compression: javascript': [ |
| 612 self._metrics.AddResultsForHeaderValidation, |
| 613 self._metrics.AddResultsForDataSaving, |
| 614 ], |
| 615 'compression: css': [ |
| 616 self._metrics.AddResultsForHeaderValidation, |
| 617 self._metrics.AddResultsForDataSaving, |
| 618 ], |
| 619 'bypass': [self._metrics.AddResultsForBypass], |
| 620 } |
| 621 if not page.name in page_to_metrics: |
| 622 raise page_test.MeasurementFailure( |
| 623 'Invalid page name (%s) in QUIC smoke. ' |
| 624 'Page name must be one of:\n%s' % ( |
| 625 page.name, page_to_metrics.keys())) |
| 626 for add_result in page_to_metrics[page.name]: |
| 627 add_result(tab, results) |
567 | 628 |
568 PROXIED = metrics.PROXIED | 629 PROXIED = metrics.PROXIED |
569 DIRECT = metrics.DIRECT | 630 DIRECT = metrics.DIRECT |
570 | 631 |
571 class ChromeProxyClientConfig(ChromeProxyValidation): | 632 class ChromeProxyClientConfig(ChromeProxyValidation): |
572 """Chrome proxy client configuration service validation.""" | 633 """Chrome proxy client configuration service validation.""" |
573 | 634 |
574 def __init__(self): | 635 def __init__(self): |
575 super(ChromeProxyClientConfig, self).__init__( | 636 super(ChromeProxyClientConfig, self).__init__( |
576 restart_after_each_page=True, | 637 restart_after_each_page=True, |
577 metrics=metrics.ChromeProxyMetric()) | 638 metrics=metrics.ChromeProxyMetric()) |
578 | 639 |
579 def CustomizeBrowserOptions(self, options): | 640 def CustomizeBrowserOptions(self, options): |
580 super(ChromeProxyClientConfig, self).CustomizeBrowserOptions(options) | 641 super(ChromeProxyClientConfig, self).CustomizeBrowserOptions(options) |
581 options.AppendExtraBrowserArgs( | 642 options.AppendExtraBrowserArgs( |
582 '--enable-data-reduction-proxy-config-client') | 643 '--enable-data-reduction-proxy-config-client') |
| 644 options.AppendExtraBrowserArgs('--disable-quic') |
583 | 645 |
584 def AddResults(self, tab, results): | 646 def AddResults(self, tab, results): |
585 self._metrics.AddResultsForClientConfig(tab, results) | 647 self._metrics.AddResultsForClientConfig(tab, results) |
586 | 648 |
587 class ChromeProxyVideoValidation(page_test.PageTest): | 649 class ChromeProxyVideoValidation(page_test.PageTest): |
588 """Validation for video pages. | 650 """Validation for video pages. |
589 | 651 |
590 Measures pages using metrics.ChromeProxyVideoMetric. Pages can be fetched | 652 Measures pages using metrics.ChromeProxyVideoMetric. Pages can be fetched |
591 either direct from the origin server or via the proxy. If a page is fetched | 653 either direct from the origin server or via the proxy. If a page is fetched |
592 both ways, then the PROXIED and DIRECT measurements are compared to ensure | 654 both ways, then the PROXIED and DIRECT measurements are compared to ensure |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 762 |
701 def CustomizeBrowserOptions(self, options): | 763 def CustomizeBrowserOptions(self, options): |
702 super(ChromeProxyPingback, self).CustomizeBrowserOptions(options) | 764 super(ChromeProxyPingback, self).CustomizeBrowserOptions(options) |
703 options.AppendExtraBrowserArgs( | 765 options.AppendExtraBrowserArgs( |
704 '--enable-data-reduction-proxy-force-pingback') | 766 '--enable-data-reduction-proxy-force-pingback') |
705 options.AppendExtraBrowserArgs( | 767 options.AppendExtraBrowserArgs( |
706 '--enable-stats-collection-bindings') | 768 '--enable-stats-collection-bindings') |
707 | 769 |
708 def AddResults(self, tab, results): | 770 def AddResults(self, tab, results): |
709 self._metrics.AddResultsForPingback(tab, results) | 771 self._metrics.AddResultsForPingback(tab, results) |
| 772 |
| 773 class ChromeProxyQuicTransaction(page_test.PageTest): |
| 774 """Chrome quic proxy usage validation when connecting to a proxy that |
| 775 supports QUIC.""" |
| 776 |
| 777 def __init__(self, *args, **kwargs): |
| 778 super(ChromeProxyQuicTransaction, self).__init__(*args, **kwargs) |
| 779 self._metrics = metrics.ChromeProxyMetric() |
| 780 self._enable_proxy = True |
| 781 |
| 782 def CustomizeBrowserOptions(self, options): |
| 783 options.AppendExtraBrowserArgs( |
| 784 '--enable-quic') |
| 785 options.AppendExtraBrowserArgs( |
| 786 '--data-reduction-proxy-http-proxies=https://proxy.googlezip.net:443') |
| 787 options.AppendExtraBrowserArgs( |
| 788 '--force-fieldtrials=DataReductionProxyUseQuic/Enabled') |
| 789 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') |
| 790 options.AppendExtraBrowserArgs( |
| 791 '--enable-stats-collection-bindings') |
| 792 |
| 793 def WillNavigateToPage(self, page, tab): |
| 794 if self._enable_proxy: |
| 795 measurements.WaitForViaHeader(tab) |
| 796 tab.ClearCache(force=True) |
| 797 self._metrics.Start(page, tab) |
| 798 |
| 799 def ValidateAndMeasurePage(self, page, tab, results): |
| 800 # Wait for the load event. |
| 801 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) |
| 802 self._metrics.Stop(page, tab) |
| 803 self._metrics.AddResultsForQuicTransaction(tab, results) |
OLD | NEW |