2011-01-06 Julie Parent <jparent@chromium.org>
authorjparent@chromium.org <jparent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jan 2011 18:42:44 +0000 (18:42 +0000)
committerjparent@chromium.org <jparent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Jan 2011 18:42:44 +0000 (18:42 +0000)
        Reviewed by Tony Chang.

        Test Result Server always truncates number of results to JSON_RESULTS_MAX_BUILDS
        https://bugs.webkit.org/show_bug.cgi?id=51217

        * TestResultServer/model/jsonresults.py:
        Pass num_runs through to _remove_items_over_max_number_of_builds, and use the value.
        Adds missing documentation.
        * TestResultServer/model/jsonresults_unittest.py:
        Add unit test to test that truncation happens at smaller value than JSON_RESULTS_MAX_BUILDS.
        Update test_merge to take a number of builds to truncate at.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@75166 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestResultServer/model/jsonresults.py
Tools/TestResultServer/model/jsonresults_unittest.py

index 2f66a23..9ec4148 100644 (file)
@@ -1,3 +1,17 @@
+2011-01-06  Julie Parent  <jparent@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        Test Result Server always truncates number of results to JSON_RESULTS_MAX_BUILDS
+        https://bugs.webkit.org/show_bug.cgi?id=51217
+
+        * TestResultServer/model/jsonresults.py:
+        Pass num_runs through to _remove_items_over_max_number_of_builds, and use the value.
+        Adds missing documentation.
+        * TestResultServer/model/jsonresults_unittest.py:
+        Add unit test to test that truncation happens at smaller value than JSON_RESULTS_MAX_BUILDS.
+        Update test_merge to take a number of builds to truncate at.
+
 2011-01-06  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Eric Seidel.
index f5a0fde..8e507a2 100755 (executable)
@@ -114,6 +114,7 @@ class JsonResults(object):
         Args:
             aggregated_json: aggregated json object.
             incremental_json: incremental json object.
+            num_runs: number of total runs to include.
 
         Returns:
             True if merge succeeds or
@@ -140,6 +141,7 @@ class JsonResults(object):
         Args:
             aggregated_json: aggregated json object.
             incremental_json: incremental json object.
+            num_runs: number of total runs to include.
 
         Returns:
             True if merge succeeds or
@@ -188,6 +190,7 @@ class JsonResults(object):
             aggregated_json: aggregated json object.
             incremental_json: incremental json object.
             incremental_index: index of the incremental json results to merge.
+            num_runs: number of total runs to include.
         """
 
         for key in incremental_json.keys():
@@ -211,6 +214,7 @@ class JsonResults(object):
         Args:
             aggregated_json: aggregated json object.
             incremental_json: incremental json object.
+            num_runs: number of total runs to include.
         """
 
         all_tests = (set(aggregated_json.iterkeys()) |
@@ -230,7 +234,7 @@ class JsonResults(object):
                     results, aggregated_test[JSON_RESULTS_RESULTS], num_runs)
                 cls._insert_item_run_length_encoded(
                     times, aggregated_test[JSON_RESULTS_TIMES], num_runs)
-                cls._normalize_results_json(test_name, aggregated_json)
+                cls._normalize_results_json(test_name, aggregated_json, num_runs)
             else:
                 aggregated_json[test_name] = incremental_json[test_name]
 
@@ -242,6 +246,7 @@ class JsonResults(object):
         Args:
             incremental_item: incremental run-length encoded results.
             aggregated_item: aggregated run-length encoded results.
+            num_runs: number of total runs to include.
         """
 
         for item in incremental_item:
@@ -252,23 +257,24 @@ class JsonResults(object):
                 aggregated_item.insert(0, item)
 
     @classmethod
-    def _normalize_results_json(cls, test_name, aggregated_json):
+    def _normalize_results_json(cls, test_name, aggregated_json, num_runs):
         """ Prune tests where all runs pass or tests that no longer exist and
-        truncate all results to JSON_RESULTS_MAX_BUILDS.
+        truncate all results to num_runs.
 
         Args:
           test_name: Name of the test.
           aggregated_json: The JSON object with all the test results for
                            this builder.
+          num_runs: number of total runs to include.
         """
 
         aggregated_test = aggregated_json[test_name]
         aggregated_test[JSON_RESULTS_RESULTS] = \
             cls._remove_items_over_max_number_of_builds(
-                aggregated_test[JSON_RESULTS_RESULTS])
+                aggregated_test[JSON_RESULTS_RESULTS], num_runs)
         aggregated_test[JSON_RESULTS_TIMES] = \
             cls._remove_items_over_max_number_of_builds(
-                aggregated_test[JSON_RESULTS_TIMES])
+                aggregated_test[JSON_RESULTS_TIMES], num_runs)
 
         is_all_pass = cls._is_results_all_of_type(
             aggregated_test[JSON_RESULTS_RESULTS], JSON_RESULTS_PASS)
@@ -285,20 +291,21 @@ class JsonResults(object):
             del aggregated_json[test_name]
 
     @classmethod
-    def _remove_items_over_max_number_of_builds(cls, encoded_list):
+    def _remove_items_over_max_number_of_builds(cls, encoded_list, num_runs):
         """Removes items from the run-length encoded list after the final
         item that exceeds the max number of builds to track.
 
         Args:
           encoded_results: run-length encoded results. An array of arrays, e.g.
               [[3,'A'],[1,'Q']] encodes AAAQ.
+          num_runs: number of total runs to include.
         """
         num_builds = 0
         index = 0
         for result in encoded_list:
             num_builds = num_builds + result[0]
             index = index + 1
-            if num_builds > JSON_RESULTS_MAX_BUILDS:
+            if num_builds > num_runs:
                 return encoded_list[:index]
 
         return encoded_list
index c70b90c..03f1b46 100755 (executable)
@@ -118,11 +118,11 @@ class JsonResultsTest(unittest.TestCase):
 
         return JSON_RESULTS_PREFIX + json + JSON_RESULTS_SUFFIX
 
-    def _test_merge(self, aggregated_data, incremental_data, expected_data):
+    def _test_merge(self, aggregated_data, incremental_data, expected_data, max_builds=jsonresults.JSON_RESULTS_MAX_BUILDS):
         aggregated_results = self._make_test_json(aggregated_data)
         incremental_results = self._make_test_json(incremental_data)
         merged_results = JsonResults.merge(self._builder,
-            aggregated_results, incremental_results, jsonresults.JSON_RESULTS_MAX_BUILDS,
+            aggregated_results, incremental_results, max_builds,
             sort_keys=True)
 
         if expected_data:
@@ -299,7 +299,7 @@ class JsonResultsTest(unittest.TestCase):
             # Expected results
             (["3", "2", "1"], [["001.html", "[201,\"P\"]", "[1,1],[200,0]"], ["002.html", "[1,\"P\"],[10,\"F\"]", "[11,0]"]]))
 
-        # Remove items from test results and times that exceeds the max number
+        # Remove items from test results and times that exceed the max number
         # of builds to track.
         max_builds = str(jsonresults.JSON_RESULTS_MAX_BUILDS)
         self._test_merge(
@@ -310,6 +310,18 @@ class JsonResultsTest(unittest.TestCase):
             # Expected results
             (["3", "2", "1"], [["001.html", "[1,\"T\"],[" + max_builds + ",\"F\"]", "[1,1],[" + max_builds + ",0]"]]))
 
+        # Remove items from test results and times that exceed the max number
+        # of builds to track, using smaller threshold.
+        max_builds = str(jsonresults.JSON_RESULTS_MAX_BUILDS_SMALL)
+        self._test_merge(
+            # Aggregated results
+            (["2", "1"], [["001.html", "[" + max_builds + ",\"F\"],[1,\"I\"]", "[" + max_builds + ",0],[1,1]"]]),
+            # Incremental results
+            (["3"], [["001.html", "[1,\"T\"]", "[1,1]"]]),
+            # Expected results
+            (["3", "2", "1"], [["001.html", "[1,\"T\"],[" + max_builds + ",\"F\"]", "[1,1],[" + max_builds + ",0]"]]),
+            int(max_builds))
+
         # Get test name list only. Don't include non-test-list data and
         # of test result details.
         self._test_get_test_list(