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

Side by Side Diff: testing/chromoting/chromoting_test_driver_launcher.py

Issue 1718733002: Add a retry to Chromoting tests on Linux builders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Retain logic to identify failure owing to http://crbug/480025. Add TODO to remove retries for Integ… Created 4 years, 10 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """Utility script to run chromoting test driver tests on the Chromoting bot.""" 5 """Utility script to run chromoting test driver tests on the Chromoting bot."""
6 6
7 import argparse 7 import argparse
8 8
9 from chromoting_test_utilities import GetJidFromHostLog 9 from chromoting_test_utilities import GetJidFromHostLog
10 from chromoting_test_utilities import InitialiseTestMachineForLinux 10 from chromoting_test_utilities import InitialiseTestMachineForLinux
11 from chromoting_test_utilities import MAX_RETRIES
11 from chromoting_test_utilities import PrintHostLogContents 12 from chromoting_test_utilities import PrintHostLogContents
12 from chromoting_test_utilities import PROD_DIR_ID 13 from chromoting_test_utilities import PROD_DIR_ID
13 from chromoting_test_utilities import RunCommandInSubProcess 14 from chromoting_test_utilities import RunCommandInSubProcess
14 from chromoting_test_utilities import TestCaseSetup 15 from chromoting_test_utilities import TestCaseSetup
15 from chromoting_test_utilities import TestMachineCleanup 16 from chromoting_test_utilities import TestMachineCleanup
16 17
17 TEST_ENVIRONMENT_TEAR_DOWN_INDICATOR = 'Global test environment tear-down' 18 TEST_ENVIRONMENT_TEAR_DOWN_INDICATOR = 'Global test environment tear-down'
18 FAILED_INDICATOR = '[ FAILED ]' 19 FAILED_INDICATOR = '[ FAILED ]'
19 20
20 21
(...skipping 12 matching lines...) Expand all
33 34
34 host_log_file_names.append(TestCaseSetup(args)) 35 host_log_file_names.append(TestCaseSetup(args))
35 # Parse the me2me host log to obtain the JID that the host registered. 36 # Parse the me2me host log to obtain the JID that the host registered.
36 host_jid = GetJidFromHostLog(host_log_file_names[-1]) 37 host_jid = GetJidFromHostLog(host_log_file_names[-1])
37 38
38 if not host_jid: 39 if not host_jid:
39 # Host-JID not found in log. Let's not attempt to run this test. 40 # Host-JID not found in log. Let's not attempt to run this test.
40 print 'Host-JID not found in log %s.' % host_log_file_names[-1] 41 print 'Host-JID not found in log %s.' % host_log_file_names[-1]
41 return '[Command failed]: %s, %s' % (command, host_log_file_names) 42 return '[Command failed]: %s, %s' % (command, host_log_file_names)
42 43
43 # In order to ensure the host is online with the expected JID, pass in the 44 retries = 0
44 # jid obtained from the host-log as a command-line parameter. 45 failed_tests_list = []
45 command = command.replace('\n', '') + ' --hostjid=%s' % host_jid 46 # TODO(jamiewalch): Remove this retry-logic once http://crbug/570840 is fixed.
joedow 2016/02/22 21:52:15 I think this should be TODO(anandc): blah... The
anandc1 2016/02/22 21:56:08 I see. Thanks. Done.
47 while retries <= MAX_RETRIES:
48 # In order to ensure the host is online with the expected JID, pass in the
49 # jid obtained from the host-log as a command-line parameter.
50 command = command.replace('\n', '') + ' --hostjid=%s' % host_jid
46 51
47 results = RunCommandInSubProcess(command) 52 results = RunCommandInSubProcess(command)
48 53
49 tear_down_index = results.find(TEST_ENVIRONMENT_TEAR_DOWN_INDICATOR) 54 tear_down_index = results.find(TEST_ENVIRONMENT_TEAR_DOWN_INDICATOR)
50 if tear_down_index == -1: 55 if tear_down_index == -1:
51 # The test environment did not tear down. Something went horribly wrong. 56 # The test environment did not tear down. Something went horribly wrong.
52 return '[Command failed]: ' + command, host_log_file_names 57 return '[Command failed]: ' + command, host_log_file_names
53 58
54 end_results_list = results[tear_down_index:].split('\n') 59 end_results_list = results[tear_down_index:].split('\n')
55 failed_tests_list = [] 60 test_failed = False
56 for result in end_results_list: 61 for result in end_results_list:
57 if result.startswith(FAILED_INDICATOR): 62 if result.startswith(FAILED_INDICATOR):
58 failed_tests_list.append(result) 63 test_failed = True
64 if retries == MAX_RETRIES:
65 # Test failed and we have no more retries left.
66 failed_tests_list.append(result)
67
68 if test_failed:
69 retries += 1
70 else:
71 break
59 72
60 if failed_tests_list: 73 if failed_tests_list:
61 test_result = '[Command]: ' + command 74 test_result = '[Command]: ' + command
62 # Note: Skipping the first one is intentional. 75 # Note: Skipping the first one is intentional.
63 for i in range(1, len(failed_tests_list)): 76 for i in range(1, len(failed_tests_list)):
64 test_result += ' ' + failed_tests_list[i] 77 test_result += ' ' + failed_tests_list[i]
65 return test_result, host_log_file_names 78 return test_result, host_log_file_names
66 79
67 # All tests passed! 80 # All tests passed!
68 return '', host_log_file_names 81 return '', host_log_file_names
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 try: 123 try:
111 failing_tests, host_logs = main(command_line_args) 124 failing_tests, host_logs = main(command_line_args)
112 if failing_tests: 125 if failing_tests:
113 print '++++++++++FAILED TESTS++++++++++' 126 print '++++++++++FAILED TESTS++++++++++'
114 print failing_tests.rstrip('\n') 127 print failing_tests.rstrip('\n')
115 print '++++++++++++++++++++++++++++++++' 128 print '++++++++++++++++++++++++++++++++'
116 raise Exception('At least one test failed.') 129 raise Exception('At least one test failed.')
117 finally: 130 finally:
118 # Stop host and cleanup user-profile-dir. 131 # Stop host and cleanup user-profile-dir.
119 TestMachineCleanup(command_line_args.user_profile_dir, host_logs) 132 TestMachineCleanup(command_line_args.user_profile_dir, host_logs)
OLDNEW
« no previous file with comments | « testing/chromoting/browser_tests_launcher.py ('k') | testing/chromoting/chromoting_test_utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698