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

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

Issue 2143013002: Revert "[Android] Reland splitting of device recovery and device status." (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: 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()' 35 'devices is only available after device_status_check()'
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_recovery() 332 self.device_status_check(restart_usb=restart_usb)
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()
340 339
341 @property 340 @property
342 def blacklist_file(self): 341 def blacklist_file(self):
343 return self.out_path.join('bad_devices.json') 342 return self.out_path.join('bad_devices.json')
344 343
345 344
346 def revert_device_file_format(self): 345 def revert_device_file_format(self):
347 # If current device file is jsonified, revert it back to original format. 346 # If current device file is jsonified, revert it back to original format.
348 if self.m.path.exists(self.known_devices_file): 347 if self.m.path.exists(self.known_devices_file):
349 with self.m.step.nest('fix_device_file_format'): 348 with self.m.step.nest('fix_device_file_format'):
(...skipping 10 matching lines...) Expand all
360 except ValueError: 359 except ValueError:
361 # File wasn't json, so no need to revert. 360 # File wasn't json, so no need to revert.
362 self.m.step.active_result.presentation.step_text += ( 361 self.m.step.active_result.presentation.step_text += (
363 'file format is compatible') 362 'file format is compatible')
364 363
365 def device_status_check(self, restart_usb=False, **kwargs): 364 def device_status_check(self, restart_usb=False, **kwargs):
366 # TODO(bpastene): Remove once chromium revisions prior to 365 # TODO(bpastene): Remove once chromium revisions prior to
367 # crrev.com/1faecde0c03013b6cd725da413339c60223f8948 are no longer tested. 366 # crrev.com/1faecde0c03013b6cd725da413339c60223f8948 are no longer tested.
368 # See crbug.com/619707 for context. 367 # See crbug.com/619707 for context.
369 self.revert_device_file_format() 368 self.revert_device_file_format()
370 self.device_recovery()
371 self.device_status()
372 369
373 def device_recovery(self, restart_usb=False, **kwargs): 370 # TODO(phajdan.jr): Remove path['build'] usage, http://crbug.com/437264 .
374 args = [ 371 args = [
372 '--adb-path', self.m.adb.adb_path(),
375 '--blacklist-file', self.blacklist_file, 373 '--blacklist-file', self.blacklist_file,
376 '--known-devices-file', self.known_devices_file, 374 '--json-output', self.m.json.output(),
377 '--adb-path', self.m.adb.adb_path(), 375 '--known-devices-file', self.known_devices_file
378 '-v'
379 ] 376 ]
380 self.m.step( 377 if restart_usb:
381 'device_recovery', 378 args += ['--restart-usb']
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 379
389 def device_status(self, **kwargs):
390 buildbot_file = '/home/chrome-bot/.adb_device_info'
391 args = [
392 '--json-output', self.m.json.output(),
393 '--blacklist-file', self.blacklist_file,
394 '--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',
398 ]
399 try: 380 try:
400 result = self.m.step( 381 result = self.m.step(
401 'device_status', 382 'device_status_check',
402 [self.m.path['checkout'].join('third_party', 'catapult', 'devil', 383 [self.m.path['checkout'].join('build', 'android', 'buildbot',
403 'devil', 'android', 'tools', 384 'bb_device_status_check.py')] + args,
404 'device_status.py')] + args,
405 step_test_data=lambda: self.m.json.test_api.output([ 385 step_test_data=lambda: self.m.json.test_api.output([
406 { 386 {
407 "battery": { 387 "battery": {
408 "status": "5", 388 "status": "5",
409 "scale": "100", 389 "scale": "100",
410 "temperature": "249", 390 "temperature": "249",
411 "level": "100", 391 "level": "100",
412 "AC powered": "false", 392 "AC powered": "false",
413 "health": "2", 393 "health": "2",
414 "voltage": "4286", 394 "voltage": "4286",
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 self.m.properties['buildername']), 458 self.m.properties['buildername']),
479 'labels': 'Restrict-View-Google,OS-Android,Infra,Infra-Labs', 459 'labels': 'Restrict-View-Google,OS-Android,Infra,Infra-Labs',
480 } 460 }
481 link = ('https://code.google.com/p/chromium/issues/entry?%s' % 461 link = ('https://code.google.com/p/chromium/issues/entry?%s' %
482 urllib.urlencode(params)) 462 urllib.urlencode(params))
483 f.result.presentation.links.update({ 463 f.result.presentation.links.update({
484 'report a bug': link 464 'report a bug': link
485 }) 465 })
486 raise 466 raise
487 467
488
489 def provision_devices(self, skip_wipe=False, disable_location=False, 468 def provision_devices(self, skip_wipe=False, disable_location=False,
490 min_battery_level=None, disable_network=False, 469 min_battery_level=None, disable_network=False,
491 disable_java_debug=False, max_battery_temp=None, 470 disable_java_debug=False, max_battery_temp=None,
492 disable_system_chrome=False, reboot_timeout=None, 471 disable_system_chrome=False, reboot_timeout=None,
493 remove_system_webview=False, emulators=False, 472 remove_system_webview=False, emulators=False,
494 **kwargs): 473 **kwargs):
495 args = [ 474 args = [
496 '--adb-path', self.m.adb.adb_path(), 475 '--adb-path', self.m.adb.adb_path(),
497 '--blacklist-file', self.blacklist_file, 476 '--blacklist-file', self.blacklist_file,
498 '--output-device-blacklist', self.m.json.output(add_json_log=False), 477 '--output-device-blacklist', self.m.json.output(add_json_log=False),
(...skipping 30 matching lines...) Expand all
529 if emulators: 508 if emulators:
530 args.append('--emulators') 509 args.append('--emulators')
531 result = self.m.python( 510 result = self.m.python(
532 'provision_devices', 511 'provision_devices',
533 self.m.path['checkout'].join( 512 self.m.path['checkout'].join(
534 'build', 'android', 'provision_devices.py'), 513 'build', 'android', 'provision_devices.py'),
535 args=args, 514 args=args,
536 env=self.m.chromium.get_env(), 515 env=self.m.chromium.get_env(),
537 infra_step=True, 516 infra_step=True,
538 **kwargs) 517 **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]
539 524
540 def apk_path(self, apk): 525 def apk_path(self, apk):
541 return self.m.chromium.output_dir.join('apks', apk) if apk else None 526 return self.m.chromium.output_dir.join('apks', apk) if apk else None
542 527
543 def adb_install_apk(self, apk, allow_downgrade=False, devices=None): 528 def adb_install_apk(self, apk, allow_downgrade=False, devices=None):
544 install_cmd = [ 529 install_cmd = [
545 self.m.path['checkout'].join('build', 530 self.m.path['checkout'].join('build',
546 'android', 531 'android',
547 'adb_install_apk.py'), 532 'adb_install_apk.py'),
548 apk, '-v', '--blacklist-file', self.blacklist_file, 533 apk, '-v', '--blacklist-file', self.blacklist_file,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 self.create_adb_symlink() 927 self.create_adb_symlink()
943 if self.c.gce_setup: 928 if self.c.gce_setup:
944 self.launch_gce_instances(snapshot=self.c.gce_snapshot, 929 self.launch_gce_instances(snapshot=self.c.gce_snapshot,
945 count=self.c.gce_count) 930 count=self.c.gce_count)
946 self.spawn_logcat_monitor() 931 self.spawn_logcat_monitor()
947 self.provision_devices(emulators=True, 932 self.provision_devices(emulators=True,
948 remove_system_webview=remove_system_webview) 933 remove_system_webview=remove_system_webview)
949 else: 934 else:
950 self.spawn_logcat_monitor() 935 self.spawn_logcat_monitor()
951 self.authorize_adb_devices() 936 self.authorize_adb_devices()
952 self.device_recovery() 937 self.device_status_check()
953 if perf_setup: 938 if perf_setup:
954 kwargs = { 939 kwargs = {
955 'min_battery_level': 95, 940 'min_battery_level': 95,
956 'disable_network': True, 941 'disable_network': True,
957 'disable_java_debug': True, 942 'disable_java_debug': True,
958 'max_battery_temp': 350} 943 'max_battery_temp': 350}
959 else: 944 else:
960 kwargs = {} 945 kwargs = {}
961 self.provision_devices(remove_system_webview=remove_system_webview, 946 self.provision_devices(remove_system_webview=remove_system_webview,
962 **kwargs) 947 **kwargs)
963 self.device_status()
964 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1: 948 if self.m.chromium.c.gyp_env.GYP_DEFINES.get('asan', 0) == 1:
965 self.asan_device_setup() 949 self.asan_device_setup()
966 950
967 self.spawn_device_monitor() 951 self.spawn_device_monitor()
968 952
969 def common_tests_final_steps(self, logcat_gs_bucket='chromium-android'): 953 def common_tests_final_steps(self, logcat_gs_bucket='chromium-android'):
970 if not self.c.gce_setup: 954 if not self.c.gce_setup:
971 self.shutdown_device_monitor() 955 self.shutdown_device_monitor()
972 self.logcat_dump(gs_bucket=logcat_gs_bucket) 956 self.logcat_dump(gs_bucket=logcat_gs_bucket)
973 self.stack_tool_steps() 957 self.stack_tool_steps()
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 script = self.c.test_runner 1360 script = self.c.test_runner
1377 if wrapper_script_suite_name: 1361 if wrapper_script_suite_name:
1378 script = self.m.chromium.output_dir.join('bin', 'run_%s' % 1362 script = self.m.chromium.output_dir.join('bin', 'run_%s' %
1379 wrapper_script_suite_name) 1363 wrapper_script_suite_name)
1380 else: 1364 else:
1381 env = kwargs.get('env', {}) 1365 env = kwargs.get('env', {})
1382 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', 1366 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR',
1383 self.m.chromium.output_dir) 1367 self.m.chromium.output_dir)
1384 kwargs['env'] = env 1368 kwargs['env'] = env
1385 return self.m.python(step_name, script, args, **kwargs) 1369 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