Bug 1520592 - Enable screen captures on pageload timeouts; r=davehunt
authorRob Wood <rwood@mozilla.com>
Fri, 08 Feb 2019 21:33:35 +0000
changeset 458513 c5073e671318e41e99cead73210c0b4d9e887253
parent 458512 68526e6afbd2dda02486b7e4893a80c8bf14b33c
child 458514 68e3ee13edd9b8c8fa36c3a77491950f485cbadf
push id111855
push userbtara@mozilla.com
push dateMon, 11 Feb 2019 22:01:49 +0000
treeherdermozilla-inbound@42a097167d36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavehunt
bugs1520592
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520592 - Enable screen captures on pageload timeouts; r=davehunt Differential Revision: https://phabricator.services.mozilla.com/D18878
testing/raptor/raptor/output.py
testing/raptor/webext/raptor/runner.js
--- a/testing/raptor/raptor/output.py
+++ b/testing/raptor/raptor/output.py
@@ -601,43 +601,47 @@ class Output(object):
                         screenshot['screenshot'],
                         screenshot['test_name'],
                         screenshot['page_cycle']))
 
         self.summarized_screenshots.append("""</table></body> </html>""")
 
     def output(self, test_names):
         """output to file and perfherder data json """
-        if self.summarized_results == {}:
-            LOG.error("error: no summarized raptor results found for %s" %
-                      ', '.join(test_names))
-            return False
-
         if os.environ['MOZ_UPLOAD_DIR']:
             # i.e. testing/mozharness/build/raptor.json locally; in production it will
             # be at /tasks/task_*/build/ (where it will be picked up by mozharness later
             # and made into a tc artifact accessible in treeherder as perfherder-data.json)
             results_path = os.path.join(os.path.dirname(os.environ['MOZ_UPLOAD_DIR']),
                                         'raptor.json')
             screenshot_path = os.path.join(os.path.dirname(os.environ['MOZ_UPLOAD_DIR']),
                                            'screenshots.html')
         else:
             results_path = os.path.join(os.getcwd(), 'raptor.json')
             screenshot_path = os.path.join(os.getcwd(), 'screenshots.html')
 
-        with open(results_path, 'w') as f:
-            for result in self.summarized_results:
-                f.write("%s\n" % result)
+        if self.summarized_results == {}:
+            LOG.error("error: no summarized raptor results found for %s" %
+                      ', '.join(test_names))
+        else:
+            with open(results_path, 'w') as f:
+                for result in self.summarized_results:
+                    f.write("%s\n" % result)
 
         if len(self.summarized_screenshots) > 0:
             with open(screenshot_path, 'w') as f:
                 for result in self.summarized_screenshots:
                     f.write("%s\n" % result)
             LOG.info("screen captures can be found locally at: %s" % screenshot_path)
 
+        # now that we've checked for screen captures too, if there were no actual
+        # test results we can bail out here
+        if self.summarized_results == {}:
+            return False
+
         # when gecko_profiling, we don't want results ingested by Perfherder
         extra_opts = self.summarized_results['suites'][0].get('extraOptions', [])
         if 'gecko_profile' not in extra_opts:
             # if we have supporting data i.e. power, we ONLY want those measurements
             # dumped out. TODO: Bug 1515406 - Add option to output both supplementary
             # data (i.e. power) and the regular Raptor test result
             # Both are already available as separate PERFHERDER_DATA json blobs
             if len(self.summarized_supporting_data) == 0:
--- a/testing/raptor/webext/raptor/runner.js
+++ b/testing/raptor/webext/raptor/runner.js
@@ -391,19 +391,23 @@ async function nextCycle() {
         ext.tabs.update(testTabID, {url: testURL}, testTabUpdated);
         }, newTabDelay);
       }, pageCycleDelay);
     } else {
       verifyResults();
     }
 }
 
-function timeoutAlarmListener() {
+async function timeoutAlarmListener() {
   console.error("raptor-page-timeout on %s" % testURL);
   postToControlServer("raptor-page-timeout", [testName, testURL]);
+  // take a screen capture
+  if (screenCapture) {
+    await getScreenCapture();
+  }
   // call clean-up to shutdown gracefully
   cleanUp();
 }
 
 function setTimeoutAlarm(timeoutName, timeoutMS) {
   // webext alarms require date.now NOT performance.now
   var now = Date.now(); // eslint-disable-line mozilla/avoid-Date-timing
   var timeout_when = now + timeoutMS;