Flutter Engine
The Flutter Engine
Functions | Variables
firebase_testlab Namespace Reference

Functions

def run_firebase_test (apk, results_dir)
 
def check_logcat (results_dir)
 
def check_timeline (results_dir)
 
def main ()
 

Variables

 BUCKET = os.environ['STORAGE_BUCKET']
 
 PROJECT = os.environ['GCP_PROJECT']
 
list FTL_INFRA_FAILURE_CODES = [1, 15, 20]
 
int 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')
 
 error_re = re.compile(r'[EF]/flutter.+')
 

Function Documentation

◆ check_logcat()

def firebase_testlab.check_logcat (   results_dir)

Definition at line 72 of file firebase_testlab.py.

72def check_logcat(results_dir):
73 logcat = subprocess.check_output(['gsutil', 'cat', '%s/%s/*/logcat' % (BUCKET, results_dir)])
74 logcat = byte_str_decode(logcat)
75 if not logcat:
76 sys.exit(1)
77
78 logcat_matches = error_re.findall(logcat)
79 if logcat_matches:
80 print('Errors in logcat:')
81 print(logcat_matches)
82 sys.exit(1)
83
84
def byte_str_decode(str_or_bytes)
def check_logcat(results_dir)
def print(*args, **kwargs)
Definition: run_tests.py:49

◆ check_timeline()

def firebase_testlab.check_timeline (   results_dir)

Definition at line 85 of file firebase_testlab.py.

85def check_timeline(results_dir):
86 gsutil_du = subprocess.check_output([
87 'gsutil', 'du',
88 '%s/%s/*/game_loop_results/results_scenario_0.json' % (BUCKET, results_dir)
89 ])
90 gsutil_du = byte_str_decode(gsutil_du)
91 gsutil_du = gsutil_du.strip()
92 if gsutil_du == '0':
93 print('Failed to produce a timeline.')
94 sys.exit(1)
95
96
def check_timeline(results_dir)

◆ main()

def firebase_testlab.main ( )

Definition at line 97 of file firebase_testlab.py.

97def main():
98 parser = argparse.ArgumentParser()
99 parser.add_argument(
100 '--variant',
101 dest='variant',
102 action='store',
103 default='android_profile_arm64',
104 help='The engine variant to run tests for.'
105 )
106 parser.add_argument(
107 '--build-id',
108 default=os.environ.get('SWARMING_TASK_ID', 'local_test'),
109 help='A unique build identifier for this test. Used to sort results in the GCS bucket.'
110 )
111
112 args = parser.parse_args()
113
114 apks_dir = os.path.join(out_dir, args.variant, 'firebase_apks')
115 apks = set(glob.glob('%s/*.apk' % apks_dir))
116
117 if not apks:
118 print('No APKs found at %s' % apks_dir)
119 return 1
120
121 git_revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=script_dir)
122 git_revision = byte_str_decode(git_revision)
123 git_revision = git_revision.strip()
124
125 for retry in range(MAX_RETRY_ATTEMPTS):
126 if retry > 0:
127 print('Retrying %s' % apks)
128
129 results = []
130 for apk in sorted(apks):
131 results_dir = '%s/%s/%s' % (os.path.basename(apk), git_revision, args.build_id)
132 process = run_firebase_test(apk, results_dir)
133 results.append((apk, results_dir, process))
134
135 for apk, results_dir, process in results:
136 print('===== Test output for %s' % apk)
137 for line in iter(process.stdout.readline, ''):
138 print(line.strip())
139
140 return_code = process.wait()
141 if return_code in FTL_INFRA_FAILURE_CODES:
142 print('Firebase test %s failed with infrastructure error code: %s' % (apk, return_code))
143 continue
144 if return_code != 0:
145 print('Firebase test %s failed with code: %s' % (apk, return_code))
146 sys.exit(return_code)
147
148 print('Checking logcat for %s' % results_dir)
149 check_logcat(results_dir)
150 # scenario_app produces a timeline, but the android image test does not.
151 if 'scenario' in apk:
152 print('Checking timeline for %s' % results_dir)
153 check_timeline(results_dir)
154
155 apks.remove(apk)
156
157 if not apks:
158 break
159
160 return 0
161
162
def run_firebase_test(apk, results_dir)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76

◆ run_firebase_test()

def firebase_testlab.run_firebase_test (   apk,
  results_dir 
)

Definition at line 37 of file firebase_testlab.py.

37def run_firebase_test(apk, results_dir):
38 # game-loop tests are meant for OpenGL apps.
39 # This type of test will give the application a handle to a file, and
40 # we'll write the timeline JSON to that file.
41 # See https://firebase.google.com/docs/test-lab/android/game-loop
42 # Pixel 5. As of this commit, this is a highly available device in FTL.
43 process = subprocess.Popen(
44 [
45 'gcloud',
46 '--project',
47 PROJECT,
48 'firebase',
49 'test',
50 'android',
51 'run',
52 '--type',
53 'game-loop',
54 '--app',
55 apk,
56 '--timeout',
57 '2m',
58 '--results-bucket',
59 BUCKET,
60 '--results-dir',
61 results_dir,
62 '--device',
63 'model=shiba,version=34',
64 ],
65 stdout=subprocess.PIPE,
66 stderr=subprocess.STDOUT,
67 universal_newlines=True,
68 )
69 return process
70
71

Variable Documentation

◆ BUCKET

firebase_testlab.BUCKET = os.environ['STORAGE_BUCKET']

Definition at line 18 of file firebase_testlab.py.

◆ buildroot_dir

firebase_testlab.buildroot_dir = os.path.abspath(os.path.join(script_dir, '..', '..'))

Definition at line 32 of file firebase_testlab.py.

◆ error_re

firebase_testlab.error_re = re.compile(r'[EF]/flutter.+')

Definition at line 34 of file firebase_testlab.py.

◆ FTL_INFRA_FAILURE_CODES

list firebase_testlab.FTL_INFRA_FAILURE_CODES = [1, 15, 20]

Definition at line 26 of file firebase_testlab.py.

◆ MAX_RETRY_ATTEMPTS

int firebase_testlab.MAX_RETRY_ATTEMPTS = 2

Definition at line 29 of file firebase_testlab.py.

◆ out_dir

firebase_testlab.out_dir = os.path.join(buildroot_dir, 'out')

Definition at line 33 of file firebase_testlab.py.

◆ PROJECT

firebase_testlab.PROJECT = os.environ['GCP_PROJECT']

Definition at line 23 of file firebase_testlab.py.

◆ script_dir

firebase_testlab.script_dir = os.path.dirname(os.path.realpath(__file__))

Definition at line 31 of file firebase_testlab.py.