blob: a7741b8e1160674e5a76c017cc3cd0de5d9fda4e [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from PB.infra.fuchsia import Fuchsia
from recipe_engine.recipe_api import Property
DEPS = [
'fuchsia/artifacts',
'fuchsia/build',
'fuchsia/buildbucket_util',
'fuchsia/checkout',
'fuchsia/experimental',
'fuchsia/fuchsia',
'fuchsia/testing',
'fuchsia/testing_requests',
'fuchsia/testsharder',
'recipe_engine/buildbucket',
'recipe_engine/isolated',
'recipe_engine/file',
'recipe_engine/json',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/raw_io',
'recipe_engine/step',
'recipe_engine/swarming',
]
PROPERTIES = {
'build_artifact_hash':
Property(
kind=str,
help='Hash for which build artifact may be downloaded',
default='abc'),
'device_type':
Property(
kind=str,
help='Passed through to spec field Fuchsia.Test.device_type',
default='QEMU'),
'pave':
Property(
kind=bool,
help='Passed through to spec field Fuchsia.Test.pave',
default=True),
'requires_secrets':
Property(
kind=bool,
help='Passed through to spec field Fuchsia.Test.requires_secrets',
default=True),
'test_in_shards':
Property(
kind=bool,
help='Passed through to spec field Fuchsia.Test.test_in_shards',
default=False),
'collect_timeout_secs':
Property(
kind=int,
help=('Passed through to spec field '
'Fuchsia.Test.collect_timeout_secs'),
default=0),
'deprecated':
Property(
kind=bool,
help='Whether to use the deprecated code path',
default=False),
'per_test_timeout_secs':
Property(
kind=int,
help='Passed through to spec field Fuchsia.Test.per_test_timeout_secs',
default=0),
'use_runtests':
Property(kind=bool, help='Whether to use runtests', default=False),
}
def RunSteps(api, build_artifact_hash, device_type, pave, requires_secrets,
test_in_shards, collect_timeout_secs, deprecated,
per_test_timeout_secs, use_runtests):
build_artifacts = api.build.BuildArtifacts.download(api, build_artifact_hash)
# Configure context of uploaded artifacts for test task construction.
api.artifacts.gcs_bucket = 'fuchsia-artifacts'
api.artifacts.uuid = api.buildbucket_util.id
test_spec = Fuchsia.Test(
device_type=device_type,
pave=pave,
pool='fuchsia.tests',
requires_secrets=requires_secrets,
test_in_shards=test_in_shards,
collect_timeout_secs=collect_timeout_secs,
per_test_timeout_secs=per_test_timeout_secs,
use_runtests=use_runtests,
)
if deprecated:
shard_requests = api.testing_requests.deprecated_shard_requests(
build_artifacts,
api.testing_requests.deprecated_test_cmds(test_spec),
test_spec.device_type,
test_spec.pool,
test_spec.timeout_secs,
test_spec.pave,
requires_secrets=test_spec.requires_secrets)
assert len(shard_requests) == 1
else:
_ = api.testing_requests.shard_requests(
build_artifacts, api.buildbucket.build, test_spec.per_test_timeout_secs,
test_spec.pool, test_spec.swarming_expiration_timeout_secs,
test_spec.swarming_io_timeout_secs, test_spec.use_runtests,
test_spec.timeout_secs)
def GenTests(api):
# For coverage
api.testing_requests.task_requests_step_data(
[api.testing_requests.task_request_jsonish(False)], '')
api.testing_requests.default_tests()
testsharder_tests = [
api.testsharder.test(
name='TEST',
label='//path/to/test:test(//toolchain)',
os='linux',
path='/path/to/test',
deps=['/path/to/dep'],
)
]
# Test cases for running Fuchsia tests as a swarming task.
yield (api.test('deprecated_with_secrets') + api.properties(
deprecated=True, requires_secrets=True, per_test_timeout_secs=1) +
api.testing_requests.secrets_step_data())
yield api.test('deprecated_non_emu') + api.properties(
deprecated=True, pave=False, device_type='DEVICE TYPE')
yield api.test('not-emu') + api.testing_requests.shards_step_data(shards=[
api.testsharder.shard(
name='NAME',
tests=testsharder_tests,
dimensions={'device_type': 'DEVICE TYPE'},
netboot=True,
service_account='my-service-account@example.com',
)
]) + api.properties(
use_runtests=True, per_test_timeout_secs=1)
yield api.test('legacy_qemu') + api.testing_requests.shards_step_data(shards=[
api.testsharder.shard(
name='NAME',
tests=testsharder_tests,
dimensions={'device_type': 'QEMU'},
)
]) + api.properties(**{
'experimental.ssh_into_qemu': False,
'per_test_timeout_secs': 1
}) + api.testing_requests.args_test_data(variants=['asan'])
yield api.test('legacy_aemu') + api.testing_requests.shards_step_data(shards=[
api.testsharder.shard(
name='NAME',
tests=testsharder_tests,
dimensions={'device_type': 'AEMU'},
)
]) + api.properties(**{'experimental.ssh_into_qemu': False})
yield api.test('qemu') + api.testing_requests.shards_step_data(shards=[
api.testsharder.shard(
name='NAME',
tests=testsharder_tests,
dimensions={'device_type': 'QEMU'},
)
]) + api.properties(per_test_timeout_secs=1)
yield api.test('aemu') + api.testing_requests.shards_step_data(shards=[
api.testsharder.shard(
name='NAME',
tests=testsharder_tests,
dimensions={'device_type': 'AEMU'},
)
])