Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions configs/test/swarming/swarming.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ mapping:
expiration_secs: 86400
execution_timeout_secs: 86400
docker_image: 'gcr.io/clusterfuzz-images/base:a2f4dd6-202202070654'
ANDROID_EMULATOR:
priority: 1
command:
- 'luci-auth'
- 'context'
- '--'
- './linux_entry_point.sh'
cas_input_root:
cas_instance: 'projects/server-name/instances/instance_name'
digest:
hash: 'linux_entry_point_archive_hash'
size_bytes: 1234
service_account_email: test-clusterfuzz-service-account-email
preemptible: false
expiration_secs: 86400
execution_timeout_secs: 86400
docker_image: 'gcr.io/clusterfuzz-images/base:a2f4dd6-202202070654'
env:
- key: OS_OVERRIDE
value: ANDROID_EMULATOR
MAC:
priority: 1
command:
Expand Down
2 changes: 1 addition & 1 deletion src/clusterfuzz/_internal/cron/schedule_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _get_jobs_for_platforms(platforms: list[str]) -> list[data_types.Job]:

def _get_swarming_jobs():
"""Returns all jobs that have swarming environment variables."""
jobs = _get_jobs_for_platforms(['ANDROID', 'LINUX'])
jobs = _get_jobs_for_platforms(['ANDROID', 'LINUX', 'ANDROID_EMULATOR'])
return [
job for job in jobs
if swarming.has_swarming_env_vars(job.get_environment())
Expand Down
3 changes: 2 additions & 1 deletion src/clusterfuzz/_internal/platforms/android/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def wait_until_good_state():
"""Check battery and make sure it is charged beyond minimum level and
temperature thresholds."""
# Battery levels are not applicable on GCE.
if environment.is_android_cuttlefish() or settings.is_automotive():
if (environment.is_android_cuttlefish() or
environment.is_android_emulator() or settings.is_automotive()):
return

# Make sure device is online.
Expand Down
5 changes: 4 additions & 1 deletion src/clusterfuzz/_internal/swarming/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def _get_task_dimensions(job: data_types.Job, platform_specific_dimensions: list
return []

unique_dimensions = {}
unique_dimensions['os'] = str(job.platform).capitalize()
if job.platform == 'ANDROID_EMULATOR':
unique_dimensions['os'] = 'Linux'
else:
unique_dimensions['os'] = str(job.platform).capitalize()
unique_dimensions['pool'] = swarming_config.get('swarming_pool')

for dimension in platform_specific_dimensions:
Expand Down
64 changes: 64 additions & 0 deletions src/clusterfuzz/_internal/tests/core/swarming/swarming_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,70 @@ def test_get_spec_from_config_for_fuzz_task(self):
])
self.assertEqual(spec, expected_spec)

def test_get_spec_from_config_for_android_emulator(self):
"""Tests that create_new_task_request overrides dimensions with (os=Linux)
and environment with (OS_OVERRIDE=ANDROID_EMULATOR)
for ANDROID_EMULATOR platform tasks."""
job = data_types.Job(
name='libfuzzer_chrome_asan', platform='ANDROID_EMULATOR')
job.put()
spec = swarming.create_new_task_request('corpus_pruning', job.name,
'https://download_url')
expected_spec = swarming_pb2.NewTaskRequest(
name='task_name',
priority=1,
realm='realm-name',
service_account='test-clusterfuzz-service-account-email',
task_slices=[
swarming_pb2.TaskSlice(
expiration_secs=86400,
properties=swarming_pb2.TaskProperties(
command=[
'luci-auth', 'context', '--', './linux_entry_point.sh'
],
dimensions=[
swarming_pb2.StringPair(key='os', value='Linux'),
swarming_pb2.StringPair(key='pool', value='pool-name')
],
cipd_input=swarming_pb2.CipdInput(), # pylint: disable=no-member
cas_input_root=swarming_pb2.CASReference(
cas_instance=
'projects/server-name/instances/instance_name',
digest=swarming_pb2.Digest(
hash='linux_entry_point_archive_hash',
size_bytes=1234)),
execution_timeout_secs=86400,
env=[
swarming_pb2.StringPair(
key='DOCKER_IMAGE',
value=
'gcr.io/clusterfuzz-images/base:a2f4dd6-202202070654'
),
swarming_pb2.StringPair(
key='OS_OVERRIDE', value='ANDROID_EMULATOR'),
swarming_pb2.StringPair(key='UWORKER', value='True'),
swarming_pb2.StringPair(
key='SWARMING_BOT', value='True'),
swarming_pb2.StringPair(key='LOG_TO_GCP', value='True'),
swarming_pb2.StringPair(key='IS_K8S_ENV', value='True'),
swarming_pb2.StringPair(
key='DISABLE_MOUNTS', value='True'),
swarming_pb2.StringPair(
key='LOGGING_CLOUD_PROJECT_ID', value='project_id'),
swarming_pb2.StringPair(
key='DOCKER_ENV_VARS',
value=(
'{"DOCKER_IMAGE": "gcr.io/clusterfuzz-images/'
'base:a2f4dd6-202202070654", "OS_OVERRIDE": '
'"ANDROID_EMULATOR", "UWORKER": "True", '
'"SWARMING_BOT": "True", "LOG_TO_GCP": "True", '
'"IS_K8S_ENV": "True", "DISABLE_MOUNTS": "True", '
'"LOGGING_CLOUD_PROJECT_ID": "project_id"}')),
],
secret_bytes='https://download_url'.encode('utf-8')))
])
self.assertEqual(spec, expected_spec)

def test_is_swarming_task(self):
"""Tests that is_swarming_task works as expected."""
job = data_types.Job(
Expand Down
Loading