Skip to content
Permalink
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):


Canonical link: https://commits.webkit.org/93684@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Jan 23, 2012
1 parent 3512e38 commit 111370474c5cf42e4589a00c7619924c407a5718
Showing 4 changed files with 47 additions and 6 deletions.
@@ -1,3 +1,24 @@
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 @@ def __init__(self, url, timeout_seconds):
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 @@ def upload_as_multipart_form_data(self, filesystem, files, params, timeout_secon

# 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 @@ def _generate_json(self, timestamp, output_json_path, source_json_path, branch,
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 @@ def mock_upload_json(hostname, json_path):

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 @@ def upload_single_text_file(mock, filesystem, content_type, filename):
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

0 comments on commit 1113704

Please sign in to comment.