Commit b8edc624 authored by rniwa@webkit.org's avatar rniwa@webkit.org
Browse files

run-perf-tests should report server-side errors

https://bugs.webkit.org/show_bug.cgi?id=76802

Reviewed by Tony Chang.

Report errors whenever server's response doesn't match "OK".

* Scripts/webkitpy/common/net/file_uploader.py:
(FileUploader.upload_single_text_file):
(FileUploader.upload_as_multipart_form_data):
(FileUploader._upload_data.callback):
(FileUploader):
(FileUploader._upload_data):
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner._upload_json):
* Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py:
(test_upload_json):
(test_upload_json.MockFileUploader.upload_single_text_file):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5f5c5f30
2012-01-23 Ryosuke Niwa <rniwa@webkit.org>
run-perf-tests should report server-side errors
https://bugs.webkit.org/show_bug.cgi?id=76802
Reviewed by Tony Chang.
Report errors whenever server's response doesn't match "OK".
* Scripts/webkitpy/common/net/file_uploader.py:
(FileUploader.upload_single_text_file):
(FileUploader.upload_as_multipart_form_data):
(FileUploader._upload_data.callback):
(FileUploader):
(FileUploader._upload_data):
* Scripts/webkitpy/performance_tests/perftestsrunner.py:
(PerfTestsRunner._upload_json):
* Scripts/webkitpy/performance_tests/perftestsrunner_unittest.py:
(test_upload_json):
(test_upload_json.MockFileUploader.upload_single_text_file):
2012-01-22 Ryosuke Niwa <rniwa@webkit.org>
 
run-perf-tests ignore Skipped list on chromium
......@@ -89,7 +89,7 @@ class FileUploader(object):
self._timeout_seconds = timeout_seconds
def upload_single_text_file(self, filesystem, content_type, filename):
self._upload_data(content_type, filesystem.read_text_file(filename))
return self._upload_data(content_type, filesystem.read_text_file(filename))
def upload_as_multipart_form_data(self, filesystem, files, params, timeout_seconds):
file_objs = []
......@@ -99,17 +99,19 @@ class FileUploader(object):
# FIXME: We should use the same variable names for the formal and actual parameters.
content_type, data = _encode_multipart_form_data(attrs, file_objs)
self._upload_data(content_type, data)
return self._upload_data(content_type, data)
def _upload_data(self, content_type, data):
def callback():
request = urllib2.Request(self._url, data, {"Content-Type": content_type})
urllib2.urlopen(request)
return urllib2.urlopen(request)
orig_timeout = socket.getdefaulttimeout()
response = None
try:
# FIXME: We shouldn't mutate global static state.
socket.setdefaulttimeout(self._timeout_seconds)
NetworkTransaction(timeout_seconds=self._timeout_seconds).run(callback)
response = NetworkTransaction(timeout_seconds=self._timeout_seconds).run(callback)
finally:
socket.setdefaulttimeout(orig_timeout)
return response
......@@ -174,11 +174,18 @@ class PerfTestsRunner(object):
def _upload_json(self, test_results_server, json_path, file_uploader=FileUploader):
uploader = file_uploader("https://%s/api/test/report" % test_results_server, 120)
try:
uploader.upload_single_text_file(self._host.filesystem, 'application/json', json_path)
response = uploader.upload_single_text_file(self._host.filesystem, 'application/json', json_path)
except Exception, error:
_log.error("Failed to upload JSON file in 120s: %s" % error)
return False
response_body = [line.strip('\n') for line in response]
if response_body != ['OK']:
_log.error("Uploaded JSON but got a bad response:")
for line in response_body:
_log.error(line)
return False
self._printer.write("JSON file uploaded.")
return True
......
......@@ -29,12 +29,14 @@
"""Unit tests for run_perf_tests."""
import StringIO
import json
import unittest
from webkitpy.common import array_stream
from webkitpy.common.host_mock import MockHost
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.layout_tests.port.driver import DriverInput, DriverOutput
from webkitpy.layout_tests.port.test import TestPort
from webkitpy.layout_tests.views import printing
......@@ -240,11 +242,12 @@ max 1120
def test_upload_json(self):
regular_output = array_stream.ArrayStream()
runner = self.create_runner(buildbot_output=regular_output)
runner = self.create_runner(regular_output=regular_output)
runner._host.filesystem.files['/mock-checkout/some.json'] = 'some content'
called = []
upload_single_text_file_throws = False
upload_single_text_file_return_value = StringIO.StringIO('OK')
class MockFileUploader:
def __init__(mock, url, timeout):
......@@ -259,10 +262,18 @@ max 1120
called.append('upload_single_text_file')
if upload_single_text_file_throws:
raise "Some exception"
return upload_single_text_file_return_value
runner._upload_json('some.host', 'some.json', MockFileUploader)
self.assertEqual(called, ['FileUploader', 'upload_single_text_file'])
output = OutputCapture()
output.capture_output()
upload_single_text_file_return_value = StringIO.StringIO('Some error')
runner._upload_json('some.host', 'some.json', MockFileUploader)
_, _, logs = output.restore_output()
self.assertEqual(logs, 'Uploaded JSON but got a bad response:\nSome error\n')
# Throwing an exception upload_single_text_file shouldn't blow up _upload_json
called = []
upload_single_text_file_throws = True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment