Bug 1415858 - Adding logs for Talos cloning step r?jmaher draft
authorTarek Ziadé <tarek@mozilla.com>
Wed, 15 Nov 2017 10:37:39 +0100
changeset 698326 a9d145f364444c513502fbb13a84111f8a05a130
parent 697453 e1d7427787f7a26983c92ea1a1ac99eb863edd6c
child 740338 e6e9e440c5b91fbc7cd6742ff3d254b1375ad2a7
push id89247
push usertziade@mozilla.com
push dateWed, 15 Nov 2017 14:00:50 +0000
reviewersjmaher
bugs1415858
milestone59.0a1
Bug 1415858 - Adding logs for Talos cloning step r?jmaher MozReview-Commit-ID: GVXcCty2nNi
testing/mozbase/mozprofile/mozprofile/profile.py
testing/mozbase/mozprofile/tests/test_clone_cleanup.py
testing/talos/talos/ffsetup.py
--- a/testing/mozbase/mozprofile/mozprofile/profile.py
+++ b/testing/mozbase/mozprofile/mozprofile/profile.py
@@ -179,26 +179,27 @@ class Profile(object):
             if not os.path.exists(os.path.join(self.profile, filename)):
                 # file has been deleted
                 break
             while True:
                 if not self.pop_preferences(filename):
                     break
 
     @classmethod
-    def clone(cls, path_from, path_to=None, **kwargs):
+    def clone(cls, path_from, path_to=None, ignore=None, **kwargs):
         """Instantiate a temporary profile via cloning
         - path: path of the basis to clone
+        - ignore: callable passed to shutil.copytree
         - kwargs: arguments to the profile constructor
         """
         if not path_to:
             tempdir = tempfile.mkdtemp()  # need an unused temp dir name
             mozfile.remove(tempdir)  # copytree requires that dest does not exist
             path_to = tempdir
-        copytree(path_from, path_to)
+        copytree(path_from, path_to, ignore=ignore)
 
         c = cls(path_to, **kwargs)
         c.create_new = True  # deletes a cloned profile when restore is True
         return c
 
     def exists(self):
         """returns whether the profile exists or not"""
         return os.path.exists(self.profile)
--- a/testing/mozbase/mozprofile/tests/test_clone_cleanup.py
+++ b/testing/mozbase/mozprofile/tests/test_clone_cleanup.py
@@ -29,24 +29,38 @@ class CloneCleanupTest(unittest.TestCase
         self.addCleanup(mozfile.remove, path)
         self.profile = Profile(path,
                                preferences={'foo': 'bar'},
                                restore=False)
         user_js = os.path.join(self.profile.profile, 'user.js')
         self.assertTrue(os.path.exists(user_js))
 
     def test_restore_true(self):
+        counter = [0]
+
+        def _feedback(dir, content):
+            # Called by shutil.copytree on each visited directory.
+            # Used here to display info.
+            #
+            # Returns the items that should be ignored by
+            # shutil.copytree when copying the tree, so always returns
+            # an empty list.
+            counter[0] += 1
+            return []
+
         # make a clone of this profile with restore=True
-        clone = Profile.clone(self.profile.profile, restore=True)
+        clone = Profile.clone(self.profile.profile, restore=True,
+                              ignore=_feedback)
         self.addCleanup(mozfile.remove, clone.profile)
 
         clone.cleanup()
 
         # clone should be deleted
         self.assertFalse(os.path.exists(clone.profile))
+        self.assertTrue(counter[0] > 0)
 
     def test_restore_false(self):
         # make a clone of this profile with restore=False
         clone = Profile.clone(self.profile.profile, restore=False)
         self.addCleanup(mozfile.remove, clone.profile)
 
         clone.cleanup()
 
--- a/testing/talos/talos/ffsetup.py
+++ b/testing/talos/talos/ffsetup.py
@@ -93,32 +93,49 @@ class FFSetup(object):
         if self.test_config.get('extensions'):
             extensions.append(self.test_config['extensions'])
 
         # downloading a profile instead of using the empty one
         if self.test_config['profile'] is not None:
             path = heavy.download_profile(self.test_config['profile'])
             self.test_config['profile_path'] = path
 
-        profile = Profile.clone(
-            os.path.normpath(self.test_config['profile_path']),
-            self.profile_dir,
-            restore=False)
+        profile_path = os.path.normpath(self.test_config['profile_path'])
+        LOG.info("Cloning profile located at %s" % profile_path)
+
+        def _feedback(directory, content):
+            # Called by shutil.copytree on each visited directory.
+            # Used here to display info.
+            #
+            # Returns the items that should be ignored by
+            # shutil.copytree when copying the tree, so always returns
+            # an empty list.
+            sub = directory.split(profile_path)[-1].lstrip("/")
+            if sub:
+                LOG.info("=> %s" % sub)
+            return []
+
+        profile = Profile.clone(profile_path,
+                                self.profile_dir,
+                                ignore=_feedback,
+                                restore=False)
 
         profile.set_preferences(preferences)
 
         # installing addons
+        LOG.info("Installing Add-ons")
         profile.addon_manager.install_addons(extensions)
 
         # installing webextensions
         webextensions = self.test_config.get('webextensions', None)
         if isinstance(webextensions, basestring):
             webextensions = [webextensions]
 
         if webextensions is not None:
+            LOG.info("Installing Webextensions")
             for webext in webextensions:
                 filename = utils.interpolate(webext)
                 if mozinfo.os == 'win':
                     filename = filename.replace('/', '\\')
                 if not filename.endswith('.xpi'):
                     continue
                 if not os.path.exists(filename):
                     continue