Bug 1300163 - Move the Android 'stop-emulator' step to a PostScriptAction of 'run-tests', r=gbrown
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 02 Sep 2016 14:22:23 -0400
changeset 354136 f72acbecdf93c31585d35ac4bb10f96b017479f7
parent 354135 5ee0ea599ba3a80cc14da0dc80a235d767c8e7c3
child 354137 1b40346919cc81301f39ba13f75633f508aee717
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1300163
milestone51.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 1300163 - Move the Android 'stop-emulator' step to a PostScriptAction of 'run-tests', r=gbrown Currently 'stop-emulator' is its own action in mozharness. This means that anytime the mozharness script finishes emulators will get shutdown. Usually, this is what we want to do. But if the user passes in --no-run-tests, then presumably they are intending to run tests at a later time for some reason. But when they do this, the emulator will be terminated, and then running tests later no longer works. The main place where this becomes a problem is on interactive loaners in taskcluster. This patch fixes the problem by instead running 'stop-emulator' only after the 'run-tests' step finishes. So if --no-run-tests is passed in, the emulator will be left open. MozReview-Commit-ID: 4lsKGpizfH7
testing/mozharness/configs/android/androidarm.py
testing/mozharness/configs/android/androidarm_4_3.py
testing/mozharness/configs/android/androidx86-tc.py
testing/mozharness/scripts/android_emulator_unittest.py
testing/mozharness/scripts/androidx86_emulator_unittest.py
--- a/testing/mozharness/configs/android/androidarm.py
+++ b/testing/mozharness/configs/android/androidarm.py
@@ -38,17 +38,16 @@ config = {
         'read-buildbot-config',
         'setup-avds',
         'start-emulator',
         'download-and-extract',
         'create-virtualenv',
         'verify-emulator',
         'install',
         'run-tests',
-        'stop-emulator',
     ],
     "emulator": {
             "name": "test-1",
             "device_id": "emulator-5554",
             "http_port": "8854", # starting http port to use for the mochitest server
             "ssl_port": "4454", # starting ssl port to use for the server
             "emulator_port": 5554,
             "sut_port1": 20701,
--- a/testing/mozharness/configs/android/androidarm_4_3.py
+++ b/testing/mozharness/configs/android/androidarm_4_3.py
@@ -48,17 +48,16 @@ config = {
         'read-buildbot-config',
         'setup-avds',
         'start-emulator',
         'download-and-extract',
         'create-virtualenv',
         'verify-emulator',
         'install',
         'run-tests',
-        'stop-emulator',
     ],
     "emulator": {
         "name": "test-1",
         "device_id": "emulator-5554",
         "http_port": "8854",  # starting http port to use for the mochitest server
         "ssl_port": "4454",  # starting ssl port to use for the server
         "emulator_port": 5554,
     },
--- a/testing/mozharness/configs/android/androidx86-tc.py
+++ b/testing/mozharness/configs/android/androidx86-tc.py
@@ -33,17 +33,16 @@ config = {
         'clobber',
         'read-buildbot-config',
         'setup-avds',
         'start-emulator',
         'download-and-extract',
         'create-virtualenv',
         'verify-emulator',
         'run-tests',
-        'stop-emulator',
     ],
     "emulator": {
         "name": "test-1",
         "device_id": "emulator-5554",
         "http_port": "8854",  # starting http port to use for the mochitest server
         "ssl_port": "4454",  # starting ssl port to use for the server
         "emulator_port": 5554,
     },
--- a/testing/mozharness/scripts/android_emulator_unittest.py
+++ b/testing/mozharness/scripts/android_emulator_unittest.py
@@ -19,17 +19,17 @@ import time
 import tempfile
 
 # load modules from parent dir
 sys.path.insert(1, os.path.dirname(sys.path[0]))
 
 from mozprocess import ProcessHandler
 
 from mozharness.base.log import FATAL
-from mozharness.base.script import BaseScript, PreScriptAction
+from mozharness.base.script import BaseScript, PreScriptAction, PostScriptAction
 from mozharness.base.vcs.vcsbase import VCSMixin
 from mozharness.mozilla.blob_upload import BlobUploadMixin, blobupload_config_options
 from mozharness.mozilla.mozbase import MozbaseMixin
 from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
 from mozharness.mozilla.testing.unittest import EmulatorMixin
 
 
 class AndroidEmulatorTest(BlobUploadMixin, TestingMixin, EmulatorMixin, VCSMixin, BaseScript, MozbaseMixin):
@@ -80,25 +80,25 @@ class AndroidEmulatorTest(BlobUploadMixi
                          'read-buildbot-config',
                          'setup-avds',
                          'start-emulator',
                          'download-and-extract',
                          'create-virtualenv',
                          'verify-emulator',
                          'install',
                          'run-tests',
-                         'stop-emulator'],
+                        ],
             default_actions=['clobber',
                              'start-emulator',
                              'download-and-extract',
                              'create-virtualenv',
                              'verify-emulator',
                              'install',
                              'run-tests',
-                             'stop-emulator'],
+                            ],
             require_config_file=require_config_file,
             config={
                 'virtualenv_modules': self.virtualenv_modules,
                 'virtualenv_requirements': self.virtualenv_requirements,
                 'require_test_zip': True,
                 # IP address of the host as seen from the emulator
                 'remote_webserver': '10.0.2.2',
             }
@@ -719,27 +719,32 @@ class AndroidEmulatorTest(BlobUploadMixi
         self.run_command(cmd, cwd=cwd, env=env, output_parser=parser)
         tbpl_status, log_level = parser.evaluate_parser(0)
         parser.append_tinderboxprint_line(self.test_suite)
 
         self.info("##### %s log ends" % self.test_suite)
         self._dump_emulator_log()
         self.buildbot_status(tbpl_status, level=log_level)
 
-    def stop_emulator(self):
+    @PostScriptAction('run-tests')
+    def stop_emulator(self, action, success=None):
         '''
         Report emulator health, then make sure that the emulator has been stopped
         '''
         self._verify_emulator()
         self._kill_processes(self.config["emulator_process_name"])
 
     def upload_blobber_files(self):
         '''
         Override BlobUploadMixin.upload_blobber_files to ensure emulator is killed
         first (if the emulator is still running, logcat may still be running, which
         may lock the blob upload directory, causing a hang).
         '''
-        self._kill_processes(self.config["emulator_process_name"])
+        if self.config.get('blob_upload_branch'):
+            # Except on interactive workers, we want the emulator to keep running
+            # after the script is finished. So only kill it if blobber would otherwise
+            # have run anyway (it doesn't get run on interactive workers).
+            self._kill_processes(self.config["emulator_process_name"])
         super(AndroidEmulatorTest, self).upload_blobber_files()
 
 if __name__ == '__main__':
     emulatorTest = AndroidEmulatorTest()
     emulatorTest.run_and_exit()
--- a/testing/mozharness/scripts/androidx86_emulator_unittest.py
+++ b/testing/mozharness/scripts/androidx86_emulator_unittest.py
@@ -17,17 +17,17 @@ import time
 import tempfile
 
 # load modules from parent dir
 sys.path.insert(1, os.path.dirname(sys.path[0]))
 
 from mozprocess import ProcessHandler
 
 from mozharness.base.log import FATAL
-from mozharness.base.script import BaseScript, PostScriptRun, PreScriptAction
+from mozharness.base.script import BaseScript, PostScriptRun, PreScriptAction, PostScriptAction
 from mozharness.base.vcs.vcsbase import VCSMixin
 from mozharness.mozilla.blob_upload import BlobUploadMixin, blobupload_config_options
 from mozharness.mozilla.mozbase import MozbaseMixin
 from mozharness.mozilla.buildbot import TBPL_WORST_LEVEL_TUPLE
 from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
 from mozharness.mozilla.testing.unittest import EmulatorMixin
 
 
@@ -71,24 +71,24 @@ class AndroidEmulatorTest(BlobUploadMixi
             all_actions=['clobber',
                          'read-buildbot-config',
                          'setup-avds',
                          'start-emulators',
                          'download-and-extract',
                          'create-virtualenv',
                          'install',
                          'run-tests',
-                         'stop-emulators'],
+                        ],
             default_actions=['clobber',
                              'start-emulators',
                              'download-and-extract',
                              'create-virtualenv',
                              'install',
                              'run-tests',
-                             'stop-emulators'],
+                            ],
             require_config_file=require_config_file,
             config={
                 'virtualenv_modules': self.virtualenv_modules,
                 'virtualenv_requirements': self.virtualenv_requirements,
                 'require_test_zip': True,
                 # IP address of the host as seen from the emulator
                 'remote_webserver': '10.0.2.2',
             }
@@ -817,17 +817,18 @@ class AndroidEmulatorTest(BlobUploadMixi
                 # so buildbot won't kill the process due to lack of output
                 if int(time.time()) - start_time > 5 * 60:
                     self.info('#')
                     start_time = int(time.time())
                 time.sleep(30)
 
         self.buildbot_status(joint_tbpl_status, level=joint_log_level)
 
-    def stop_emulators(self):
+    @PostScriptAction('run-tests')
+    def stop_emulators(self, action, success=None):
         '''
         Report emulator health, then make sure that every emulator has been stopped
         '''
         emulator_index = 0
         for test in self.test_suites:
             emulator = self.emulators[emulator_index]
             emulator_index += 1
             self._check_emulator(emulator)