- Revision
- 113399
- Author
- [email protected]
- Date
- 2012-04-05 18:14:05 -0700 (Thu, 05 Apr 2012)
Log Message
nrwt is failing to upload test results on the chromium-mac-leopard bots
https://bugs.webkit.org/show_bug.cgi?id=83230
Reviewed by Ojan Vafai.
This should fix things properly; FileUploader() was setting the
socket default timeout value, and apparently that doesn't work
properly with urllib. Also, the class had a bad try/finally
block that was causing the exceptions to be swallowed :(.
* Scripts/webkitpy/common/net/file_uploader.py:
(FileUploader.__init__):
(FileUploader._upload_data.callback):
(FileUploader):
(FileUploader._upload_data):
* Scripts/webkitpy/common/net/networktransaction.py:
(NetworkTimeout.__str__):
(NetworkTransaction.run):
* Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
(JSONResultsGeneratorBase.upload_json_files):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (113398 => 113399)
--- trunk/Tools/ChangeLog 2012-04-06 01:06:57 UTC (rev 113398)
+++ trunk/Tools/ChangeLog 2012-04-06 01:14:05 UTC (rev 113399)
@@ -1,3 +1,26 @@
+2012-04-05 Dirk Pranke <[email protected]>
+
+ nrwt is failing to upload test results on the chromium-mac-leopard bots
+ https://bugs.webkit.org/show_bug.cgi?id=83230
+
+ Reviewed by Ojan Vafai.
+
+ This should fix things properly; FileUploader() was setting the
+ socket default timeout value, and apparently that doesn't work
+ properly with urllib. Also, the class had a bad try/finally
+ block that was causing the exceptions to be swallowed :(.
+
+ * Scripts/webkitpy/common/net/file_uploader.py:
+ (FileUploader.__init__):
+ (FileUploader._upload_data.callback):
+ (FileUploader):
+ (FileUploader._upload_data):
+ * Scripts/webkitpy/common/net/networktransaction.py:
+ (NetworkTimeout.__str__):
+ (NetworkTransaction.run):
+ * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
+ (JSONResultsGeneratorBase.upload_json_files):
+
2012-04-05 Patrick Gansterer <[email protected]>
[Qt] Correct <wtf/*.h> include paths.
Modified: trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py (113398 => 113399)
--- trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py 2012-04-06 01:06:57 UTC (rev 113398)
+++ trunk/Tools/Scripts/webkitpy/common/net/file_uploader.py 2012-04-06 01:14:05 UTC (rev 113399)
@@ -28,17 +28,13 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import codecs
-import logging
import mimetypes
-import socket
+import time
import urllib2
-from webkitpy.common.net.networktransaction import NetworkTransaction
+from webkitpy.common.net.networktransaction import NetworkTransaction, NetworkTimeout
-_log = logging.getLogger(__name__)
-
-
def get_mime_type(filename):
return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
@@ -86,10 +82,10 @@
class FileUploader(object):
- def __init__(self, url, timeout_seconds, debug=False):
+ def __init__(self, url, timeout_seconds):
self._url = url
self._timeout_seconds = timeout_seconds
- self._debug = debug
+ self._deadline = time.time() + self._timeout_seconds
def upload_single_text_file(self, filesystem, content_type, filename):
return self._upload_data(content_type, filesystem.read_text_file(filename))
@@ -107,19 +103,11 @@
def _upload_data(self, content_type, data):
def callback():
- if self._debug:
- _log.debug("uploading %d bytes to '%s', content-type '%s'" % (len(data), self._url, content_type))
+ now = time.time()
+ if now > self._deadline:
+ # This shouldn't happen, but just to be safe ...
+ raise NetworkTimeout()
request = urllib2.Request(self._url, data, {"Content-Type": content_type})
- return urllib2.urlopen(request)
+ return urllib2.urlopen(request, timeout=(self._deadline - now))
- orig_timeout = socket.getdefaulttimeout()
- response = None
- try:
- # FIXME: We shouldn't mutate global static state.
- # FIXME: clean this up once we understand what's going on on chromium leopard bots.
- if not self._debug:
- socket.setdefaulttimeout(self._timeout_seconds)
- return NetworkTransaction(timeout_seconds=self._timeout_seconds).run(callback)
- finally:
- if not self._debug:
- socket.setdefaulttimeout(orig_timeout)
+ return NetworkTransaction(timeout_seconds=self._timeout_seconds).run(callback)
Modified: trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py (113398 => 113399)
--- trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py 2012-04-06 01:06:57 UTC (rev 113398)
+++ trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py 2012-04-06 01:14:05 UTC (rev 113399)
@@ -37,7 +37,8 @@
class NetworkTimeout(Exception):
- pass
+ def __str__(self):
+ return 'NetworkTimeout'
class NetworkTransaction(object):
@@ -59,13 +60,7 @@
self._check_for_timeout()
_log.warn("Received HTTP status %s loading \"%s\". Retrying in %s seconds..." % (e.code, e.filename, self._backoff_seconds))
self._sleep()
- except urllib2.URLError, e:
- # FIXME: urllib2 seems to convert socket errors to this.
- self._check_for_timeout()
- _log.warn("Received URLError %s. Retrying in %s seconds..." % (str(s), self._backoff_seconds))
- self._sleep()
-
def _check_for_timeout(self):
if self._total_sleep + self._backoff_seconds > self._timeout_seconds:
raise NetworkTimeout()
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py (113398 => 113399)
--- trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py 2012-04-06 01:06:57 UTC (rev 113398)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py 2012-04-06 01:14:05 UTC (rev 113399)
@@ -317,18 +317,20 @@
url = "" % self._test_results_server
# Set uploading timeout in case appengine server is having problems.
# 120 seconds are more than enough to upload test results.
- uploader = FileUploader(url, 120, debug=True)
+ uploader = FileUploader(url, 120)
try:
response = uploader.upload_as_multipart_form_data(self._filesystem, files, attrs)
if response:
- _log.debug("Upload returned %d: '%s'" % (response.code, response.read()))
+ if response.code == 200:
+ _log.info("JSON uploaded.")
+ else:
+ _log.debug("JSON upload failed, %d: '%s'" % (response.code, response.read()))
else:
- _log.debug("Upload returned None")
+ _log.error("JSON upload failed; no response returned")
except Exception, err:
_log.error("Upload failed: %s" % err)
return
- _log.info("JSON files uploaded.")
def _get_test_timing(self, test_name):
"""Returns test timing data (elapsed time) in second