Title: [115142] trunk/Tools
Revision
115142
Author
[email protected]
Date
2012-04-24 17:10:48 -0700 (Tue, 24 Apr 2012)

Log Message

webkit-patch rebaseline-test is retrieving stale expectations
https://bugs.webkit.org/show_bug.cgi?id=84762

Reviewed by Ojan Vafai.

webkit-patch rebaseline-expectations is fetching files directly
from the layout-test-results directory on the buildbots, rather
than fetching them from the archive. This is problematic because
we don't clobber the directory after each run and so you can end
up fetching stale failing results.

This change temporarily changes the code to fetch the zip file
instead -- making things much slower -- until I can confer w/
abarth and ojan over the best way to fix this for the long-term.

* Scripts/webkitpy/tool/commands/rebaseline.py:
(RebaselineTest.__init__):
(RebaselineTest._zip_file_set):
(RebaselineTest):
(RebaselineTest._fetch_baseline):
(RebaselineTest._rebaseline_test):
* Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
(TestRebaseline.stub_rebaseline_test_command_and_tool):
(TestRebaseline.stub_rebaseline_test_command_and_tool.FakeZipFileSet):
(TestRebaseline.stub_rebaseline_test_command_and_tool.FakeZipFileSet.read):
(TestRebaseline.test_rebaseline_updates_expectations_file_noop):
(test_rebaseline_updates_expectations_file):
(test_rebaseline_test):
(test_rebaseline_and_copy_test):
(test_rebaseline_and_copy_test_no_existing_result):
(test_rebaseline_and_copy_test_with_lion_result):
(test_rebaseline_and_copy_no_overwrite_test):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (115141 => 115142)


--- trunk/Tools/ChangeLog	2012-04-25 00:06:04 UTC (rev 115141)
+++ trunk/Tools/ChangeLog	2012-04-25 00:10:48 UTC (rev 115142)
@@ -1,3 +1,38 @@
+2012-04-24  Dirk Pranke  <[email protected]>
+
+        webkit-patch rebaseline-test is retrieving stale expectations
+        https://bugs.webkit.org/show_bug.cgi?id=84762
+
+        Reviewed by Ojan Vafai.
+
+        webkit-patch rebaseline-expectations is fetching files directly
+        from the layout-test-results directory on the buildbots, rather
+        than fetching them from the archive. This is problematic because
+        we don't clobber the directory after each run and so you can end
+        up fetching stale failing results.
+
+        This change temporarily changes the code to fetch the zip file
+        instead -- making things much slower -- until I can confer w/
+        abarth and ojan over the best way to fix this for the long-term.
+
+        * Scripts/webkitpy/tool/commands/rebaseline.py:
+        (RebaselineTest.__init__):
+        (RebaselineTest._zip_file_set):
+        (RebaselineTest):
+        (RebaselineTest._fetch_baseline):
+        (RebaselineTest._rebaseline_test):
+        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
+        (TestRebaseline.stub_rebaseline_test_command_and_tool):
+        (TestRebaseline.stub_rebaseline_test_command_and_tool.FakeZipFileSet):
+        (TestRebaseline.stub_rebaseline_test_command_and_tool.FakeZipFileSet.read):
+        (TestRebaseline.test_rebaseline_updates_expectations_file_noop):
+        (test_rebaseline_updates_expectations_file):
+        (test_rebaseline_test):
+        (test_rebaseline_and_copy_test):
+        (test_rebaseline_and_copy_test_no_existing_result):
+        (test_rebaseline_and_copy_test_with_lion_result):
+        (test_rebaseline_and_copy_no_overwrite_test):
+
 2012-04-24  Ojan Vafai  <[email protected]>
 
         Improve code for embedding flakiness dashboard as an iframe

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py (115141 => 115142)


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-04-25 00:06:04 UTC (rev 115141)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline.py	2012-04-25 00:10:48 UTC (rev 115142)
@@ -38,6 +38,7 @@
 from webkitpy.common.net.layouttestresults import LayoutTestResults
 from webkitpy.common.system.executive import ScriptError
 from webkitpy.common.system.user import User
+from webkitpy.common.system.zipfileset import ZipFileSet
 from webkitpy.layout_tests.controllers.test_result_writer import TestResultWriter
 from webkitpy.layout_tests.models import test_failures
 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
@@ -60,10 +61,13 @@
     help_text = "Rebaseline a single test from a buildbot.  (Currently works only with build.chromium.org buildbots.)"
     argument_names = "BUILDER_NAME TEST_NAME [PLATFORMS_TO_MOVE_EXISTING_BASELINES_TO]"
 
-    def _results_url(self, builder_name):
+    def __init__(self, options=None, **kwargs):
+        super(RebaselineTest, self).__init__(options, **kwargs)
+        self._zip_file_sets = {}
+
+    def _results_zip_url(self, builder_name):
         # FIXME: Generalize this command to work with non-build.chromium.org builders.
-        builder = self._tool.chromium_buildbot().builder_with_name(builder_name)
-        return builder.accumulated_results_url()
+        return self._tool.chromium_buildbot().builder_with_name(builder_name).accumulated_results_url().replace('results/layout-test-results', 'layout-test-results.zip')
 
     def _baseline_directory(self, builder_name):
         port = self._tool.port_factory.get_from_builder_name(builder_name)
@@ -129,18 +133,35 @@
     def _file_name_for_expected_result(self, test_name, suffix):
         return "%s-expected.%s" % (self._test_root(test_name), suffix)
 
+    def _zip_file_set(self, url):
+        return ZipFileSet(url)
+
+    def _fetch_baseline(self, builder_name, test_name, suffix):
+        # FIXME: See https://bugs.webkit.org/show_bug.cgi?id=84762 ... fetching the whole
+        # zip file and then extracting individual results is much slower than just fetching
+        # the result directly from the buildbot, but it guarantees that we are getting correct results.
+        member_name = self._file_name_for_actual_result(test_name, suffix)
+        zip_url = self._results_zip_url(builder_name)
+        if not builder_name in self._zip_file_sets:
+            print "Retrieving " + zip_url
+            self._zip_file_sets[builder_name] = self._zip_file_set(zip_url)
+
+        try:
+            data = "" + member_name)
+            print "  Found " + member_name
+            return data
+        except KeyError, e:
+            return None
+
     def _rebaseline_test(self, builder_name, test_name, platforms_to_move_existing_baselines_to, suffix):
-        results_url = self._results_url(builder_name)
         baseline_directory = self._baseline_directory(builder_name)
 
-        source_baseline = "%s/%s" % (results_url, self._file_name_for_actual_result(test_name, suffix))
         target_baseline = self._tool.filesystem.join(baseline_directory, self._file_name_for_expected_result(test_name, suffix))
 
         if platforms_to_move_existing_baselines_to:
             self._copy_existing_baseline(platforms_to_move_existing_baselines_to, test_name, suffix)
 
-        print "Retrieving %s." % source_baseline
-        self._save_baseline(self._tool.web.get_binary(source_baseline, convert_404_to_None=True), target_baseline)
+        self._save_baseline(self._fetch_baseline(builder_name, test_name, suffix), target_baseline)
 
     def _rebaseline_test_and_update_expectations(self, builder_name, test_name, platforms_to_move_existing_baselines_to):
         for suffix in _baseline_suffix_list:

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py (115141 => 115142)


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-04-25 00:06:04 UTC (rev 115141)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-04-25 00:10:48 UTC (rev 115142)
@@ -36,6 +36,20 @@
 
 
 class TestRebaseline(unittest.TestCase):
+    def stub_rebaseline_test_command_and_tool(self):
+
+        class FakeZipFileSet(object):
+            contents = {}
+
+            def read(self, member):
+                return self.contents[member]
+
+        command = RebaselineTest()
+        tool = MockTool()
+        command.bind_to_tool(tool)
+        command._zip_file_set = lambda url: FakeZipFileSet()
+        return (command, tool)
+
     def test_tests_to_update(self):
         command = Rebaseline()
         command.bind_to_tool(MockTool())
@@ -43,10 +57,7 @@
         OutputCapture().assert_outputs(self, command._tests_to_update, [build])
 
     def test_rebaseline_updates_expectations_file_noop(self):
-        command = RebaselineTest()
-        tool = MockTool()
-        command.bind_to_tool(tool)
-
+        command, tool = self.stub_rebaseline_test_command_and_tool()
         lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
         tool.filesystem.write_text_file(lion_port.path_to_test_expectations_file(), """BUGB MAC LINUX XP DEBUG : fast/dom/Window/window-postmessage-clone-really-deep-array.html = PASS
 BUGA DEBUG : fast/css/large-list-of-rules-crash.html = TEXT
@@ -55,10 +66,7 @@
         tool.filesystem.write_text_file(os.path.join(lion_port.layout_tests_dir(), "fast/css/large-list-of-rules-crash.html"), "Dummy test contents")
         tool.filesystem.write_text_file(os.path.join(lion_port.layout_tests_dir(), "userscripts/another-test.html"), "Dummy test contents")
 
-        expected_stdout = """Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.png.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.wav.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
-"""
+        expected_stdout = "Retrieving http://example.com/f/builders/Webkit Mac10.7/layout-test-results.zip\n"
         OutputCapture().assert_outputs(self, command._rebaseline_test_and_update_expectations, ["Webkit Mac10.7", "userscripts/another-test.html", None], expected_stdout=expected_stdout)
 
         new_expectations = tool.filesystem.read_text_file(lion_port.path_to_test_expectations_file())
@@ -67,70 +75,56 @@
 """)
 
     def test_rebaseline_updates_expectations_file(self):
-        command = RebaselineTest()
-        tool = MockTool()
-        command.bind_to_tool(tool)
+        command, tool = self.stub_rebaseline_test_command_and_tool()
 
         lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
         tool.filesystem.write_text_file(lion_port.path_to_test_expectations_file(), "BUGX MAC : userscripts/another-test.html = IMAGE\nBUGZ LINUX : userscripts/another-test.html = IMAGE\n")
         tool.filesystem.write_text_file(os.path.join(lion_port.layout_tests_dir(), "userscripts/another-test.html"), "Dummy test contents")
 
-        expected_stdout = """Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.png.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.wav.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
-"""
+        expected_stdout = "Retrieving http://example.com/f/builders/Webkit Mac10.7/layout-test-results.zip\n"
         OutputCapture().assert_outputs(self, command._rebaseline_test_and_update_expectations, ["Webkit Mac10.7", "userscripts/another-test.html", None], expected_stdout=expected_stdout)
 
         new_expectations = tool.filesystem.read_text_file(lion_port.path_to_test_expectations_file())
         self.assertEqual(new_expectations, "BUGX LEOPARD SNOWLEOPARD : userscripts/another-test.html = IMAGE\nBUGZ LINUX : userscripts/another-test.html = IMAGE\n")
 
     def test_rebaseline_test(self):
-        command = RebaselineTest()
-        command.bind_to_tool(MockTool())
-        expected_stdout = "Retrieving http://example.com/f/builders/Webkit Linux/results/layout-test-results/userscripts/another-test-actual.txt.\n"
+        command, _ = self.stub_rebaseline_test_command_and_tool()
+        expected_stdout = "Retrieving http://example.com/f/builders/Webkit Linux/layout-test-results.zip\n"
         OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Linux", "userscripts/another-test.html", None, "txt"], expected_stdout=expected_stdout)
 
     def test_rebaseline_and_copy_test(self):
-        command = RebaselineTest()
-        tool = MockTool()
-        command.bind_to_tool(tool)
+        command, tool = self.stub_rebaseline_test_command_and_tool()
 
         lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
         tool.filesystem.write_text_file(os.path.join(lion_port.layout_tests_dir(), "userscripts/another-test-expected.txt"), "Dummy expected result")
 
         expected_stdout = """Copying baseline from /mock-checkout/LayoutTests/userscripts/another-test-expected.txt to /mock-checkout/LayoutTests/platform/chromium-mac-snowleopard/userscripts/another-test-expected.txt.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/layout-test-results.zip
 """
         OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", ["chromium-mac-snowleopard"], "txt"], expected_stdout=expected_stdout)
 
     def test_rebaseline_and_copy_test_no_existing_result(self):
-        command = RebaselineTest()
-        tool = MockTool()
-        command.bind_to_tool(tool)
+        command, _ = self.stub_rebaseline_test_command_and_tool()
 
         expected_stdout = """No existing baseline for userscripts/another-test.html.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/layout-test-results.zip
 """
         OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", ["chromium-mac-snowleopard"], "txt"], expected_stdout=expected_stdout)
 
     def test_rebaseline_and_copy_test_with_lion_result(self):
-        command = RebaselineTest()
-        tool = MockTool()
-        command.bind_to_tool(tool)
+        command, tool = self.stub_rebaseline_test_command_and_tool()
 
         lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
         tool.filesystem.write_text_file(os.path.join(lion_port.baseline_path(), "userscripts/another-test-expected.txt"), "Dummy expected result")
 
         expected_stdout = """Copying baseline from /mock-checkout/LayoutTests/platform/chromium-mac/userscripts/another-test-expected.txt to /mock-checkout/LayoutTests/platform/chromium-mac-snowleopard/userscripts/another-test-expected.txt.
 Copying baseline from /mock-checkout/LayoutTests/platform/chromium-mac/userscripts/another-test-expected.txt to /mock-checkout/LayoutTests/platform/chromium-mac-leopard/userscripts/another-test-expected.txt.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/layout-test-results.zip
 """
         OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", ["chromium-mac-snowleopard", "chromium-mac-leopard"], "txt"], expected_stdout=expected_stdout)
 
     def test_rebaseline_and_copy_no_overwrite_test(self):
-        command = RebaselineTest()
-        tool = MockTool()
-        command.bind_to_tool(tool)
+        command, tool = self.stub_rebaseline_test_command_and_tool()
 
         lion_port = tool.port_factory.get_from_builder_name("Webkit Mac10.7")
         tool.filesystem.write_text_file(os.path.join(lion_port.baseline_path(), "userscripts/another-test-expected.txt"), "Dummy expected result")
@@ -139,7 +133,7 @@
         tool.filesystem.write_text_file(os.path.join(snowleopard_port.baseline_path(), "userscripts/another-test-expected.txt"), "Dummy expected result")
 
         expected_stdout = """Existing baseline at /mock-checkout/LayoutTests/platform/chromium-mac-snowleopard/userscripts/another-test-expected.txt, not copying over it.
-Retrieving http://example.com/f/builders/Webkit Mac10.7/results/layout-test-results/userscripts/another-test-actual.txt.
+Retrieving http://example.com/f/builders/Webkit Mac10.7/layout-test-results.zip
 """
         OutputCapture().assert_outputs(self, command._rebaseline_test, ["Webkit Mac10.7", "userscripts/another-test.html", ["chromium-mac-snowleopard"], "txt"], expected_stdout=expected_stdout)
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to