[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

mihaip at chromium.org mihaip at chromium.org
Wed Dec 22 13:55:25 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6630d77aff231a830bf0ba1e042ce012d5621d23
Author: mihaip at chromium.org <mihaip at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 29 19:07:40 2010 +0000

    2010-09-29  Mihai Parparita  <mihaip at chromium.org>
    
            Reviewed by Adam Barth.
    
            Record bot ID when updating queue status
            https://bugs.webkit.org/show_bug.cgi?id=46764
    
            Since we now have multiple bots handling patches from the commit queue,
            we need to differentiate status updates from them, so that we can group
            the queue status page in a less confusing way.
    
            * QueueStatusServer/handlers/updatestatus.py: Accept bot_id as input
            * QueueStatusServer/model/queuestatus.py: Add bot_id property
            * QueueStatusServer/templates/updatestatus.html: Add bot_id input
            * Scripts/webkitpy/common/net/bugzilla_unittest.py: Extract MockBrowser
            * Scripts/webkitpy/common/net/statusserver.py: Add bot_id
            * Scripts/webkitpy/common/net/statusserver_unittest.py: Added.
            * Scripts/webkitpy/tool/main.py: Add --bot-id
            * Scripts/webkitpy/tool/mocktool.py: Add MockBrowser
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68673 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 7ab1f58..fc0850e 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2010-09-29  Mihai Parparita  <mihaip at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Record bot ID when updating queue status
+        https://bugs.webkit.org/show_bug.cgi?id=46764
+        
+        Since we now have multiple bots handling patches from the commit queue,
+        we need to differentiate status updates from them, so that we can group
+        the queue status page in a less confusing way.
+
+        * QueueStatusServer/handlers/updatestatus.py: Accept bot_id as input
+        * QueueStatusServer/model/queuestatus.py: Add bot_id property
+        * QueueStatusServer/templates/updatestatus.html: Add bot_id input
+        * Scripts/webkitpy/common/net/bugzilla_unittest.py: Extract MockBrowser
+        * Scripts/webkitpy/common/net/statusserver.py: Add bot_id
+        * Scripts/webkitpy/common/net/statusserver_unittest.py: Added.
+        * Scripts/webkitpy/tool/main.py: Add --bot-id
+        * Scripts/webkitpy/tool/mocktool.py: Add MockBrowser
+
 2010-09-29  Simon Fraser  <simon.fraser at apple.com>
 
         No review.
diff --git a/WebKitTools/QueueStatusServer/handlers/updatestatus.py b/WebKitTools/QueueStatusServer/handlers/updatestatus.py
index 89858b6..7f27cc6 100644
--- a/WebKitTools/QueueStatusServer/handlers/updatestatus.py
+++ b/WebKitTools/QueueStatusServer/handlers/updatestatus.py
@@ -49,7 +49,9 @@ class UpdateStatus(UpdateBase):
         bug_id = self._int_from_request("bug_id")
         patch_id = self._int_from_request("patch_id")
         queue_name = self.request.get("queue_name")
+        bot_id = self.request.get("bot_id")
         queue_status.queue_name = queue_name
+        queue_status.bot_id = bot_id
         queue_status.active_bug_id = bug_id
         queue_status.active_patch_id = patch_id
         queue_status.message = self.request.get("status")
diff --git a/WebKitTools/QueueStatusServer/model/queuestatus.py b/WebKitTools/QueueStatusServer/model/queuestatus.py
index 3d7e599..d7dae45 100644
--- a/WebKitTools/QueueStatusServer/model/queuestatus.py
+++ b/WebKitTools/QueueStatusServer/model/queuestatus.py
@@ -31,6 +31,7 @@ from google.appengine.ext import db
 class QueueStatus(db.Model):
     author = db.UserProperty()
     queue_name = db.StringProperty()
+    bot_id = db.StringProperty()
     active_bug_id = db.IntegerProperty()
     active_patch_id = db.IntegerProperty()
     message = db.StringProperty(multiline=True)
diff --git a/WebKitTools/QueueStatusServer/templates/updatestatus.html b/WebKitTools/QueueStatusServer/templates/updatestatus.html
index 9343c60..0f98ba4 100644
--- a/WebKitTools/QueueStatusServer/templates/updatestatus.html
+++ b/WebKitTools/QueueStatusServer/templates/updatestatus.html
@@ -1,6 +1,10 @@
 <form name="update_status" enctype="multipart/form-data" method="post">
 Update status for a queue: <input name="queue_name">
  <div>
+     Bot Id:
+    <input name="bot_id">
+ </div>
+ <div>
      Active Bug Id:
     <input name="bug_id">
  </div>
diff --git a/WebKitTools/Scripts/webkitpy/common/net/bugzilla_unittest.py b/WebKitTools/Scripts/webkitpy/common/net/bugzilla_unittest.py
index 32f23cd..3a454d6 100644
--- a/WebKitTools/Scripts/webkitpy/common/net/bugzilla_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/common/net/bugzilla_unittest.py
@@ -33,24 +33,11 @@ import datetime
 from webkitpy.common.config.committers import CommitterList, Reviewer, Committer
 from webkitpy.common.net.bugzilla import Bugzilla, BugzillaQueries, parse_bug_id, CommitterValidator, Bug
 from webkitpy.common.system.outputcapture import OutputCapture
+from webkitpy.tool.mocktool import MockBrowser
 from webkitpy.thirdparty.mock import Mock
 from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup
 
 
-class MockBrowser(object):
-    def open(self, url):
-        pass
-
-    def select_form(self, name):
-        pass
-
-    def __setitem__(self, key, value):
-        pass
-
-    def submit(self):
-        pass
-
-
 class BugTest(unittest.TestCase):
     def test_is_unassigned(self):
         for email in Bug.unassigned_emails:
diff --git a/WebKitTools/Scripts/webkitpy/common/net/statusserver.py b/WebKitTools/Scripts/webkitpy/common/net/statusserver.py
index 57390b8..95d2f16 100644
--- a/WebKitTools/Scripts/webkitpy/common/net/statusserver.py
+++ b/WebKitTools/Scripts/webkitpy/common/net/statusserver.py
@@ -41,14 +41,18 @@ _log = logging.getLogger("webkitpy.common.net.statusserver")
 class StatusServer:
     default_host = "queues.webkit.org"
 
-    def __init__(self, host=default_host):
+    def __init__(self, host=default_host, browser=None, bot_id=None):
         self.set_host(host)
-        self.browser = Browser()
+        self._browser = browser or Browser()
+        self.set_bot_id(bot_id)
 
     def set_host(self, host):
         self.host = host
         self.url = "http://%s" % self.host
 
+    def set_bot_id(self, bot_id):
+        self.bot_id = bot_id
+
     def results_url_for_status(self, status_id):
         return "%s/results/%s" % (self.url, status_id)
 
@@ -56,14 +60,14 @@ class StatusServer:
         if not patch:
             return
         if patch.bug_id():
-            self.browser["bug_id"] = unicode(patch.bug_id())
+            self._browser["bug_id"] = unicode(patch.bug_id())
         if patch.id():
-            self.browser["patch_id"] = unicode(patch.id())
+            self._browser["patch_id"] = unicode(patch.id())
 
     def _add_results_file(self, results_file):
         if not results_file:
             return
-        self.browser.add_file(results_file, "text/plain", "results.txt", 'results_file')
+        self._browser.add_file(results_file, "text/plain", "results.txt", 'results_file')
 
     def _post_status_to_server(self, queue_name, status, patch, results_file):
         if results_file:
@@ -71,30 +75,32 @@ class StatusServer:
             results_file.seek(0)
 
         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
+        self._browser.open(update_status_url)
+        self._browser.select_form(name="update_status")
+        self._browser["queue_name"] = queue_name
+        if self.bot_id:
+            self._browser["bot_id"] = self.bot_id
         self._add_patch(patch)
-        self.browser["status"] = status
+        self._browser["status"] = status
         self._add_results_file(results_file)
-        return self.browser.submit().read() # This is the id of the newly created status object.
+        return self._browser.submit().read()  # This is the id of the newly created status object.
 
     def _post_svn_revision_to_server(self, svn_revision_number, broken_bot):
         update_svn_revision_url = "%s/update-svn-revision" % self.url
-        self.browser.open(update_svn_revision_url)
-        self.browser.select_form(name="update_svn_revision")
-        self.browser["number"] = unicode(svn_revision_number)
-        self.browser["broken_bot"] = broken_bot
-        return self.browser.submit().read()
+        self._browser.open(update_svn_revision_url)
+        self._browser.select_form(name="update_svn_revision")
+        self._browser["number"] = unicode(svn_revision_number)
+        self._browser["broken_bot"] = broken_bot
+        return self._browser.submit().read()
 
     def _post_work_items_to_server(self, queue_name, work_items):
         update_work_items_url = "%s/update-work-items" % self.url
-        self.browser.open(update_work_items_url)
-        self.browser.select_form(name="update_work_items")
-        self.browser["queue_name"] = queue_name
+        self._browser.open(update_work_items_url)
+        self._browser.select_form(name="update_work_items")
+        self._browser["queue_name"] = queue_name
         work_items = map(unicode, work_items)  # .join expects strings
-        self.browser["work_items"] = " ".join(work_items)
-        return self.browser.submit().read()
+        self._browser["work_items"] = " ".join(work_items)
+        return self._browser.submit().read()
 
     def next_work_item(self, queue_name):
         _log.debug("Fetching next work item for %s" % queue_name)
diff --git a/WebKitTools/Scripts/webkitpy/common/net/statusserver_unittest.py b/WebKitTools/Scripts/webkitpy/common/net/statusserver_unittest.py
new file mode 100644
index 0000000..1169ba0
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/common/net/statusserver_unittest.py
@@ -0,0 +1,43 @@
+# 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 webkitpy.common.net.statusserver import StatusServer
+from webkitpy.common.system.outputcapture import OutputCaptureTestCaseBase
+from webkitpy.tool.mocktool import MockBrowser
+
+
+class StatusServerTest(OutputCaptureTestCaseBase):
+    def test_url_for_issue(self):
+        mock_browser = MockBrowser()
+        status_server = StatusServer(browser=mock_browser, bot_id='123')
+        status_server.update_status('queue name', 'the status')
+        self.assertEqual('queue name', mock_browser.params['queue_name'])
+        self.assertEqual('the status', mock_browser.params['status'])
+        self.assertEqual('123', mock_browser.params['bot_id'])
diff --git a/WebKitTools/Scripts/webkitpy/common/system/outputcapture.py b/WebKitTools/Scripts/webkitpy/common/system/outputcapture.py
index 68a3919..45e0e3f 100644
--- a/WebKitTools/Scripts/webkitpy/common/system/outputcapture.py
+++ b/WebKitTools/Scripts/webkitpy/common/system/outputcapture.py
@@ -29,6 +29,7 @@
 # Class for unittest support.  Used for capturing stderr/stdout.
 
 import sys
+import unittest
 from StringIO import StringIO
 
 class OutputCapture(object):
@@ -37,7 +38,9 @@ class OutputCapture(object):
 
     def _capture_output_with_name(self, output_name):
         self.saved_outputs[output_name] = getattr(sys, output_name)
-        setattr(sys, output_name, StringIO())
+        captured_output = StringIO()
+        setattr(sys, output_name, captured_output)
+        return captured_output
 
     def _restore_output_with_name(self, output_name):
         captured_output = getattr(sys, output_name).getvalue()
@@ -46,8 +49,7 @@ class OutputCapture(object):
         return captured_output
 
     def capture_output(self):
-        self._capture_output_with_name("stdout")
-        self._capture_output_with_name("stderr")
+        return (self._capture_output_with_name("stdout"), self._capture_output_with_name("stderr"))
 
     def restore_output(self):
         return (self._restore_output_with_name("stdout"), self._restore_output_with_name("stderr"))
@@ -63,3 +65,22 @@ class OutputCapture(object):
         testcase.assertEqual(stderr_string, expected_stderr)
         # This is a little strange, but I don't know where else to return this information.
         return return_value
+
+
+class OutputCaptureTestCaseBase(unittest.TestCase):
+    def setUp(self):
+        unittest.TestCase.setUp(self)
+        self.output_capture = OutputCapture()
+        (self.__captured_stdout, self.__captured_stderr) = self.output_capture.capture_output()
+
+    def tearDown(self):
+        del self.__captured_stdout
+        del self.__captured_stderr
+        self.output_capture.restore_output()
+        unittest.TestCase.tearDown(self)
+
+    def assertStdout(self, expected_stdout):
+        self.assertEquals(expected_stdout, self.__captured_stdout.getvalue())
+
+    def assertStderr(self, expected_stderr):
+        self.assertEquals(expected_stderr, self.__captured_stderr.getvalue())
diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/queues.py b/WebKitTools/Scripts/webkitpy/tool/commands/queues.py
index 80fd2ea..4fb1a7c 100644
--- a/WebKitTools/Scripts/webkitpy/tool/commands/queues.py
+++ b/WebKitTools/Scripts/webkitpy/tool/commands/queues.py
@@ -78,6 +78,8 @@ class AbstractQueue(Command, QueueEngineDelegate):
         # because our global option code looks for the first argument which does
         # not begin with "-" and assumes that is the command name.
         webkit_patch_args += ["--status-host=%s" % self._tool.status_server.host]
+        if self._tool.status_server.bot_id:
+            webkit_patch_args += ["--bot-id=%s" % self._tool.status_server.bot_id]
         webkit_patch_args.extend(args)
         return self._tool.executive.run_and_throw_if_fail(webkit_patch_args)
 
diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py b/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py
index 029814e..c89a0c0 100644
--- a/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py
@@ -63,11 +63,12 @@ class AbstractQueueTest(CommandsTest):
     def _assert_run_webkit_patch(self, run_args):
         queue = TestQueue()
         tool = MockTool()
+        tool.status_server.bot_id = "gort"
         tool.executive = Mock()
         queue.bind_to_tool(tool)
 
         queue.run_webkit_patch(run_args)
-        expected_run_args = ["echo", "--status-host=example.com"] + run_args
+        expected_run_args = ["echo", "--status-host=example.com", "--bot-id=gort"] + run_args
         tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args)
 
     def test_run_webkit_patch(self):
diff --git a/WebKitTools/Scripts/webkitpy/tool/main.py b/WebKitTools/Scripts/webkitpy/tool/main.py
index 9531b63..b47bb43 100755
--- a/WebKitTools/Scripts/webkitpy/tool/main.py
+++ b/WebKitTools/Scripts/webkitpy/tool/main.py
@@ -59,8 +59,9 @@ class WebKitPatch(MultiCommandTool):
     global_options = [
         make_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="enable all logging"),
         make_option("--dry-run", action="store_true", dest="dry_run", default=False, help="do not touch remote servers"),
-        make_option("--status-host", action="store", dest="status_host", type="string", nargs=1, help="Hostname (e.g. localhost or commit.webkit.org) where status updates should be posted."),
-        make_option("--irc-password", action="store", dest="irc_password", type="string", nargs=1, help="Password to use when communicating via IRC."),
+        make_option("--status-host", action="store", dest="status_host", type="string", help="Hostname (e.g. localhost or commit.webkit.org) where status updates should be posted."),
+        make_option("--bot-id", action="store", dest="bot_id", type="string", help="Identifier for this bot (if multiple bots are running for a queue)"),
+        make_option("--irc-password", action="store", dest="irc_password", type="string", help="Password to use when communicating via IRC."),
     ]
 
     def __init__(self, path):
@@ -123,6 +124,8 @@ class WebKitPatch(MultiCommandTool):
             self.codereview.dryrun = True
         if options.status_host:
             self.status_server.set_host(options.status_host)
+        if options.bot_id:
+            self.status_server.set_bot_id(options.bot_id)
         if options.irc_password:
             self.irc_password = options.irc_password
 
diff --git a/WebKitTools/Scripts/webkitpy/tool/mocktool.py b/WebKitTools/Scripts/webkitpy/tool/mocktool.py
index 277bd08..fd25579 100644
--- a/WebKitTools/Scripts/webkitpy/tool/mocktool.py
+++ b/WebKitTools/Scripts/webkitpy/tool/mocktool.py
@@ -515,8 +515,9 @@ class MockIRC(object):
 
 class MockStatusServer(object):
 
-    def __init__(self, work_items=None):
+    def __init__(self, bot_id=None, work_items=None):
         self.host = "example.com"
+        self.bot_id = bot_id
         self._work_items = work_items or []
 
     def patch_status(self, queue_name, patch_id):
@@ -630,3 +631,19 @@ class MockTool():
 
     def path(self):
         return "echo"
+
+
+class MockBrowser(object):
+    params = {}
+
+    def open(self, url):
+        pass
+
+    def select_form(self, name):
+        pass
+
+    def __setitem__(self, key, value):
+        self.params[key] = value
+
+    def submit(self):
+        return Mock(file)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list