Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: scripts/slave/recipe_modules/chromium_android/api.py

Issue 2140713002: [Android] Reland splitting of device recovery and device status. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: rebase and retrain Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/example.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import contextlib 5 import contextlib
6 import datetime 6 import datetime
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import sys 10 import sys
(...skipping 14 matching lines...) Expand all
25 25
26 def get_config_defaults(self): 26 def get_config_defaults(self):
27 return { 27 return {
28 'REVISION': self.m.properties.get('revision', ''), 28 'REVISION': self.m.properties.get('revision', ''),
29 'CHECKOUT_PATH': self.m.path['checkout'], 29 'CHECKOUT_PATH': self.m.path['checkout'],
30 } 30 }
31 31
32 @property 32 @property
33 def devices(self): 33 def devices(self):
34 assert self._devices is not None,\ 34 assert self._devices is not None,\
35 'devices is only available after device_status_check()' 35 'devices is only available after device_status()'
36 return self._devices 36 return self._devices
37 37
38 @property 38 @property
39 def out_path(self): 39 def out_path(self):
40 return self.m.path['checkout'].join('out') 40 return self.m.path['checkout'].join('out')
41 41
42 @property 42 @property
43 def coverage_dir(self): 43 def coverage_dir(self):
44 return self.out_path.join(self.c.BUILD_CONFIG, 'coverage') 44 return self.out_path.join(self.c.BUILD_CONFIG, 'coverage')
45 45
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 args = ['--verbose', '--adb-path', self.m.adb.adb_path()] 322 args = ['--verbose', '--adb-path', self.m.adb.adb_path()]
323 return self.m.python('authorize_adb_devices', script, args, infra_step=True, 323 return self.m.python('authorize_adb_devices', script, args, infra_step=True,
324 env=self.m.chromium.get_env()) 324 env=self.m.chromium.get_env())
325 325
326 def detect_and_setup_devices(self, restart_usb=False, skip_wipe=False, 326 def detect_and_setup_devices(self, restart_usb=False, skip_wipe=False,
327 disable_location=False, min_battery_level=None, 327 disable_location=False, min_battery_level=None,
328 disable_network=False, disable_java_debug=False, 328 disable_network=False, disable_java_debug=False,
329 reboot_timeout=None, max_battery_temp=None, 329 reboot_timeout=None, max_battery_temp=None,
330 remove_system_webview=False): 330 remove_system_webview=False):
331 self.authorize_adb_devices() 331 self.authorize_adb_devices()
332 self.device_status_check(restart_usb=restart_usb) 332 self.device_recovery()
333 self.provision_devices( 333 self.provision_devices(
334 skip_wipe=skip_wipe, disable_location=disable_location, 334 skip_wipe=skip_wipe, disable_location=disable_location,
335 min_battery_level=min_battery_level, disable_network=disable_network, 335 min_battery_level=min_battery_level, disable_network=disable_network,
336 disable_java_debug=disable_java_debug, reboot_timeout=reboot_timeout, 336 disable_java_debug=disable_java_debug, reboot_timeout=reboot_timeout,
337 max_battery_temp=max_battery_temp, 337 max_battery_temp=max_battery_temp,
338 remove_system_webview=remove_system_webview) 338 remove_system_webview=remove_system_webview)
339 self.device_status()
339 340
340 @property 341 @property
341 def blacklist_file(self): 342 def blacklist_file(self):
342 return self.out_path.join('bad_devices.json') 343 return self.out_path.join('bad_devices.json')
343 344
344 345
345 def revert_device_file_format(self): 346 def revert_device_file_format(self):
346 # If current device file is jsonified, revert it back to original format. 347 # If current device file is jsonified, revert it back to original format.
347 if self.m.path.exists(self.known_devices_file): 348 if self.m.path.exists(self.known_devices_file):
348 with self.m.step.nest('fix_device_file_format'): 349 with self.m.step.nest('fix_device_file_format'):
(...skipping 10 matching lines...) Expand all
359 except ValueError: 360 except ValueError:
360 # File wasn't json, so no need to revert. 361 # File wasn't json, so no need to revert.
361 self.m.step.active_result.presentation.step_text += ( 362 self.m.step.active_result.presentation.step_text += (
362 'file format is compatible') 363 'file format is compatible')
363 364
364 def device_status_check(self, restart_usb=False, **kwargs): 365 def device_status_check(self, restart_usb=False, **kwargs):
365 # TODO(bpastene): Remove once chromium revisions prior to 366 # TODO(bpastene): Remove once chromium revisions prior to
366 # crrev.com/1faecde0c03013b6cd725da413339c60223f8948 are no longer tested. 367 # crrev.com/1faecde0c03013b6cd725da413339c60223f8948 are no longer tested.
367 # See crbug.com/619707 for context. 368 # See crbug.com/619707 for context.
368 self.revert_device_file_format() 369 self.revert_device_file_format()
370 self.device_recovery()
371 self.device_status()
369 372
370 # TODO(phajdan.jr): Remove path['build'] usage, http://crbug.com/437264 . 373 def device_recovery(self, restart_usb=False, **kwargs):
371 args = [ 374 args = [
375 '--blacklist-file', self.blacklist_file,
376 '--known-devices-file', self.known_devices_file,
372 '--adb-path', self.m.adb.adb_path(), 377 '--adb-path', self.m.adb.adb_path(),
378 '-v'
379 ]
380 self.m.step(
381 'device_recovery',
382 [self.m.path['checkout'].join('third_party', 'catapult', 'devil',
383 'devil', 'android', 'tools',
384 'device_recovery.py')] + args,
385 env=self.m.chromium.get_env(),
386 infra_step=True,
387 **kwargs)
388
389 def device_status(self, **kwargs):
390 buildbot_file = '/home/chrome-bot/.adb_device_info'
391 args = [
392 '--json-output', self.m.json.output(),
373 '--blacklist-file', self.blacklist_file, 393 '--blacklist-file', self.blacklist_file,
374 '--json-output', self.m.json.output(), 394 '--known-devices-file', self.known_devices_file,
375 '--known-devices-file', self.known_devices_file 395 '--buildbot-path', buildbot_file,
396 '--adb-path', self.m.adb.adb_path(),
397 '-v', '--overwrite-known-devices-files',
376 ] 398 ]
377 if restart_usb:
378 args += ['--restart-usb']
379
380 try: 399 try:
381 result = self.m.step( 400 result = self.m.step(
382 'device_status_check', 401 'device_status',
383 [self.m.path['checkout'].join('build', 'android', 'buildbot', 402 [self.m.path['checkout'].join('third_party', 'catapult', 'devil',
384 'bb_device_status_check.py')] + args, 403 'devil', 'android', 'tools',
404 'device_status.py')] + args,
385 step_test_data=lambda: self.m.json.test_api.output([ 405 step_test_data=lambda: self.m.json.test_api.output([
386 { 406 {
387 "battery": { 407 "battery": {
388 "status": "5", 408 "status": "5",
389 "scale": "100", 409 "scale": "100",
390 "temperature": "249", 410 "temperature": "249",
391 "level": "100", 411 "level": "100",
392 "AC powered": "false", 412 "AC powered": "false",
393 "health": "2", 413 "health": "2",
394 "voltage": "4286", 414 "voltage": "4286",
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 self.m.properties['buildername']), 478 self.m.properties['buildername']),
459 'labels': 'Restrict-View-Google,OS-Android,Infra,Infra-Labs', 479 'labels': 'Restrict-View-Google,OS-Android,Infra,Infra-Labs',
460 } 480 }
461 link = ('https://code.google.com/p/chromium/issues/entry?%s' % 481 link = ('https://code.google.com/p/chromium/issues/entry?%s' %
462 urllib.urlencode(params)) 482 urllib.urlencode(params))
463 f.result.presentation.links.update({ 483 f.result.presentation.links.update({
464 'report a bug': link 484 'report a bug': link
465 }) 485 })
466 raise 486 raise
467 487
488
468 def provision_devices(self, skip_wipe=False, disable_location=False, 489 def provision_devices(self, skip_wipe=False, disable_location=False,
469 min_battery_level=None, disable_network=False, 490 min_battery_level=None, disable_network=False,
470 disable_java_debug=False, max_battery_temp=None, 491 disable_java_debug=False, max_battery_temp=None,
471 disable_system_chrome=False, reboot_timeout=None, 492 disable_system_chrome=False, reboot_timeout=None,
472 remove_system_webview=False, emulators=False, 493 remove_system_webview=False, emulators=False,
473 **kwargs): 494 **kwargs):
474 args = [ 495 args = [
475 '--adb-path', self.m.adb.adb_path(), 496 '--adb-path', self.m.adb.adb_path(),
476 '--blacklist-file', self.blacklist_file, 497 '--blacklist-file', self.blacklist_file,
477 '--output-device-blacklist', self.m.json.output(add_json_log=False), 498 '--output-device-blacklist', self.m.json.output(add_json_log=False),
(...skipping 30 matching lines...) Expand all
508 if emulators: 529 if emulators:
509 args.append('--emulators') 530 args.append('--emulators')
510 result = self.m.python( 531 result = self.m.python(
511 'provision_devices', 532 'provision_devices',
512 self.m.path['checkout'].join( 533 self.m.path['checkout'].join(
513 'build', 'android', 'provision_devices.py'), 534 'build', 'android', 'provision_devices.py'),
514 args=args, 535 args=args,
515 env=self.m.chromium.get_env(), 536 env=self.m.chromium.get_env(),
516 infra_step=True, 537 infra_step=True,
517 **kwargs) 538 **kwargs)
518 blacklisted_devices = result.json.output
519 if blacklisted_devices:
520 result.presentation.status = self.m.step.WARNING
521 for d in blacklisted_devices:
522 key = 'blacklisted %s' % d
523 result.presentation.logs[key] = [d]
524 539
525 def apk_path(self, apk): 540 def apk_path(self, apk):
526 return self.m.chromium.output_dir.join('apks', apk) if apk else None 541 return self.m.chromium.output_dir.join('apks', apk) if apk else None
527 542
528 def adb_install_apk(self, apk, allow_downgrade=False, devices=None): 543 def adb_install_apk(self, apk, allow_downgrade=False, devices=None):
529 install_cmd = [ 544 install_cmd = [
530 self.m.path['checkout'].join('build', 545 self.m.path['checkout'].join('build',
531 'android', 546 'android',
532 'adb_install_apk.py'), 547 'adb_install_apk.py'),
533 apk, '-v', '--blacklist-file', self.blacklist_file, 548 apk, '-v', '--blacklist-file', self.blacklist_file,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 self.create_adb_symlink() 942 self.create_adb_symlink()
928 if self.c.gce_setup: 943 if self.c.gce_setup:
929 self.launch_gce_instances(snapshot=self.c.gce_snapshot, 944 self.launch_gce_instances(snapshot=self.c.gce_snapshot,
930 count=self.c.gce_count) 945 count=self.c.gce_count)
931 self.spawn_logcat_monitor() 946 self.spawn_logcat_monitor()
932 self.provision_devices(emulators=True, 947 self.provision_devices(emulators=True,
933 remove_system_webview=remove_system_webview) 948 remove_system_webview=remove_system_webview)
934 else: 949 else:
935 self.spawn_logcat_monitor() 950 self.spawn_logcat_monitor()
936 self.authorize_adb_devices() 951 self.authorize_adb_devices()
937 self.device_status_check() 952 self.device_recovery()
938 if perf_setup: 953 if perf_setup:
939 kwargs = { 954 kwargs = {
940 'min_battery_level': 95, 955 'min_battery_level': 95,
941 'disable_network': True, 956 'disable_network': True,
942 'disable_java_debug': True, 957 'disable_java_debug': True,
943 'max_battery_temp': 350} 958 'max_battery_temp': 350}
944 else: 959 else:
945 kwargs = {} 960 kwargs = {}
946 self.provision_devices(remove_system_webview=remove_system_webview, 961 self.provision_devices(remove_system_webview=remove_system_webview,
947 **kwargs) 962 **kwargs)
963 self.device_status()
948 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1: 964 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1:
949 self.asan_device_setup() 965 self.asan_device_setup()
950 966
951 self.spawn_device_monitor() 967 self.spawn_device_monitor()
952 968
953 def common_tests_final_steps(self, logcat_gs_bucket='chromium-android'): 969 def common_tests_final_steps(self, logcat_gs_bucket='chromium-android'):
954 if not self.c.gce_setup: 970 if not self.c.gce_setup:
955 self.shutdown_device_monitor() 971 self.shutdown_device_monitor()
956 self.logcat_dump(gs_bucket=logcat_gs_bucket) 972 self.logcat_dump(gs_bucket=logcat_gs_bucket)
957 self.stack_tool_steps() 973 self.stack_tool_steps()
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 script = self.c.test_runner 1376 script = self.c.test_runner
1361 if wrapper_script_suite_name: 1377 if wrapper_script_suite_name:
1362 script = self.m.chromium.output_dir.join('bin', 'run_%s' % 1378 script = self.m.chromium.output_dir.join('bin', 'run_%s' %
1363 wrapper_script_suite_name) 1379 wrapper_script_suite_name)
1364 else: 1380 else:
1365 env = kwargs.get('env', {}) 1381 env = kwargs.get('env', {})
1366 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', 1382 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR',
1367 self.m.chromium.output_dir) 1383 self.m.chromium.output_dir)
1368 kwargs['env'] = env 1384 kwargs['env'] = env
1369 return self.m.python(step_name, script, args, **kwargs) 1385 return self.m.python(step_name, script, args, **kwargs)
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/chromium_android/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698