[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

abarth at webkit.org abarth at webkit.org
Thu Apr 8 00:59:19 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit b1caf8e3c8a8511e6211e140bcdd36d50ded6e48
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jan 10 00:20:52 2010 +0000

    2010-01-09  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Eric Seidel.
    
            Retry writes to QueueStatusServer when we get 500 errors
            https://bugs.webkit.org/show_bug.cgi?id=33412
    
            This prevents the queues from failing to mark a patch as "pass" or
            "fail" when AppEngine throws 500 errors.
    
            * Scripts/test-webkitpy:
            * Scripts/webkitpy/networktransaction.py: Added.
            * Scripts/webkitpy/networktransaction_unittest.py: Added.
            * Scripts/webkitpy/statusserver.py:
            * Scripts/webkitpy/steps/closebugformarkbugfixed.py: Added.
            * Scripts/webkitpy/steps/closebugregardlessofpatches.py: Added.
            * Scripts/webkitpy/steps/findbugidfromsvnrevision.py: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53043 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 2e757ae..8326a33 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,21 @@
+2010-01-09  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        Retry writes to QueueStatusServer when we get 500 errors
+        https://bugs.webkit.org/show_bug.cgi?id=33412
+
+        This prevents the queues from failing to mark a patch as "pass" or
+        "fail" when AppEngine throws 500 errors.
+
+        * Scripts/test-webkitpy:
+        * Scripts/webkitpy/networktransaction.py: Added.
+        * Scripts/webkitpy/networktransaction_unittest.py: Added.
+        * Scripts/webkitpy/statusserver.py:
+        * Scripts/webkitpy/steps/closebugformarkbugfixed.py: Added.
+        * Scripts/webkitpy/steps/closebugregardlessofpatches.py: Added.
+        * Scripts/webkitpy/steps/findbugidfromsvnrevision.py: Added.
+
 2010-01-09  David Kilzer  <ddkilzer at apple.com>
 
         <http://webkit.org/b/33430> Fix rounded borders in queue status on older Firefox and Safari browsers
diff --git a/WebKitTools/Scripts/test-webkitpy b/WebKitTools/Scripts/test-webkitpy
index 4c2e1df..f320eeb 100755
--- a/WebKitTools/Scripts/test-webkitpy
+++ b/WebKitTools/Scripts/test-webkitpy
@@ -43,6 +43,7 @@ from webkitpy.credentials_unittest import *
 from webkitpy.diff_parser_unittest import *
 from webkitpy.executive_unittest import *
 from webkitpy.multicommandtool_unittest import *
+from webkitpy.networktransaction_unittest import *
 from webkitpy.queueengine_unittest import *
 from webkitpy.steps.steps_unittest import *
 from webkitpy.steps.updatechangelogswithreview_unittests import *
diff --git a/WebKitTools/Scripts/webkitpy/networktransaction.py b/WebKitTools/Scripts/webkitpy/networktransaction.py
new file mode 100644
index 0000000..65ea27d
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/networktransaction.py
@@ -0,0 +1,63 @@
+# Copyright (C) 2010 Google Inc. All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import time
+
+from mechanize import HTTPError
+from webkitpy.webkit_logging import log
+
+
+class NetworkTimeout(Exception):
+    pass
+
+
+class NetworkTransaction(object):
+    def __init__(self, initial_backoff_seconds=10, grown_factor=1.1, timeout_seconds=5*60*60):
+        self._initial_backoff_seconds = initial_backoff_seconds
+        self._grown_factor = grown_factor
+        self._timeout_seconds = timeout_seconds
+
+    def run(self, request):
+        self._total_sleep = 0
+        self._backoff_seconds = self._initial_backoff_seconds
+        while True:
+            try:
+                return request()
+            except HTTPError, e:
+                self._check_for_timeout()
+                log("Received HTTP status %s from server.  Retrying in %s seconds..." % (e.code, self._backoff_seconds))
+                self._sleep()
+
+    def _check_for_timeout(self):
+        if self._total_sleep + self._backoff_seconds > self._timeout_seconds:
+            raise NetworkTimeout()
+
+    def _sleep(self):
+        time.sleep(self._backoff_seconds)
+        self._total_sleep += self._backoff_seconds
+        self._backoff_seconds *= self._grown_factor
diff --git a/WebKitTools/Scripts/webkitpy/networktransaction_unittest.py b/WebKitTools/Scripts/webkitpy/networktransaction_unittest.py
new file mode 100644
index 0000000..3cffe02
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/networktransaction_unittest.py
@@ -0,0 +1,80 @@
+# Copyright (c) 2010 Google Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# 
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import unittest
+
+from mechanize import HTTPError
+from webkitpy.networktransaction import NetworkTransaction, NetworkTimeout
+
+class NetworkTransactionTest(unittest.TestCase):
+    exception = Exception("Test exception")
+
+    def test_success(self):
+        transaction = NetworkTransaction()
+        self.assertEqual(transaction.run(lambda: 42), 42)
+
+    def _raise_exception(self):
+        raise self.exception
+
+    def test_exception(self):
+        transaction = NetworkTransaction()
+        did_process_exception = False
+        did_throw_exception = True
+        try:
+            transaction.run(lambda: self._raise_exception())
+            did_throw_exception = False
+        except Exception, e:
+            did_process_exception = True
+            self.assertEqual(e, self.exception)
+        self.assertTrue(did_throw_exception)
+        self.assertTrue(did_process_exception)
+
+    def _raise_http_error(self):
+        self._run_count += 1
+        if self._run_count < 3:
+            raise HTTPError("http://example.com/", 500, "inteneral server error", None, None)
+        return 42
+
+    def test_retry(self):
+        self._run_count = 0
+        transaction = NetworkTransaction(initial_backoff_seconds=0)
+        self.assertEqual(transaction.run(lambda: self._raise_http_error()), 42)
+        self.assertEqual(self._run_count, 3)
+
+    def test_timeout(self):
+        self._run_count = 0
+        transaction = NetworkTransaction(initial_backoff_seconds=60*60, timeout_seconds=60)
+        did_process_exception = False
+        did_throw_exception = True
+        try:
+            transaction.run(lambda: self._raise_http_error())
+            did_throw_exception = False
+        except NetworkTimeout, e:
+            did_process_exception = True
+        self.assertTrue(did_throw_exception)
+        self.assertTrue(did_process_exception)
diff --git a/WebKitTools/Scripts/webkitpy/statusserver.py b/WebKitTools/Scripts/webkitpy/statusserver.py
index 61161a7..cc2aeae 100644
--- a/WebKitTools/Scripts/webkitpy/statusserver.py
+++ b/WebKitTools/Scripts/webkitpy/statusserver.py
@@ -25,9 +25,8 @@
 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# WebKit's Python module for interacting with the Commit Queue status page.
 
+from webkitpy.networktransaction import NetworkTransaction
 from webkitpy.webkit_logging import log
 from mechanize import Browser
 
@@ -52,26 +51,36 @@ class StatusServer:
     def results_url_for_status(self, status_id):
         return "%s/results/%s" % (self.url, status_id)
 
-    def update_status(self, queue_name, status, patch=None, results_file=None):
-        # During unit testing, host is None
-        if not self.host:
+    def _add_patch(self, patch):
+        if not patch:
             return
+        if patch.get('bug_id'):
+            self.browser['bug_id'] = str(patch['bug_id'])
+        if patch.get('id'):
+            self.browser['patch_id'] = str(patch['id'])
 
-        log(status)
+    def _add_results_file(self, results_file):
+        if not results_file:
+            return
+        self.browser.add_file(results_file, "text/plain", "results.txt", 'results_file')
+
+    def _post_to_server(self, queue_name, status, patch, results_file):
         update_status_url = "%s/update-status" % self.url
         self.browser.open(update_status_url)
         self.browser.select_form(name="update_status")
         self.browser['queue_name'] = queue_name
-        if patch:
-            if patch.get('bug_id'):
-                self.browser['bug_id'] = str(patch['bug_id'])
-            if patch.get('id'):
-                self.browser['patch_id'] = str(patch['id'])
+        self._add_patch(patch)
         self.browser['status'] = status
-        if results_file:
-            self.browser.add_file(results_file, "text/plain", "results.txt", 'results_file')
-        response = self.browser.submit()
-        return response.read() # This is the id of the newly created status object.
+        self._add_results_file(results_file)
+        return self.browser.submit().read() # This is the id of the newly created status object.
+
+    def update_status(self, queue_name, status, patch=None, results_file=None):
+        # During unit testing, host is None
+        if not self.host:
+            return
+
+        log(status)
+        return NetworkTransaction().run(lambda: self._post_to_server(queue_name, status, patch, results_file))
 
     def patch_status(self, queue_name, patch_id):
         update_status_url = "%s/patch-status/%s/%s" % (self.url, queue_name, patch_id)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list