Bug 1410723 - Improve diagnostics when Android devicemanager getDirectory fails. r=bc, a=test-only
authorGeoff Brown <gbrown@mozilla.com>
Thu, 30 Nov 2017 22:00:11 -0700
changeset 445275 888df756364281a9565e5aad3d1b373c33abeafa
parent 445274 d4fe05793ea607307bdb2a4c1e90da09cc096648
child 445276 c7a07000546af757f53499ce80f16d49a600114b
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)
reviewersbc, test-only
bugs1410723
milestone58.0
Bug 1410723 - Improve diagnostics when Android devicemanager getDirectory fails. r=bc, a=test-only Also re-works _runCmd for improved error handling.
testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -533,20 +533,26 @@ class DeviceManagerADB(DeviceManager):
             localName = os.path.basename(localDir)
             remoteName = os.path.basename(remoteDir)
             if localName != remoteName:
                 copyRequired = True
                 tempParent = tempfile.mkdtemp()
                 localDir = os.path.join(tempParent, remoteName)
             else:
                 localDir = '/'.join(localDir.rstrip('/').split('/')[:-1])
-        self._runCmd(["pull", remoteDir, localDir]).wait()
+        cmd = ["pull", remoteDir, localDir]
+        proc = self._runCmd(cmd)
         if copyRequired:
-            dir_util.copy_tree(localDir, originalLocal)
-            mozfile.remove(tempParent)
+            try:
+                dir_util.copy_tree(localDir, originalLocal)
+                mozfile.remove(tempParent)
+            except:
+                self._logger.error("getDirectory() failed after %s" % str(cmd))
+                self._logger.error("rc=%d out=%s" % (proc.returncode, str(proc.output)))
+                raise
 
     def validateFile(self, remoteFile, localFile):
         md5Remote = self._getRemoteHash(remoteFile)
         md5Local = self._getLocalHash(localFile)
         if md5Remote is None or md5Local is None:
             return None
         return md5Remote == md5Local
 
@@ -673,26 +679,30 @@ class DeviceManagerADB(DeviceManager):
         self._logger.debug("_runCmd - command: %s" % ' '.join(finalArgs))
         if not timeout:
             timeout = self.default_timeout
 
         def _timeout():
             self._logger.error("Timeout exceeded for _runCmd call '%s'" % ' '.join(finalArgs))
 
         retries = 0
+        proc = None
         while retries < retryLimit:
             proc = ProcessHandler(finalArgs, storeOutput=True,
                                   processOutputLine=self._log, onTimeout=_timeout)
             proc.run(timeout=timeout)
             proc.returncode = proc.wait()
-            if proc.returncode is None:
-                proc.kill()
-                retries += 1
-            else:
-                return proc
+            if proc.returncode is not None:
+                break
+            proc.kill()
+            self._logger.warning("_runCmd failed for '%s'" % ' '.join(finalArgs))
+            retries += 1
+        if retries >= retryLimit:
+            self._logger.warning("_runCmd exceeded all retries")
+        return proc
 
     # timeout is specified in seconds, and if no timeout is given,
     # we will run until we hit the default_timeout specified in the __init__
     def _checkCmd(self, args, timeout=None, retryLimit=None):
         """
         Runs a command using adb and waits for the command to finish.
         If timeout is specified, the process is killed after <timeout> seconds.