Skip to content

Commit

Permalink
Specify the default device state to use for buck tests
Browse files Browse the repository at this point in the history
Summary:
If we don't pass the setup_preference_key to remote execution, the device we lease will be in a random state, which can affect flakiness. Fix it.

As D68185161 is pushed to all tiers, we now can update the bzl to pass the setup_preference_key to buck. Default to use A14 userdebug lkg build. But also provide a config to let user overrides.

Note: the side effect is the lease time will be longer because lab need to setup the devices. But this is the right thing to do.

Reviewed By: ywang226

Differential Revision: D68281753

fbshipit-source-id: 0e027cd9a257ef151f582c037460eae477480496
  • Loading branch information
dongyansu authored and facebook-github-bot committed Feb 5, 2025
1 parent f7f51c9 commit 7aa4e26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions prelude/android/android.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ _RE_CAPS = attrs.option(attrs.dict(key = attrs.string(), value = attrs.dict(key
# }
_RE_USE_CASE = attrs.option(attrs.dict(key = attrs.string(), value = attrs.string()), default = None)

# Format is {"ovveride_name": {"param_name": param_value}}; for example:
# {
# "remote_execution_policy": {"setup_preference_key": "some_json_string"},
# }
_META_INTERNAL_EXTRA_PARAMS = attrs.option(attrs.dict(key = attrs.string(), value = attrs.any()), default = None)

extra_attributes = {
"android_aar": {
"abi_generation_mode": attrs.option(attrs.enum(AbiGenerationMode), default = None),
Expand Down Expand Up @@ -182,6 +188,7 @@ extra_attributes = {
"instrumentation_test_listener": attrs.option(attrs.exec_dep(), default = None),
"instrumentation_test_listener_class": attrs.option(attrs.string(), default = None),
"is_self_instrumenting": attrs.bool(default = False),
"meta_internal_extra_params": _META_INTERNAL_EXTRA_PARAMS,
"re_caps": _RE_CAPS,
"re_use_case": _RE_USE_CASE,
"_android_toolchain": toolchains_common.android(),
Expand Down
2 changes: 2 additions & 0 deletions prelude/android/android_instrumentation_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def _compute_executor_overrides(ctx: AnalysisContext, instrumentation_test_can_r
remote_enabled = True,
remote_execution_properties = ctx.attrs.re_caps["dynamic-listing"],
remote_execution_use_case = ctx.attrs.re_use_case["dynamic-listing"],
meta_internal_extra_params = ctx.attrs.meta_internal_extra_params,
)
if "test-execution" in ctx.attrs.re_caps and "test-execution" in ctx.attrs.re_use_case:
_validate_executor_override_re_config(ctx.attrs.re_caps["test-execution"], ctx.attrs.re_use_case["test-execution"])
Expand All @@ -202,6 +203,7 @@ def _compute_executor_overrides(ctx: AnalysisContext, instrumentation_test_can_r
remote_enabled = True,
remote_execution_properties = ctx.attrs.re_caps["test-execution"],
remote_execution_use_case = ctx.attrs.re_use_case["test-execution"],
meta_internal_extra_params = ctx.attrs.meta_internal_extra_params,
)

return {
Expand Down

0 comments on commit 7aa4e26

Please sign in to comment.