Commit a322b7d8 authored by rnephew's avatar rnephew Committed by Commit bot

Revert of Add multiple device/os filtering and a config file. (patchset #9...

Revert of Add multiple device/os filtering and a config file. (patchset #9 id:160001 of https://codereview.chromium.org/879983002/)

Reason for revert:
Not working on bots.

Original issue's description:
> Add multiple device/os filtering and a config file.
>
> BUG=
>
> Committed: https://crrev.com/241e6870d1f5cb7e2f23a8b1edc33eb6db64ad24
> Cr-Commit-Position: refs/heads/master@{#314151}

TBR=jbudorick@chromium.org,rnephew@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review URL: https://codereview.chromium.org/890143004

Cr-Commit-Position: refs/heads/master@{#314174}
parent e77a5395
......@@ -4,8 +4,6 @@
"""Environment setup and teardown for remote devices."""
import distutils.version
import json
import logging
import os
import random
......@@ -30,138 +28,50 @@ class RemoteDeviceEnvironment(environment.Environment):
error_func: error to show when using bad command line arguments.
"""
super(RemoteDeviceEnvironment, self).__init__()
self._access_token = None
self._device = None
self._device_type = args.device_type
if args.api_key_file:
with open(args.api_key_file) as api_key_file:
self._api_key = api_key_file.read().strip()
elif args.api_key:
self._api_key = args.api_key
else:
error_func('Must set api key with --api-key or --api-key-file')
if args.api_secret_file:
with open(args.api_secret_file) as api_secret_file:
self._api_secret = api_secret_file.read().strip()
elif args.api_secret:
self._api_secret = args.api_secret
else:
error_func('Must set api secret with --api-secret or --api-secret-file')
if not args.api_protocol:
error_func('Must set api protocol with --api-protocol. Example: http')
self._api_protocol = args.api_protocol
if not args.api_address:
error_func('Must set api address with --api-address')
self._api_address = args.api_address
if not args.api_port:
error_func('Must set api port with --api-port.')
self._api_port = args.api_port
self._access_token = ''
self._results_path = args.results_path
self._remote_device = args.remote_device
self._remote_device_os = args.remote_device_os
self._runner_package = args.runner_package
self._runner_type = args.runner_type
self._device = ''
self._verbose_count = args.verbose_count
self._device_type = args.device_type
self._timeouts = {
'queueing': 60 * 10,
'installing': 60 * 10,
'in-progress': 60 * 30,
'unknown': 60 * 5
}
# Example config file:
# {
# "remote_device": ["Galaxy S4", "Galaxy S3"],
# "remote_device_os": ["4.4.2", "4.4.4"],
# "remote_device_minimum_os": "4.4.2",
# "api_address": "www.example.com",
# "api_port": "80",
# "api_protocol": "http",
# "api_secret": "apisecret",
# "api_key": "apikey",
# "timeouts": {
# "queueing": 600,
# "installing": 600,
# "in-progress": 1800,
# "unknown": 300
# }
# }
if args.remote_device_file:
with open(args.remote_device_file) as device_file:
device_json = json.load(device_file)
else:
device_json = {}
self._api_address = device_json.get('api_address', None)
self._api_key = device_json.get('api_key', None)
self._api_port = device_json.get('api_port', None)
self._api_protocol = device_json.get('api_protocol', None)
self._api_secret = device_json.get('api_secret', None)
self._remote_device = device_json.get('remote_device', None)
self._remote_device_minimum_os = device_json.get(
'remote_device_minimum_os', None)
self._remote_device_os = device_json.get('remote_device_os', None)
self._device_oem = device_json.get('device_oem', None)
self._device_type = device_json.get('device_type', 'Android')
self._results_path = device_json.get('results_path', None)
self._runner_package = device_json.get('runner_package', None)
self._runner_type = device_json.get('runner_type', None)
if 'timeouts' in device_json:
for key in device_json['timeouts']:
self._timeouts[key] = device_json['timeouts'][key]
def command_line_override(
file_value, cmd_line_value, desc, print_value=True):
if cmd_line_value:
if file_value and file_value != cmd_line_value:
if print_value:
logging.info('Overriding %s from %s to %s',
desc, file_value, cmd_line_value)
else:
logging.info('overriding %s', desc)
return cmd_line_value
return file_value
self._api_address = command_line_override(
self._api_address, args.api_address, 'api_address')
self._api_port = command_line_override(
self._api_port, args.api_port, 'api_port')
self._api_protocol = command_line_override(
self._api_protocol, args.api_protocol, 'api_protocol')
self._device_oem = command_line_override(
self._device_oem, args.device_oem, 'device_oem')
self._device_type = command_line_override(
self._device_type, args.device_type, 'device_type')
self._remote_device = command_line_override(
self._remote_device, args.remote_device, 'remote_device')
self._remote_device_minimum_os = command_line_override(
self._remote_device_minimum_os, args.remote_device_minimum_os,
'remote_device_minimum_os')
self._remote_device_os = command_line_override(
self._remote_device_os, args.remote_device_os, 'remote_device_os')
self._results_path = command_line_override(
self._results_path, args.results_path, 'results_path')
self._runner_package = command_line_override(
self._runner_package, args.runner_package, 'runner_package')
self._runner_type = command_line_override(
self._runner_type, args.runner_type, 'runner_type')
if args.api_key_file:
with open(args.api_key_file) as api_key_file:
temp_key = api_key_file.read().strip()
self._api_key = command_line_override(
self._api_key, temp_key, 'api_key', print_value=False)
self._api_key = command_line_override(
self._api_key, args.api_key, 'api_key', print_value=False)
if args.api_secret_file:
with open(args.api_secret_file) as api_secret_file:
temp_secret = api_secret_file.read().strip()
self._api_secret = command_line_override(
self._api_secret, temp_secret, 'api_secret', print_value=False)
self._api_secret = command_line_override(
self._api_secret, args.api_secret, 'api_secret', print_value=False)
if not self._api_address:
error_func('Must set api address with --api-address'
' or in --remote-device-file.')
if not self._api_key:
error_func('Must set api key with --api-key, --api-key-file'
' or in --remote-device-file')
if not self._api_port:
error_func('Must set api port with --api-port'
' or in --remote-device-file')
if not self._api_protocol:
error_func('Must set api protocol with --api-protocol'
' or in --remote-device-file. Example: http')
if not self._api_secret:
error_func('Must set api secret with --api-secret, --api-secret-file'
' or in --remote-device-file')
logging.info('Api address: %s', self._api_address)
logging.info('Api port: %s', self._api_port)
logging.info('Api protocol: %s', self._api_protocol)
logging.info('Remote device: %s', self._remote_device)
logging.info('Remote device minimum OS: %s',
self._remote_device_minimum_os)
logging.info('Remote device OS: %s', self._remote_device_os)
logging.info('Remote device OEM: %s', self._device_oem)
logging.info('Remote device type: %s', self._device_type)
logging.info('Results Path: %s', self._results_path)
logging.info('Runner package: %s', self._runner_package)
logging.info('Runner type: %s', self._runner_type)
logging.info('Timeouts: %s', self._timeouts)
if not args.trigger and not args.collect:
self._trigger = True
......@@ -240,16 +150,10 @@ class RemoteDeviceEnvironment(environment.Environment):
for device in device_list:
if device['os_name'] != self._device_type:
continue
if self._remote_device and device['name'] not in self._remote_device:
if self._remote_device and device['name'] != self._remote_device:
continue
if (self._remote_device_os
and device['os_version'] not in self._remote_device_os):
continue
if self._device_oem and device['brand'] not in self._device_oem:
continue
if (self._remote_device_minimum_os
and distutils.version.LooseVersion(device['os_version'])
< distutils.version.LooseVersion(self._remote_device_minimum_os)):
and device['os_version'] != self._remote_device_os):
continue
if ((self._remote_device and self._remote_device_os)
or device['available_devices_count']):
......
......@@ -121,40 +121,28 @@ def ProcessCommonOptions(args):
def AddRemoteDeviceOptions(parser):
group = parser.add_argument_group('Remote Device Options')
group.add_argument('--trigger',
group.add_argument('--trigger', default='',
help=('Only triggers the test if set. Stores test_run_id '
'in given file path. '))
group.add_argument('--collect',
group.add_argument('--collect', default='',
help=('Only collects the test results if set. '
'Gets test_run_id from given file path.'))
group.add_argument('--remote-device', action='append',
group.add_argument('--remote-device', default='',
help='Device type to run test on.')
group.add_argument('--results-path',
group.add_argument('--remote-device-os', default='',
help='OS to have on the device.')
group.add_argument('--results-path', default='',
help='File path to download results to.')
group.add_argument('--api-protocol',
help='HTTP protocol to use. (http or https)')
group.add_argument('--api-address',
help='Address to send HTTP requests.')
group.add_argument('--api-port',
help='Port to send HTTP requests to.')
group.add_argument('--runner-type',
group.add_argument('--api-address', help='Address to send HTTP requests.')
group.add_argument('--api-port', help='Port to send HTTP requests to.')
group.add_argument('--runner-type', default='',
help='Type of test to run as.')
group.add_argument('--runner-package',
help='Package name of test.')
group.add_argument('--device-type',
group.add_argument('--runner-package', help='Package name of test.')
group.add_argument('--device-type', default='Android',
choices=constants.VALID_DEVICE_TYPES,
help=('Type of device to run on. iOS or android'))
group.add_argument('--device-oem', action='append',
help='Device OEM to run on.')
group.add_argument('--remote-device-file',
help=('File with JSON to select remote device. '
'Overrides all other flags.'))
device_os_group = group.add_mutually_exclusive_group()
device_os_group.add_argument('--remote-device-minimum-os',
help='Minimum OS on device.')
device_os_group.add_argument('--remote-device-os', action='append',
help='OS to have on the device.')
api_secret_group = group.add_mutually_exclusive_group()
api_secret_group.add_argument('--api-secret', default='',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment