Bug 1298771 - Attach last-update.log to update results for Firefox UI update tests r=maja_zf a=testonly
authorHenrik Skupin <mail@hskupin.info>
Mon, 29 Aug 2016 17:55:42 +0200
changeset 347979 97d651e84739f5fadf1c39604ce3235122549176
parent 347978 7278fe6aa69fc1025ed799c3ffb427e01a89b665
child 347980 5779143fc12d6a751fedb0b8049d52f4bd10dad9
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf, testonly
Bug 1298771 - Attach last-update.log to update results for Firefox UI update tests r=maja_zf a=testonly MozReview-Commit-ID: DtNwBbPuHPy
--- a/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
+++ b/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
@@ -1,12 +1,13 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import os
 import pprint
 from datetime import datetime
 import mozfile
 from marionette import MarionetteTestCase
 from marionette_driver import Wait
@@ -109,20 +110,22 @@ class UpdateTestCase(FirefoxTestCase):
         # Check if the user has permissions to run the update
                         'Current user has permissions to update the application.')
     def tearDown(self):
+            # Add content of the update log file for detailed failures when applying an update
+            self.updates[self.current_update_index]['update_log'] = self.read_update_log()
             # Print results for now until we have treeherder integration
             output = pprint.pformat(self.updates)
             self.logger.info('Update test results: \n{}'.format(output))
             super(UpdateTestCase, self).tearDown()
             # Ensure that no trace of an partially downloaded update remain
@@ -367,21 +370,35 @@ class UpdateTestCase(FirefoxTestCase):
                 self.updates[self.current_update_index]['patch'] = self.patch_info
         # Restart Firefox to apply the update
+    def read_update_log(self):
+        """Read the content of the update log file for the last update attempt."""
+        path = os.path.join(os.path.dirname(self.software_update.staging_directory),
+                            'last-update.log')
+        try:
+            with open(path, 'rb') as f:
+                return f.read().splitlines()
+        except IOError as exc:
+            self.logger.warning(str(exc))
+            return None
     def remove_downloaded_update(self):
-        """Remove an already downloaded update from the update staging directory."""
-        self.logger.info('Clean-up update staging directory: {}'.format(
-            self.software_update.staging_directory))
-        mozfile.remove(self.software_update.staging_directory)
+        """Remove an already downloaded update from the update staging directory.
+        Hereby not only remove the update subdir but everything below 'updates'.
+        """
+        path = os.path.dirname(self.software_update.staging_directory)
+        self.logger.info('Clean-up update staging directory: {}'.format(path))
+        mozfile.remove(path)
     def restore_config_files(self):
         # Reset channel-prefs.js file if modified
             if self.default_update_channel:
                 path = self.default_update_channel['path']
                 self.logger.info('Restoring channel defaults for: {}'.format(path))
                 with open(path, 'w') as f: