Title: [252815] trunk/Tools
Revision
252815
Author
[email protected]
Date
2019-11-22 16:15:01 -0800 (Fri, 22 Nov 2019)

Log Message

results.webkit.org/api/failures should return an error when no test-run is found for specified criteria
https://bugs.webkit.org/show_bug.cgi?id=204385
<rdar://problem/57334389>

Rubber-stamped by Aakash Jain.

* resultsdbpy/resultsdbpy/controller/failure_controller.py:
(FailureController.failures): Return a 404 error if no test runs are found.
* resultsdbpy/resultsdbpy/controller/failure_controller_unittest.py:
(FailureControllerTest):
(FailureControllerTest.test_no_runs):
* resultsdbpy/resultsdbpy/model/failure_context.py:
(FailureContext._failures): Return 'None' if no test runs are found.
* resultsdbpy/resultsdbpy/model/failure_context_unittest.py:
(FailureContextTest):
(FailureContextTest.test_no_test_runs):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (252814 => 252815)


--- trunk/Tools/ChangeLog	2019-11-23 00:14:49 UTC (rev 252814)
+++ trunk/Tools/ChangeLog	2019-11-23 00:15:01 UTC (rev 252815)
@@ -1,3 +1,22 @@
+2019-11-22  Jonathan Bedard  <[email protected]>
+
+        results.webkit.org/api/failures should return an error when no test-run is found for specified criteria
+        https://bugs.webkit.org/show_bug.cgi?id=204385
+        <rdar://problem/57334389>
+
+        Rubber-stamped by Aakash Jain.
+
+        * resultsdbpy/resultsdbpy/controller/failure_controller.py:
+        (FailureController.failures): Return a 404 error if no test runs are found.
+        * resultsdbpy/resultsdbpy/controller/failure_controller_unittest.py:
+        (FailureControllerTest):
+        (FailureControllerTest.test_no_runs):
+        * resultsdbpy/resultsdbpy/model/failure_context.py:
+        (FailureContext._failures): Return 'None' if no test runs are found.
+        * resultsdbpy/resultsdbpy/model/failure_context_unittest.py:
+        (FailureContextTest):
+        (FailureContextTest.test_no_test_runs):
+
 2019-11-22  Chris Dumez  <[email protected]>
 
         HTTPHeaderMap's operator== is not fully correct

Modified: trunk/Tools/resultsdbpy/resultsdbpy/controller/failure_controller.py (252814 => 252815)


--- trunk/Tools/resultsdbpy/resultsdbpy/controller/failure_controller.py	2019-11-23 00:14:49 UTC (rev 252814)
+++ trunk/Tools/resultsdbpy/resultsdbpy/controller/failure_controller.py	2019-11-23 00:15:01 UTC (rev 252815)
@@ -81,13 +81,15 @@
                 def sort_function(result):
                     return result['start_time']
 
+            failures = find_function(**query_dict)
+            if failures is None:
+                abort(404, description='No test runs found with the specified criteria')
+
             if collapsed:
-                response = set()
-                response.update(find_function(**query_dict))
-                return jsonify(sorted(response))
+                return jsonify(sorted(set(failures)))
 
             response = []
-            for config, results in find_function(**query_dict).items():
+            for config, results in failures.items():
                 response.append(dict(
                     configuration=Configuration.Encoder().default(config),
                     results=sorted(results, key=sort_function),

Modified: trunk/Tools/resultsdbpy/resultsdbpy/controller/failure_controller_unittest.py (252814 => 252815)


--- trunk/Tools/resultsdbpy/resultsdbpy/controller/failure_controller_unittest.py	2019-11-23 00:14:49 UTC (rev 252814)
+++ trunk/Tools/resultsdbpy/resultsdbpy/controller/failure_controller_unittest.py	2019-11-23 00:15:01 UTC (rev 252815)
@@ -99,7 +99,6 @@
         response = client.get(f'{self.URL}/api/failures/layout-tests?platform=iOS&style=Debug&recent=False&after_time={time.time() - 60 * 60}&collapsed=False')
         self.assertEqual(response.status_code, 200)
         self.assertEqual(len(response.json()), 2)
-        print(response.json())
         for i in range(2):
             self.assertEqual(len(response.json()[i]['results']), 5)
             last_start_time = 0
@@ -106,3 +105,14 @@
             for result in response.json()[i]['results']:
                 self.assertGreaterEqual(result['start_time'], last_start_time)
                 last_start_time = result['start_time']
+
+    @WaitForDockerTestCase.mock_if_no_docker(mock_redis=FakeStrictRedis, mock_cassandra=MockCassandraContext)
+    @FlaskTestCase.run_with_webserver()
+    def test_no_runs(self, client, **kwargs):
+        response = client.get(f'{self.URL}/api/failures/layout-tests?platform=iOS&style=Debug&recent=False&before_uuid=0')
+        self.assertEqual(response.status_code, 404)
+        self.assertEqual(response.json(), dict(
+            status='error',
+            error='Not Found',
+            description='No test runs found with the specified criteria',
+        ))

Modified: trunk/Tools/resultsdbpy/resultsdbpy/model/failure_context.py (252814 => 252815)


--- trunk/Tools/resultsdbpy/resultsdbpy/model/failure_context.py	2019-11-23 00:14:49 UTC (rev 252814)
+++ trunk/Tools/resultsdbpy/resultsdbpy/model/failure_context.py	2019-11-23 00:15:01 UTC (rev 252815)
@@ -164,6 +164,7 @@
             return None
 
         with self:
+            has_test_runs = False
             if collapsed:
                 result = set()
             else:
@@ -180,6 +181,7 @@
                 ).items():
                     if collapsed:
                         for value in values:
+                            has_test_runs = True
                             for test in value.unpack():
                                 if test not in ['uuid', 'start_time']:
                                     result.add(test)
@@ -186,6 +188,8 @@
                     else:
                         runs = []
                         for value in values:
+                            has_test_runs = True
+
                             # uuid and start_time are not in the unpacked values
                             unpacked = value.unpack()
                             if len(unpacked) > 2:
@@ -193,7 +197,7 @@
                         if runs:
                             result.update({config: runs})
 
-            return result
+            return result if has_test_runs else None
 
     def failures_by_commit(self, *args, **kwargs):
         return self._failures(self.TestFailuresByCommit, self.UnexpectedTestFailuresByCommit, *args, **kwargs)

Modified: trunk/Tools/resultsdbpy/resultsdbpy/model/failure_context_unittest.py (252814 => 252815)


--- trunk/Tools/resultsdbpy/resultsdbpy/model/failure_context_unittest.py	2019-11-23 00:14:49 UTC (rev 252814)
+++ trunk/Tools/resultsdbpy/resultsdbpy/model/failure_context_unittest.py	2019-11-23 00:15:01 UTC (rev 252815)
@@ -121,3 +121,12 @@
             suite='layout-tests', recent=True, collapsed=False, unexpected=False,
         )
         self.assertEqual(len(results), 0)
+
+    @WaitForDockerTestCase.mock_if_no_docker(mock_redis=FakeStrictRedis, mock_cassandra=MockCassandraContext)
+    def test_no_test_runs(self, redis=StrictRedis, cassandra=CassandraContext):
+        self.init_database(redis=redis, cassandra=cassandra)
+        results = self.model.failure_context.failures_by_commit(
+            configurations=[Configuration(platform='Mac', style='Release', flavor='wk1')],
+            suite='layout-tests', recent=True, end=0,
+        )
+        self.assertEqual(results, None)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to