Changeset 70409 in webkit


Ignore:
Timestamp:
Oct 23, 2010 9:44:57 PM (13 years ago)
Author:
eric@webkit.org
Message:

2010-10-23 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

EWS never removes invalid patch ids
https://bugs.webkit.org/show_bug.cgi?id=48173

This is just sticking another finger in the dam.
However this adds more unit testing which will help
us make sure we're always releasing patches once we
redesign the release_patch API and call these from
a more central place.

  • Scripts/webkitpy/tool/commands/queues.py:
  • Scripts/webkitpy/tool/commands/queues_unittest.py:
  • Scripts/webkitpy/tool/mocktool.py:
    • Added the ability to request invalid patches. Log a warning message to make sure we don't ever have tests use invalid patch fetches by mistake.
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r70404 r70409  
     12010-10-23  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        EWS never removes invalid patch ids
     6        https://bugs.webkit.org/show_bug.cgi?id=48173
     7
     8        This is just sticking another finger in the dam.
     9        However this adds more unit testing which will help
     10        us make sure we're always releasing patches once we
     11        redesign the release_patch API and call these from
     12        a more central place.
     13
     14        * Scripts/webkitpy/tool/commands/queues.py:
     15        * Scripts/webkitpy/tool/commands/queues_unittest.py:
     16        * Scripts/webkitpy/tool/mocktool.py:
     17         - Added the ability to request invalid patches.
     18           Log a warning message to make sure we don't ever have
     19           tests use invalid patch fetches by mistake.
     20
    1212010-10-23  Dan Bernstein  <mitz@apple.com>
    222
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues.py

    r70382 r70409  
    3939from StringIO import StringIO
    4040
    41 from webkitpy.common.net.bugzilla import CommitterValidator
     41from webkitpy.common.net.bugzilla import CommitterValidator, Attachment
    4242from webkitpy.common.net.layouttestresults import path_for_layout_test, LayoutTestResults
    4343from webkitpy.common.net.statusserver import StatusServer
     
    202202        return self._tool.status_server.update_status(self.name, message, patch, results_file)
    203203
    204     def _fetch_next_work_item(self):
    205         return self._tool.status_server.next_work_item(self.name)
     204    def _next_patch(self):
     205        patch_id = self._tool.status_server.next_work_item(self.name)
     206        if not patch_id:
     207            return None
     208        patch = self._tool.bugs.fetch_attachment(patch_id)
     209        if not patch:
     210            # FIXME: Using a fake patch because release_work_item has the wrong API.
     211            # We also don't really need to release the lock (although that's fine),
     212            # mostly we just need to remove this bogus patch from our queue.
     213            # If for some reason bugzilla is just down, then it will be re-fed later.
     214            patch = Attachment({'id': patch_id}, None)
     215            self._release_work_item(patch)
     216            return None
     217        return patch
    206218
    207219    def _release_work_item(self, patch):
     
    239251
    240252    def next_work_item(self):
    241         patch_id = self._fetch_next_work_item()
    242         if not patch_id:
    243             return None
    244         return self._tool.bugs.fetch_attachment(patch_id)
     253        return self._next_patch()
    245254
    246255    def should_proceed_with_work_item(self, patch):
     
    396405
    397406    def next_work_item(self):
    398         patch_id = self._fetch_next_work_item()
    399         if not patch_id:
    400             return None
    401         return self._tool.bugs.fetch_attachment(patch_id)
     407        return self._next_patch()
    402408
    403409    def should_proceed_with_work_item(self, patch):
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py

    r70374 r70409  
    140140
    141141class AbstractPatchQueueTest(CommandsTest):
    142     def test_fetch_next_work_item(self):
     142    def test_next_patch(self):
    143143        queue = AbstractPatchQueue()
    144144        tool = MockTool()
     
    146146        queue._options = Mock()
    147147        queue._options.port = None
    148         self.assertEquals(queue._fetch_next_work_item(), None)
    149         tool.status_server = MockStatusServer(work_items=[2, 1, 3])
    150         self.assertEquals(queue._fetch_next_work_item(), 2)
     148        self.assertEquals(queue._next_patch(), None)
     149        tool.status_server = MockStatusServer(work_items=[2, 197])
     150        expected_stdout = "MOCK: fetch_attachment: 2 is not a known attachment id\n"  # A mock-only message to prevent us from making mistakes.
     151        expected_stderr = "MOCK: release_work_item: None 2\n"
     152        patch_id = OutputCapture().assert_outputs(self, queue._next_patch, [], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
     153        self.assertEquals(patch_id, None)  # 2 is an invalid patch id
     154        self.assertEquals(queue._next_patch().id(), 197)
    151155
    152156
  • trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py

    r70328 r70409  
    293293            return self._override_patch
    294294
    295         # This could be changed to .get() if we wish to allow failed lookups.
    296         attachment_dictionary = self.attachment_cache[attachment_id]
     295        attachment_dictionary = self.attachment_cache.get(attachment_id)
     296        if not attachment_dictionary:
     297            print "MOCK: fetch_attachment: %s is not a known attachment id" % attachment_id
     298            return None
    297299        bug = self.fetch_bug(attachment_dictionary["bug_id"])
    298300        for attachment in bug.attachments(include_obsolete=True):
     
    554556        if not self._work_items:
    555557            return None
    556         return self._work_items[0]
     558        return self._work_items.pop(0)
    557559
    558560    def release_work_item(self, queue_name, patch):
Note: See TracChangeset for help on using the changeset viewer.