OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Runs the whole set unit tests on swarm.""" | 6 """Runs the whole set unit tests on swarm.""" |
7 | 7 |
8 import datetime | 8 import datetime |
9 import glob | 9 import glob |
10 import getpass | 10 import getpass |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 'archive', | 68 'archive', |
69 '--isolate', os.path.join(BASE_DIR, 'run_a_test.isolate'), | 69 '--isolate', os.path.join(BASE_DIR, 'run_a_test.isolate'), |
70 '--isolated', isolated, | 70 '--isolated', isolated, |
71 '--outdir', self.isolate_server, | 71 '--outdir', self.isolate_server, |
72 '--variable', 'TEST_EXECUTABLE', test, | 72 '--variable', 'TEST_EXECUTABLE', test, |
73 '--variable', 'OS', OSES[platform], | 73 '--variable', 'OS', OSES[platform], |
74 ]) | 74 ]) |
75 step_name = '%s/%s (%3.2fs)' % (platform, test_name, duration) | 75 step_name = '%s/%s (%3.2fs)' % (platform, test_name, duration) |
76 if returncode: | 76 if returncode: |
77 self.progress.update_item( | 77 self.progress.update_item( |
78 'Failed to archive %s\n%s' % (step_name, stdout), index=True) | 78 'Failed to archive %s\n%s' % (step_name, stdout), index=1) |
79 else: | 79 else: |
80 hash_value = hashlib.sha1(open(isolated, 'rb').read()).hexdigest() | 80 hash_value = hashlib.sha1(open(isolated, 'rb').read()).hexdigest() |
81 logging.info('%s: %s', step_name, hash_value) | 81 logging.info('%s: %s', step_name, hash_value) |
82 self.progress.update_item('Archived %s' % step_name, index=True) | 82 self.progress.update_item('Archived %s' % step_name, index=1) |
83 self.add_task(0, self.trigger, test, platform, hash_value) | 83 self.add_task(0, self.trigger, test, platform, hash_value) |
84 finally: | 84 finally: |
85 try: | 85 try: |
86 os.remove(isolated) | 86 os.remove(isolated) |
87 except OSError: | 87 except OSError: |
88 logging.debug('%s was already deleted', isolated) | 88 logging.debug('%s was already deleted', isolated) |
89 return None | 89 return None |
90 | 90 |
91 def trigger(self, test, platform, hash_value): | 91 def trigger(self, test, platform, hash_value): |
92 test_name = os.path.basename(test) | 92 test_name = os.path.basename(test) |
(...skipping 11 matching lines...) Expand all Loading... |
104 # Test name. | 104 # Test name. |
105 'swarm_client_tests_%s_%s' % (platform, test_name), | 105 'swarm_client_tests_%s_%s' % (platform, test_name), |
106 # Number of shards. | 106 # Number of shards. |
107 '1', | 107 '1', |
108 # test filter. | 108 # test filter. |
109 '*', | 109 '*', |
110 ]) | 110 ]) |
111 step_name = '%s/%s (%3.2fs)' % (platform, test_name, duration) | 111 step_name = '%s/%s (%3.2fs)' % (platform, test_name, duration) |
112 if returncode: | 112 if returncode: |
113 self.progress.update_item( | 113 self.progress.update_item( |
114 'Failed to trigger %s\n%s' % (step_name, stdout), index=True) | 114 'Failed to trigger %s\n%s' % (step_name, stdout), index=1) |
115 else: | 115 else: |
116 self.progress.update_item('Triggered %s' % step_name, index=True) | 116 self.progress.update_item('Triggered %s' % step_name, index=1) |
117 self.add_task(0, self.get_result, test, platform) | 117 self.add_task(0, self.get_result, test, platform) |
118 return None | 118 return None |
119 | 119 |
120 def get_result(self, test, platform): | 120 def get_result(self, test, platform): |
121 test_name = os.path.basename(test) | 121 test_name = os.path.basename(test) |
122 name = '%s_%s' % (platform, test_name) | 122 name = '%s_%s' % (platform, test_name) |
123 returncode, stdout, duration = self._call( | 123 returncode, stdout, duration = self._call( |
124 [ | 124 [ |
125 'swarming.py', | 125 'swarming.py', |
126 'collect', | 126 'collect', |
127 '--swarming', self.swarm_server, | 127 '--swarming', self.swarm_server, |
128 self.prefix + 'swarm_client_tests_' + name, | 128 self.prefix + 'swarm_client_tests_' + name, |
129 ]) | 129 ]) |
130 step_name = '%s/%s (%3.2fs)' % (platform, test_name, duration) | 130 step_name = '%s/%s (%3.2fs)' % (platform, test_name, duration) |
131 # Only print the output for failures, successes are unexciting. | 131 # Only print the output for failures, successes are unexciting. |
132 if returncode: | 132 if returncode: |
133 self.progress.update_item( | 133 self.progress.update_item( |
134 'Failed %s:\n%s' % (step_name, stdout), index=True) | 134 'Failed %s:\n%s' % (step_name, stdout), index=1) |
135 return (test_name, platform, stdout) | 135 return (test_name, platform, stdout) |
136 self.progress.update_item('Passed %s' % step_name, index=True) | 136 self.progress.update_item('Passed %s' % step_name, index=1) |
137 return None | 137 return None |
138 | 138 |
139 | 139 |
140 def run_swarm_tests_on_swarm(oses, tests, logs, isolate_server, swarm_server): | 140 def run_swarm_tests_on_swarm(oses, tests, logs, isolate_server, swarm_server): |
141 runs = len(tests) * len(oses) | 141 runs = len(tests) * len(oses) |
142 total = 3 * runs | 142 total = 3 * runs |
143 progress = threading_utils.Progress(total) | 143 progress = threading_utils.Progress(total) |
144 progress.use_cr_only = False | 144 progress.use_cr_only = False |
145 tempdir = tempfile.mkdtemp(prefix='swarm_client_tests') | 145 tempdir = tempfile.mkdtemp(prefix='swarm_client_tests') |
146 try: | 146 try: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return run_swarm_tests_on_swarm( | 239 return run_swarm_tests_on_swarm( |
240 oses, | 240 oses, |
241 tests, | 241 tests, |
242 options.logs, | 242 options.logs, |
243 options.isolate_server, | 243 options.isolate_server, |
244 options.swarming) | 244 options.swarming) |
245 | 245 |
246 | 246 |
247 if __name__ == '__main__': | 247 if __name__ == '__main__': |
248 sys.exit(main()) | 248 sys.exit(main()) |
OLD | NEW |