Bug 1460399 - Refactor emulator installation in android_emulator_unittest.py; r=me,a=test-only
authorGeoff Brown <gbrown@mozilla.com>
Wed, 09 May 2018 13:34:06 -0600
changeset 417673 ceb28bf3abf646231cec6174a932150a2f507955
parent 417672 5c5c9cc183a0a4cd14a4a16aab4ec228adbffb16
child 417674 04f2d2c4efe6591215dd687e2a34937dbef3be4b
push id33977
push userncsoregi@mozilla.com
push dateThu, 10 May 2018 16:43:24 +0000
treeherdermozilla-central@17db33b6a124 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme, test-only
bugs1460399
milestone62.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 1460399 - Refactor emulator installation in android_emulator_unittest.py; r=me,a=test-only Remove EmulatorMixin, folding it in to android_emulator_unittest. Simplify installation options based on current needs.
testing/mozharness/mozharness/mozilla/testing/unittest.py
testing/mozharness/scripts/android_emulator_unittest.py
--- a/testing/mozharness/mozharness/mozilla/testing/unittest.py
+++ b/testing/mozharness/mozharness/mozilla/testing/unittest.py
@@ -257,54 +257,8 @@ class DesktopUnittestOutputParser(Output
         # it is only here for tbpl highlighted summaries and is not part of
         # buildbot evaluation or result status IIUC.
         summary = tbox_print_summary(self.pass_count,
                                      self.fail_count,
                                      self.known_fail_count,
                                      self.crashed,
                                      self.leaked)
         self.info("TinderboxPrint: %s<br/>%s\n" % (suite_name, summary))
-
-
-class EmulatorMixin(object):
-    """ Currently dependent on both TooltoolMixin and TestingMixin)"""
-
-    def install_emulator_from_tooltool(self, manifest_path, do_unzip=True):
-        dirs = self.query_abs_dirs()
-        if self.tooltool_fetch(manifest_path, output_dir=dirs['abs_work_dir'],
-                               cache=self.config.get("tooltool_cache", None)
-                               ):
-            self.fatal("Unable to download emulator via tooltool!")
-        if do_unzip:
-            unzip = self.query_exe("unzip")
-            unzip_cmd = [unzip, '-q', os.path.join(dirs['abs_work_dir'], "emulator.zip")]
-            self.run_command(unzip_cmd, cwd=dirs['abs_emulator_dir'], halt_on_failure=True,
-                             fatal_exit_code=3)
-
-    def install_emulator(self):
-        dirs = self.query_abs_dirs()
-        self.mkdir_p(dirs['abs_emulator_dir'])
-        if self.config.get('emulator_url'):
-            self.download_unpack(self.config['emulator_url'], dirs['abs_emulator_dir'])
-        elif self.config.get('emulator_manifest'):
-            manifest_path = self.create_tooltool_manifest(self.config['emulator_manifest'])
-            do_unzip = True
-            if 'unpack' in self.config['emulator_manifest']:
-                do_unzip = False
-            self.install_emulator_from_tooltool(manifest_path, do_unzip)
-        elif self.buildbot_config:
-            props = self.buildbot_config.get('properties')
-            url = 'https://hg.mozilla.org/%s/raw-file/%s/b2g/test/emulator.manifest' % (
-                props['repo_path'], props['revision'])
-            manifest_path = self.download_file(url,
-                                               file_name='tooltool.tt',
-                                               parent_dir=dirs['abs_work_dir'])
-            if not manifest_path:
-                self.fatal("Can't download emulator manifest from %s" % url)
-            self.install_emulator_from_tooltool(manifest_path)
-        else:
-            self.fatal("Can't get emulator; set emulator_url or emulator_manifest in the config!")
-        if self.config.get('tools_manifest'):
-            manifest_path = self.create_tooltool_manifest(self.config['tools_manifest'])
-            do_unzip = True
-            if 'unpack' in self.config['tools_manifest']:
-                do_unzip = False
-            self.install_emulator_from_tooltool(manifest_path, do_unzip)
--- a/testing/mozharness/scripts/android_emulator_unittest.py
+++ b/testing/mozharness/scripts/android_emulator_unittest.py
@@ -21,22 +21,20 @@ sys.path.insert(1, os.path.dirname(sys.p
 
 from mozprocess import ProcessHandler
 
 from mozharness.base.log import FATAL
 from mozharness.base.script import BaseScript, PreScriptAction, PostScriptAction
 from mozharness.mozilla.buildbot import TBPL_RETRY, EXIT_STATUS_DICT
 from mozharness.mozilla.mozbase import MozbaseMixin
 from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
-from mozharness.mozilla.testing.unittest import EmulatorMixin
 from mozharness.mozilla.testing.codecoverage import CodeCoverageMixin
 
 
-class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin,
-                          CodeCoverageMixin):
+class AndroidEmulatorTest(TestingMixin, BaseScript, MozbaseMixin, CodeCoverageMixin):
     config_options = [[
         ["--test-suite"],
         {"action": "store",
          "dest": "test_suite",
          "default": None
          }
     ], [
         ["--total-chunk"],
@@ -121,17 +119,16 @@ class AndroidEmulatorTest(TestingMixin, 
         dirs['abs_test_bin_dir'] = os.path.join(
             abs_dirs['abs_work_dir'], 'tests', 'bin')
         dirs['abs_xre_dir'] = os.path.join(
             abs_dirs['abs_work_dir'], 'hostutils')
         dirs['abs_modules_dir'] = os.path.join(
             dirs['abs_test_install_dir'], 'modules')
         dirs['abs_blob_upload_dir'] = os.path.join(
             abs_dirs['abs_work_dir'], 'blobber_upload_dir')
-        dirs['abs_emulator_dir'] = abs_dirs['abs_work_dir']
         dirs['abs_mochitest_dir'] = os.path.join(
             dirs['abs_test_install_dir'], 'mochitest')
         dirs['abs_reftest_dir'] = os.path.join(
             dirs['abs_test_install_dir'], 'reftest')
         dirs['abs_xpcshell_dir'] = os.path.join(
             dirs['abs_test_install_dir'], 'xpcshell')
         dirs['abs_marionette_dir'] = os.path.join(
             dirs['abs_test_install_dir'], 'marionette', 'harness', 'marionette_harness')
@@ -501,31 +498,43 @@ class AndroidEmulatorTest(TestingMixin, 
                          'using mozilla-central/default')
         url = '%s/raw-file/%s/%s' % (
             repo,
             revision,
             path)
         return url
 
     def _tooltool_fetch(self, url, dir):
-        c = self.config
-
         manifest_path = self.download_file(
             url,
             file_name='releng.manifest',
             parent_dir=dir
         )
-
         if not os.path.exists(manifest_path):
             self.fatal("Could not retrieve manifest needed to retrieve "
                        "artifacts from %s" % manifest_path)
+        cache = self.config.get("tooltool_cache", None)
+        if self.tooltool_fetch(manifest_path, output_dir=dir, cache=cache):
+            self.warning("Unable to download from tooltool: %s" % url)
 
-        self.tooltool_fetch(manifest_path,
-                            output_dir=dir,
-                            cache=c.get("tooltool_cache", None))
+    def _install_emulator(self):
+        dirs = self.query_abs_dirs()
+        self.mkdir_p(dirs['abs_work_dir'])
+        if self.config.get('emulator_url'):
+            self.download_unpack(self.config['emulator_url'], dirs['abs_work_dir'])
+        elif self.config.get('emulator_manifest'):
+            manifest_path = self.create_tooltool_manifest(self.config['emulator_manifest'])
+            dirs = self.query_abs_dirs()
+            cache = self.config.get("tooltool_cache", None)
+            if self.tooltool_fetch(manifest_path,
+                                   output_dir=dirs['abs_work_dir'],
+                                   cache=cache):
+                self.fatal("Unable to download emulator via tooltool!")
+        else:
+            self.warning("Cannot get emulator: configure emulator_url or emulator_manifest")
 
     ##########################################
     # Actions for AndroidEmulatorTest        #
     ##########################################
     def setup_avds(self):
         '''
         If tooltool cache mechanism is enabled, the cached version is used by
         the fetch command. If the manifest includes an "unpack" field, tooltool
@@ -558,19 +567,18 @@ class AndroidEmulatorTest(TestingMixin, 
             proc = ProcessHandler(cmd)
             proc.run()
             proc.wait()
 
     def start_emulator(self):
         '''
         Starts the emulator
         '''
-        if 'emulator_url' in self.config or 'emulator_manifest' in self.config or \
-           'tools_manifest' in self.config:
-            self.install_emulator()
+        if 'emulator_url' in self.config or 'emulator_manifest' in self.config:
+            self._install_emulator()
 
         if not os.path.isfile(self.adb_path):
             self.fatal("The adb binary '%s' is not a valid file!" % self.adb_path)
         self._restart_adbd()
 
         if not self.config.get("developer_mode"):
             self._kill_processes("xpcshell")