Bug 1233679 - UpdateTestcase should remove any partially downloaded update. r=maja_zf
authorHenrik Skupin <mail@hskupin.info>
Tue, 24 May 2016 12:14:59 +0200
changeset 337774 f37493706dd7f176aef13f699e82901fdc1b635d
parent 337773 011e172a9ddffa9419b3282309ee170355c4f09a
child 337775 a73b559073f5dce3cccc56cb5ff48f27f2b4d41b
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1233679 - UpdateTestcase should remove any partially downloaded update. r=maja_zf MozReview-Commit-ID: FpKDcElYF7L
--- a/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
+++ b/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
@@ -1,15 +1,17 @@
 # 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 pprint
 from datetime import datetime
+import mozfile
 from marionette import MarionetteTestCase
 from marionette_driver import Wait
 from firefox_puppeteer.api.prefs import Preferences
 from firefox_puppeteer.api.software_update import SoftwareUpdate
 from firefox_puppeteer.testcases import BaseFirefoxTestCase
 from firefox_puppeteer.ui.update_wizard import UpdateWizardDialog
@@ -52,17 +54,18 @@ class UpdateTestCase(FirefoxTestCase):
         super(UpdateTestCase, self).setUp()
         self.software_update = SoftwareUpdate(lambda: self.marionette)
         self.download_duration = None
         # Bug 604364 - Preparation to test multiple update steps
         self.current_update_index = 0
-        self.staging_directory = self.software_update.staging_directory
+        # Ensure that there exists no already partially downloaded update
+        self.remove_downloaded_update()
         # If requested modify the default update channel. It will be active
         # after the next restart of the application
         # Bug 1142805 - Modify file via Python directly
         if self.update_channel:
             # Backup the original content and the path of the channel-prefs.js file
             self.default_update_channel = {
                 'content': self.software_update.update_channel.file_contents,
@@ -113,16 +116,19 @@ class UpdateTestCase(FirefoxTestCase):
             # 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
+            self.remove_downloaded_update()
     def patch_info(self):
         """ Returns information about the active update in the queue.
         :returns: A dictionary with information about the active patch
@@ -357,16 +363,22 @@ class UpdateTestCase(FirefoxTestCase):
                 self.updates[self.current_update_index]['patch'] = self.patch_info
         # Restart Firefox to apply the update
+    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)
     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: