Changeset 249652 in webkit
- Timestamp:
- Sep 9, 2019 11:29:12 AM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r249648 r249652 1 2019-09-09 Jonathan Bedard <jbedard@apple.com> 2 3 run-webkit-tests: Report results archive to results.webkit.org 4 https://bugs.webkit.org/show_bug.cgi?id=201321 5 6 Reviewed by Aakash Jain. 7 8 * Scripts/webkitpy/layout_tests/controllers/manager.py: 9 (Manager.run): After all tests are finish, upload the results archive for each 10 configuration. 11 * Scripts/webkitpy/results/upload.py: 12 (Upload): 13 (Upload.__init__): Automatically define timestamp. 14 (Upload.upload_archive): Upload an archive associated with the test run. 15 * Scripts/webkitpy/results/upload_unittest.py: 16 (UploadTest.test_buildbot): 17 (UploadTest): 18 (UploadTest.test_archive_upload): 19 1 20 2019-09-09 Chris Dumez <cdumez@apple.com> 2 21 -
trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
r248270 r249652 38 38 import logging 39 39 import random 40 import shutil 40 41 import sys 41 42 import time … … 245 246 max_child_processes_for_run = 1 246 247 child_processes_option_value = self._options.child_processes 248 uploads = [] 247 249 248 250 for device_type in device_type_list: … … 282 284 details=Upload.create_details(options=self._options), 283 285 commits=self._port.commits_for_upload(), 286 timestamp=start_time, 284 287 run_stats=Upload.create_run_stats( 285 288 start_time=start_time_for_device, … … 289 292 results=self._results_to_upload_json_trie(self._expectations[device_type], temp_initial_results), 290 293 ) 291 for urlin self._options.report_urls:292 self._printer.write_update('Uploading to {} ...'.format( url))293 if not upload.upload( url, log_line_func=self._printer.writeln):294 for hostname in self._options.report_urls: 295 self._printer.write_update('Uploading to {} ...'.format(hostname)) 296 if not upload.upload(hostname, log_line_func=self._printer.writeln): 294 297 num_failed_uploads += 1 298 else: 299 uploads.append(upload) 295 300 self._printer.writeln('Uploads completed!') 296 301 … … 310 315 end_time = time.time() 311 316 result = self._end_test_run(start_time, end_time, initial_results, retry_results, enabled_pixel_tests_in_retry) 317 318 if self._options.report_urls and uploads: 319 self._printer.writeln('\n') 320 self._printer.write_update('Preparing to upload test archive ...') 321 322 with self._filesystem.mkdtemp() as temp: 323 archive = self._filesystem.join(temp, 'test-archive') 324 shutil.make_archive(archive, 'zip', self._results_directory) 325 326 for upload in uploads: 327 for hostname in self._options.report_urls: 328 self._printer.write_update('Uploading archive to {} ...'.format(hostname)) 329 if not upload.upload_archive(hostname, self._filesystem.open_binary_file_for_reading(archive + '.zip'), log_line_func=self._printer.writeln): 330 num_failed_uploads += 1 331 312 332 if num_failed_uploads: 313 333 result.exit_code = -1 -
trunk/Tools/Scripts/webkitpy/results/upload.py
r243030 r249652 26 26 import requests 27 27 import sys 28 import time 28 29 29 30 import platform as host_platform … … 32 33 class Upload(object): 33 34 UPLOAD_ENDPOINT = '/api/upload' 35 ARCHIVE_UPLOAD_ENDPOINT = '/api/upload/archive' 34 36 BUILDBOT_DETAILS = ['buildbot-master', 'builder-name', 'build-number', 'buildbot-worker'] 35 37 VERSION = 0 … … 100 102 self.configuration = configuration 101 103 self.commits = commits 102 self.timestamp = timestamp104 self.timestamp = int(timestamp or time.time()) 103 105 self.details = details 104 106 self.run_stats = run_stats … … 166 168 return result 167 169 168 def upload(self, url, log_line_func=lambda val: sys.stdout.write(val + '\n')):170 def upload(self, hostname, log_line_func=lambda val: sys.stdout.write(val + '\n')): 169 171 try: 170 response = requests.post( url + self.UPLOAD_ENDPOINT, data=json.dumps(self, cls=Upload.Encoder))172 response = requests.post('{}{}'.format(hostname, self.UPLOAD_ENDPOINT), data=json.dumps(self, cls=Upload.Encoder)) 171 173 except requests.exceptions.ConnectionError: 172 log_line_func(' ' * 4 + 'Failed to upload to {}, results server not online'.format( url))174 log_line_func(' ' * 4 + 'Failed to upload to {}, results server not online'.format(hostname)) 173 175 return False 174 176 except ValueError as e: … … 177 179 178 180 if response.status_code != 200: 179 log_line_func(' ' * 4 + 'Error uploading to {} :'.format(url))180 log_line_func(' ' * 8 + response.json() ['description'])181 return False 182 183 log_line_func(' ' * 4 + 'Uploaded results to {}'.format( url))181 log_line_func(' ' * 4 + 'Error uploading to {}'.format(hostname)) 182 log_line_func(' ' * 8 + response.json().get('description')) 183 return False 184 185 log_line_func(' ' * 4 + 'Uploaded results to {}'.format(hostname)) 184 186 return True 187 188 def upload_archive(self, hostname, archive, log_line_func=lambda val: sys.stdout.write(val + '\n')): 189 try: 190 meta_data = dict( 191 version=self.VERSION, 192 suite=self.suite, 193 configuration=json.dumps(self.configuration or self.create_configuration()), 194 commits=json.dumps(self.commits), 195 ) 196 if self.timestamp: 197 meta_data['timestamp'] = self.timestamp 198 response = requests.post( 199 '{}{}'.format(hostname, self.ARCHIVE_UPLOAD_ENDPOINT), 200 data=meta_data, 201 files=dict(file=archive), 202 ) 203 204 except requests.exceptions.ConnectionError: 205 log_line_func(' ' * 4 + 'Failed to upload test archive to {}, results server not online'.format(hostname)) 206 return False 207 except ValueError as e: 208 log_line_func(' ' * 4 + 'Failed to encode archive reference data: {}'.format(e)) 209 return False 210 211 if response.status_code != 200: 212 log_line_func(' ' * 4 + 'Error uploading archive to {}'.format(hostname)) 213 log_line_func(' ' * 8 + response.json().get('description')) 214 return False 215 216 log_line_func(' ' * 4 + 'Uploaded test archive to {}'.format(hostname)) 217 return True -
trunk/Tools/Scripts/webkitpy/results/upload_unittest.py
r243030 r249652 128 128 129 129 with mock.patch('requests.post', new=lambda url, data: self.MockResponse()): 130 self.assertTrue(upload.upload('https:// webkit.org/results', log_line_func=lambda _: None))130 self.assertTrue(upload.upload('https://results.webkit.org', log_line_func=lambda _: None)) 131 131 132 132 with mock.patch('requests.post', new=lambda url, data: self.raise_requests_ConnectionError()): 133 self.assertFalse(upload.upload('https://webkit.org/results', log_line_func=lambda _: None)) 133 lines = [] 134 self.assertFalse(upload.upload('https://results.webkit.org', log_line_func=lambda line: lines.append(line))) 135 self.assertEqual([' ' * 4 + 'Failed to upload to https://results.webkit.org, results server not online'], lines) 134 136 135 137 mock_404 = mock.patch('requests.post', new=lambda url, data: self.MockResponse( … … 138 140 )) 139 141 with mock_404: 140 self.assertFalse(upload.upload('https:// webkit.org/results', log_line_func=lambda _: None))142 self.assertFalse(upload.upload('https://results.webkit.org', log_line_func=lambda _: None)) 141 143 142 144 def test_packed_test(self): … … 215 217 'buildbot-worker': 'bot123', 216 218 })) 219 220 def test_archive_upload(self): 221 upload = Upload( 222 suite='webkitpy-tests', 223 commits=[Upload.create_commit( 224 repository_id='webkit', 225 id='5', 226 branch='trunk', 227 )], 228 ) 229 230 with mock.patch('requests.post', new=lambda url, data, files: self.MockResponse()): 231 self.assertTrue(upload.upload_archive('https://results.webkit.org', archive='content', log_line_func=lambda _: None)) 232 233 with mock.patch('requests.post', new=lambda url, data, files: self.raise_requests_ConnectionError()): 234 lines = [] 235 self.assertFalse(upload.upload_archive('https://results.webkit.org', archive='content', log_line_func=lambda line: lines.append(line))) 236 self.assertEqual([' ' * 4 + 'Failed to upload test archive to https://results.webkit.org, results server not online'], lines) 237 238 mock_404 = mock.patch('requests.post', new=lambda url, data, files: self.MockResponse( 239 status_code=404, 240 text=json.dumps(dict(description='No such address')), 241 )) 242 with mock_404: 243 lines = [] 244 self.assertFalse(upload.upload_archive('https://results.webkit.org', archive='content', log_line_func=lambda line: lines.append(line))) 245 self.assertEqual([ 246 ' ' * 4 + 'Error uploading archive to https://results.webkit.org', 247 ' ' * 8 + 'No such address', 248 ], lines)
Note: See TracChangeset
for help on using the changeset viewer.