Bug 1563053 - Poll Android PGO based on process existence, not file existence; r=snorp

After execute_script() returns, the Android process may not be fully
shutdown, so the profile data may not exist yet. The initial
implementation waited for this by checking if the profraw file existed
and was non-zero length, but this may be contributing to issues with
getting partial profraw files.

Instead we can wait for the whole process to exit by using
process_exist(), so the profraw file should be completely written out
by then. In the event that the profraw file is truncated for some
reason, the merge step will fail and the process will be retried (per
bug 1560755).

Differential Revision: https://phabricator.services.mozilla.com/D36839

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Shal 2019-07-08 20:53:25 +00:00
parent 5cd4d8a68e
commit d77d483c53

View File

@ -148,7 +148,7 @@ class AndroidProfileRun(TestingMixin, BaseScript, MozbaseMixin,
"""
from mozhttpd import MozHttpd
from mozprofile import Preferences
from mozdevice import ADBDevice, ADBProcessError, ADBTimeoutError
from mozdevice import ADBDevice, ADBTimeoutError
from six import string_types
from marionette_driver.marionette import Marionette
@ -256,22 +256,14 @@ class AndroidProfileRun(TestingMixin, BaseScript, MozbaseMixin,
# There is a delay between execute_script() returning and the profile data
# actually getting written out, so poll the device until we get a profile.
for i in range(50):
try:
localprof = '/builds/worker/workspace/default.profraw'
adbdevice.pull(profdata, localprof)
stats = os.stat(localprof)
if stats.st_size == 0:
# The file may not have been fully written yet, so retry until we
# get actual data.
time.sleep(2)
else:
break
except ADBProcessError:
# The file may not exist at all yet, which would raise an
# ADBProcessError, so retry.
time.sleep(2)
if not adbdevice.process_exist(app):
break
time.sleep(2)
else:
raise Exception("Unable to pull default.profraw")
raise Exception("Android App (%s) never quit" % app)
localprof = '/builds/worker/workspace/default.profraw'
adbdevice.pull(profdata, localprof)
adbdevice.pull(jarlog, '/builds/worker/workspace/en-US.log')
except ADBTimeoutError:
self.fatal('INFRA-ERROR: Failed with an ADBTimeoutError',