Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 | 5 |
| 6 """Utility script to launch browser-tests on the Chromoting bot.""" | 6 """Utility script to launch browser-tests on the Chromoting bot.""" |
| 7 import argparse | 7 import argparse |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 from chromoting_test_utilities import CleanupUserProfileDir | 10 from chromoting_test_utilities import CleanupUserProfileDir |
| 11 from chromoting_test_utilities import GetJidFromHostLog | 11 from chromoting_test_utilities import GetJidFromHostLog |
| 12 from chromoting_test_utilities import GetJidListFromTestResults | 12 from chromoting_test_utilities import GetJidListFromTestResults |
| 13 from chromoting_test_utilities import InitialiseTestMachineForLinux | 13 from chromoting_test_utilities import InitialiseTestMachineForLinux |
| 14 from chromoting_test_utilities import MAX_RETRIES | |
| 14 from chromoting_test_utilities import PrintHostLogContents | 15 from chromoting_test_utilities import PrintHostLogContents |
| 15 from chromoting_test_utilities import PROD_DIR_ID | 16 from chromoting_test_utilities import PROD_DIR_ID |
| 16 from chromoting_test_utilities import RunCommandInSubProcess | 17 from chromoting_test_utilities import RunCommandInSubProcess |
| 17 from chromoting_test_utilities import TestCaseSetup | 18 from chromoting_test_utilities import TestCaseSetup |
| 18 from chromoting_test_utilities import TestMachineCleanup | 19 from chromoting_test_utilities import TestMachineCleanup |
| 19 | 20 |
| 20 SUCCESS_INDICATOR = 'SUCCESS: all tests passed.' | 21 SUCCESS_INDICATOR = 'SUCCESS: all tests passed.' |
| 21 TEST_FAILURE = False | 22 TEST_FAILURE = False |
| 22 FAILING_TESTS = '' | 23 FAILING_TESTS = '' |
| 23 BROWSER_NOT_STARTED_ERROR = ( | 24 BROWSER_NOT_STARTED_ERROR = ( |
| 24 'Still waiting for the following processes to finish') | 25 'Still waiting for the following processes to finish') |
| 25 TIME_OUT_INDICATOR = '(TIMED OUT)' | 26 TIME_OUT_INDICATOR = '(TIMED OUT)' |
| 26 MAX_RETRIES = 1 | |
| 27 | 27 |
| 28 | 28 |
| 29 def LaunchBTCommand(args, command): | 29 def LaunchBTCommand(args, command): |
| 30 """Launches the specified browser-test command. | 30 """Launches the specified browser-test command. |
| 31 | 31 |
| 32 Retry if the execution failed because a browser-instance was not launched or | 32 Retry if the execution failed because a browser-instance was not launched or |
| 33 because the JID used did not match the host-JID. | 33 because the JID used did not match the host-JID. |
| 34 Args: | 34 Args: |
| 35 args: Command line args, used for test-case startup tasks. | 35 args: Command line args, used for test-case startup tasks. |
| 36 command: Browser-test command line. | 36 command: Browser-test command line. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 print 'JID used by test matched me2me host JID: %s' % host_jid | 86 print 'JID used by test matched me2me host JID: %s' % host_jid |
| 87 else: | 87 else: |
| 88 # There wasn't a mismatch and no JIDs were returned. If no JIDs were | 88 # There wasn't a mismatch and no JIDs were returned. If no JIDs were |
| 89 # returned, that means the test didn't use any JIDs, so there is nothing | 89 # returned, that means the test didn't use any JIDs, so there is nothing |
| 90 # further for us to do. | 90 # further for us to do. |
| 91 pass | 91 pass |
| 92 | 92 |
| 93 if SUCCESS_INDICATOR in results: | 93 if SUCCESS_INDICATOR in results: |
| 94 break | 94 break |
| 95 | 95 |
| 96 # Sometimes, during execution of browser-tests, a browser instance is | 96 # Test failed, retry. |
|
joedow
2016/02/20 17:08:38
I think this logic is important to keep. In the l
anandc1
2016/02/22 20:58:08
Done. Logging a line indicating what type of failu
| |
| 97 # not started and the test times out. See http://crbug/480025. | |
| 98 # To work around it, check if this execution failed owing to that | |
| 99 # problem and retry. | |
| 100 # There are 2 things to look for in the results: | |
| 101 # A line saying "Still waiting for the following processes to finish", | |
| 102 # and, because sometimes that line gets logged even if the test | |
| 103 # eventually passes, we'll also look for "(TIMED OUT)", before retrying. | |
| 104 if not ( | |
| 105 BROWSER_NOT_STARTED_ERROR in results and TIME_OUT_INDICATOR in results): | |
| 106 # Test failed for some other reason. Let's not retry. | |
| 107 break | |
| 108 retries += 1 | 97 retries += 1 |
| 109 | 98 |
| 110 # Check that the test passed. | 99 # Check that the test passed. |
| 111 if SUCCESS_INDICATOR not in results: | 100 if SUCCESS_INDICATOR not in results: |
| 112 TEST_FAILURE = True | 101 TEST_FAILURE = True |
| 113 # Add this command-line to list of tests that failed. | 102 # Add this command-line to list of tests that failed. |
| 114 FAILING_TESTS += command | 103 FAILING_TESTS += command |
| 115 | 104 |
| 116 return host_log_file_names | 105 return host_log_file_names |
| 117 | 106 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 try: | 144 try: |
| 156 host_logs = main(command_line_args) | 145 host_logs = main(command_line_args) |
| 157 if TEST_FAILURE: | 146 if TEST_FAILURE: |
| 158 print '++++++++++AT LEAST 1 TEST FAILED++++++++++' | 147 print '++++++++++AT LEAST 1 TEST FAILED++++++++++' |
| 159 print FAILING_TESTS.rstrip('\n') | 148 print FAILING_TESTS.rstrip('\n') |
| 160 print '++++++++++++++++++++++++++++++++++++++++++' | 149 print '++++++++++++++++++++++++++++++++++++++++++' |
| 161 raise Exception('At least one test failed.') | 150 raise Exception('At least one test failed.') |
| 162 finally: | 151 finally: |
| 163 # Stop host and cleanup user-profile-dir. | 152 # Stop host and cleanup user-profile-dir. |
| 164 TestMachineCleanup(command_line_args.user_profile_dir, host_logs) | 153 TestMachineCleanup(command_line_args.user_profile_dir, host_logs) |
| OLD | NEW |