Bug 1415247 - Warn if Firefox is running before mochitest starts Firefox. r=jmaher, a=test-only
authorGeoff Brown <gbrown@mozilla.com>
Mon, 13 Nov 2017 13:12:02 -0700
changeset 444770 c8042c122490e90495e8c37993406f0c63eb6735
parent 444769 a144f70802556b43c56fb9f967b5a2ee7f5feec5
child 444771 1d4a6dc2023c7332de374aade71742917b40d726
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher, test-only
bugs1415247
milestone58.0
Bug 1415247 - Warn if Firefox is running before mochitest starts Firefox. r=jmaher, a=test-only When running mochitests in automation, we expect no more than 1 instance of Firefox to be running at any time: the browser under test. In local testing scenarios, additional browser instances might be running. Warn when mochitests find additional 'firefox' instances running before launching a browser for testing, to make it easier to detect anomalies in automation.
testing/mochitest/runtests.py
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -2022,16 +2022,34 @@ toolbar#nav-bar {
                 self.killAndGetStack(
                     processPID,
                     utilityPath,
                     debuggerInfo,
                     dump_screen=not debuggerInfo)
 
         return foundZombie
 
+    def checkForRunningBrowsers(self):
+        firefoxes = ""
+        if HAVE_PSUTIL:
+            attrs = ['pid', 'ppid', 'name', 'cmdline', 'username']
+            for proc in psutil.process_iter():
+                try:
+                    if 'firefox' in proc.name():
+                        firefoxes = "%s%s\n" % (firefoxes, proc.as_dict(attrs=attrs))
+                except:
+                    # may not be able to access process info for all processes
+                    continue
+        if len(firefoxes) > 0:
+            # In automation, this warning is unexpected and should be investigated.
+            # In local testing, this is probably okay, as long as the browser is not
+            # running a marionette server.
+            self.log.warning("Found 'firefox' running before starting test browser!")
+            self.log.warning(firefoxes)
+
     def runApp(self,
                testUrl,
                env,
                app,
                profile,
                extraArgs,
                utilityPath,
                debuggerInfo=None,
@@ -2144,16 +2162,18 @@ toolbar#nav-bar {
                     debuggerInfo,
                     browserProcessId,
                     processLog)
             kp_kwargs = {'kill_on_timeout': False,
                          'cwd': SCRIPT_DIR,
                          'onTimeout': [timeoutHandler]}
             kp_kwargs['processOutputLine'] = [outputHandler]
 
+            self.checkForRunningBrowsers()
+
             # create mozrunner instance and start the system under test process
             self.lastTestSeen = self.test_name
             startTime = datetime.now()
 
             runner_cls = mozrunner.runners.get(
                 mozinfo.info.get(
                     'appname',
                     'firefox'),