Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Restore use of the API 34 device in the Firebase Test Lab script and handle FTL infrastructure errors in the script #50735

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 43 additions & 23 deletions ci/firebase_testlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
sys.exit(1)
PROJECT = os.environ['GCP_PROJECT']

# Exit codes returned by the FTL command that signal an infrastructure failure.
FTL_INFRA_FAILURE_CODES = [1, 15, 20]

# Maximum number of retries done if an infrastructure failure occurs.
MAX_RETRY_ATTEMPTS = 2

script_dir = os.path.dirname(os.path.realpath(__file__))
buildroot_dir = os.path.abspath(os.path.join(script_dir, '..', '..'))
out_dir = os.path.join(buildroot_dir, 'out')
Expand Down Expand Up @@ -54,7 +60,7 @@ def run_firebase_test(apk, results_dir):
'--results-dir',
results_dir,
'--device',
'model=panther,version=33',
'model=shiba,version=34',
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand Down Expand Up @@ -106,7 +112,7 @@ def main():
args = parser.parse_args()

apks_dir = os.path.join(out_dir, args.variant, 'firebase_apks')
apks = glob.glob('%s/*.apk' % apks_dir)
apks = set(glob.glob('%s/*.apk' % apks_dir))

if not apks:
print('No APKs found at %s' % apks_dir)
Expand All @@ -115,27 +121,41 @@ def main():
git_revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=script_dir)
git_revision = byte_str_decode(git_revision)
git_revision = git_revision.strip()
results = []
apk = None
for apk in apks:
results_dir = '%s/%s/%s' % (os.path.basename(apk), git_revision, args.build_id)
process = run_firebase_test(apk, results_dir)
results.append((results_dir, process))

for results_dir, process in results:
for line in iter(process.stdout.readline, ''):
print(line.strip())
return_code = process.wait()
if return_code != 0:
print('Firebase test failed with code: %s' % return_code)
sys.exit(return_code)

print('Checking logcat for %s' % results_dir)
check_logcat(results_dir)
# scenario_app produces a timeline, but the android image test does not.
if 'scenario' in apk:
print('Checking timeline for %s' % results_dir)
check_timeline(results_dir)

for retry in range(MAX_RETRY_ATTEMPTS):
if retry > 0:
print('Retrying %s' % apks)

results = []
for apk in sorted(apks):
results_dir = '%s/%s/%s' % (os.path.basename(apk), git_revision, args.build_id)
process = run_firebase_test(apk, results_dir)
results.append((apk, results_dir, process))

for apk, results_dir, process in results:
print('===== Test output for %s' % apk)
for line in iter(process.stdout.readline, ''):
print(line.strip())

return_code = process.wait()
if return_code in FTL_INFRA_FAILURE_CODES:
print('Firebase test %s failed with infrastructure error code: %s' % (apk, return_code))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition

continue
if return_code != 0:
print('Firebase test %s failed with code: %s' % (apk, return_code))
sys.exit(return_code)

print('Checking logcat for %s' % results_dir)
check_logcat(results_dir)
# scenario_app produces a timeline, but the android image test does not.
if 'scenario' in apk:
print('Checking timeline for %s' % results_dir)
check_timeline(results_dir)

apks.remove(apk)

if not apks:
break

return 0

Expand Down