Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A Windows-only end-to-end integration test for Kasko, Chrome and Crashpad. | 6 """A Windows-only end-to-end integration test for the Kasko hang watcher. |
| 7 | 7 |
| 8 This test ensures that the interface between Kasko and Chrome and Crashpad works | 8 This test ensures that Kasko is able to detect when Chrome is hanged and to |
|
Sigurður Ásgeirsson
2016/01/11 19:42:58
is hanged -> hangs
also I think you intend to name
Patrick Monette
2016/01/20 17:21:35
Done.
| |
| 9 as expected. The test causes Kasko to set certain crash keys and invoke a crash | 9 generate a report. The report is then delivered to a locally hosted test crash |
| 10 report, which is in turn delivered to a locally hosted test crash server. If the | 10 server. If a crash report is received then all is well. |
| 11 crash report is received intact with the expected crash keys then all is well. | |
| 12 | 11 |
| 13 Note that this test only works against non-component Release and Official builds | 12 Note that this test only works against non-component Release and Official builds |
|
Sigurður Ásgeirsson
2016/01/11 19:42:58
the bulk of this file wants to be reused rather th
chrisha
2016/01/12 19:42:15
I've got a CL in progress which lifts all of the p
Patrick Monette
2016/01/20 17:21:35
Done.
| |
| 14 of Chrome with Chrome branding, and attempting to use it with anything else will | 13 of Chrome with Chrome branding, and attempting to use it with anything else will |
| 15 most likely lead to constant failures. | 14 most likely lead to constant failures. |
| 16 | 15 |
| 17 Typical usage (assuming in root 'src' directory): | 16 Typical usage (assuming in root 'src' directory): |
| 18 | 17 |
| 19 - generate project files with the following GYP variables: | 18 - generate project files with the following GYP variables: |
| 20 branding=Chrome syzyasan=1 win_z7=0 chromium_win_pch=0 | 19 branding=Chrome kasko=1 kasko_hang_reports=1 |
| 21 - build the release Chrome binaries: | 20 - build the release Chrome binaries and driver: |
| 22 ninja -C out\Release chrome.exe | 21 ninja -C out\Release chrome.exe |
| 22 ninja -C out\Release chromedriver.exe | |
| 23 - run the test: | 23 - run the test: |
| 24 python chrome/test/kasko/kasko_integration_test.py --chrome-dir=out/Release | 24 python chrome/test/kasko/hang_watcher_integration_test.py |
| 25 | 25 |
| 26 Many of the components in this test could be reused in other end-to-end crash | 26 Many of the components in this test could be reused in other end-to-end crash |
| 27 testing. Feel free to open them up for reuse, but please CC chrisha@chromium.org | 27 testing. Feel free to open them up for reuse, but please CC chrisha@chromium.org |
| 28 on any associated reviews or bugs! | 28 on any associated reviews or bugs! |
| 29 """ | 29 """ |
| 30 | 30 |
| 31 import BaseHTTPServer | 31 import BaseHTTPServer |
| 32 import cgi | 32 import cgi |
| 33 import logging | 33 import logging |
| 34 import os | 34 import os |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 | 524 |
| 525 # Launch the test server. | 525 # Launch the test server. |
| 526 server = _CrashServer() | 526 server = _CrashServer() |
| 527 with _ScopedStartStop(server): | 527 with _ScopedStartStop(server): |
| 528 _LOGGER.info('Started server on port %d', server.port) | 528 _LOGGER.info('Started server on port %d', server.port) |
| 529 | 529 |
| 530 # Configure the environment so Chrome can find the test crash server. | 530 # Configure the environment so Chrome can find the test crash server. |
| 531 os.environ['KASKO_CRASH_SERVER_URL'] = ( | 531 os.environ['KASKO_CRASH_SERVER_URL'] = ( |
| 532 'http://127.0.0.1:%d/crash' % server.port) | 532 'http://127.0.0.1:%d/crash' % server.port) |
| 533 | 533 |
| 534 # Launch Chrome and navigate it to the test URL. | 534 # Launch Chrome and navigate to the hang URL. |
| 535 chrome = _ChromeInstance(options.chromedriver, options.chrome, | 535 chrome = _ChromeInstance(options.chromedriver, options.chrome, |
| 536 user_data_dir) | 536 user_data_dir) |
| 537 with _ScopedStartStop(chrome): | 537 with _ScopedStartStop(chrome): |
| 538 _LOGGER.info('Navigating to Kasko debug URL') | 538 _LOGGER.info('Navigating to the hang debug URL') |
| 539 chrome.navigate_to('chrome://kasko/send-report') | 539 chrome.navigate_to('chrome://uithreadhang') |
| 540 | 540 |
| 541 _LOGGER.info('Waiting for Kasko report') | 541 _LOGGER.info('Waiting for Kasko report') |
| 542 if not server.wait_for_report(10): | |
| 543 raise Exception('No Kasko report received.') | |
| 544 | 542 |
| 545 report = server.crash(0) | 543 # The report can take as long as 80 seconds to be generated because |
| 546 for key in sorted(report.keys()): | 544 # the polling is done every 60 seconds and the watcher gives 20 |
| 547 val = report[key][0] | 545 # seconds to Chrome to ping back before being considered hanged. |
| 548 if (len(val) < 64): | 546 if not server.wait_for_report(120): |
| 549 _LOGGER.debug('Got crashkey "%s": "%s"', key, val) | 547 raise Exception('No Kasko report received') |
| 550 else: | |
| 551 _LOGGER.debug('Got crashkey "%s": ...%d bytes...', key, len(val)) | |
| 552 | 548 |
| 553 expected_keys = { | 549 _LOGGER.info('Received Kasko report successfully') |
| 554 'kasko-set-crash-key-value-impl': 'SetCrashKeyValueImpl', | 550 # TODO(pmonette): Verify that the report contains the expected crash |
| 555 'guid': 'GetCrashKeysForKasko'} | 551 # keys when they will work. |
| 556 for expected_key, error in expected_keys.iteritems(): | |
| 557 if expected_key not in report: | |
| 558 _LOGGER.error('Missing expected "%s" crash key.', expected_key) | |
| 559 raise Exception('"%s" integration appears broken.' % error) | |
| 560 | 552 |
| 561 return 0 | 553 return 0 |
| 562 | 554 |
| 563 | 555 |
| 564 if __name__ == '__main__': | 556 if __name__ == '__main__': |
| 565 sys.exit(Main()) | 557 sys.exit(Main()) |
| OLD | NEW |