Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android_local_test isn't compatible with Android Platforms #19829

Closed
katre opened this issue Oct 16, 2023 · 7 comments
Closed

android_local_test isn't compatible with Android Platforms #19829

katre opened this issue Oct 16, 2023 · 7 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-Android Issues for Android team type: bug

Comments

@katre
Copy link
Member

katre commented Oct 16, 2023

Forked from #18262.

The android_local_test rule is a strange beast which wants to do two things: it wants to build an APK, using a valid Android SDK.

But, it also wants to run a Java binary on the local platform, with that APK as a data file. This worked before #18262, but now that we are being honest about Java versions, the cracks show up.

This sounds like a case for execution groups to me, but I also don't actually understand how this works under the hood.

For now, this means that we need to disable testing android_local_test with Android Platforms, and get the code cleaned up.

We probably also need to fix the Starlark version in bazelbuild/rules_android.

@katre katre added type: bug P1 I'll work on this now. (Assignee required) team-Android Issues for Android team labels Oct 16, 2023
@katre katre added this to the 7.0.0 release blockers milestone Oct 16, 2023
katre added a commit to katre/bazel that referenced this issue Oct 16, 2023
@gregestren
Copy link
Contributor

Is this a blocker for flipping the flag? If one of the android rules would fail with it?

copybara-service bot pushed a commit that referenced this issue Oct 16, 2023
We need this until #19829 is fixed.

This should unblock #18262.

Closes #19830.

PiperOrigin-RevId: 573892609
Change-Id: I944901a2be6c5a0cb9279dc86edc0741f3129769
@katre
Copy link
Member Author

katre commented Oct 16, 2023

I've marked it as a blocker for Bazel 7 release (not for starting the release, but for finishing it), but we need someone from the rules_android team to investigate because the code is pretty confusing.

@iancha1992 iancha1992 removed this from the 7.0.0 release blockers milestone Oct 18, 2023
@iancha1992
Copy link
Member

@bazel-io fork 7.0.0

@katre
Copy link
Member Author

katre commented Nov 6, 2023

Error log from bazel test //src/test/shell/bazel/android:android_local_test_integration_test_with_platforms (with the test re-enabled):

** test_android_local_test *****************************************************
$TEST_TMPDIR defined: output root default is '/usr/local/google/home/jcater/.cache/bazel/_bazel_jcater/a85a0dacd9e20e18c47928db0f1530e0/sandbox/linux-sandbox/1280/execroot/_main/_tmp/c0008185402992cea4ecb54c46211ee6' and max_idle_secs default is '15'.
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/etc/bazel.bazelrc
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
-- Test log: -----------------------------------------------------------
$TEST_TMPDIR defined: output root default is '/usr/local/google/home/jcater/.cache/bazel/_bazel_jcater/a85a0dacd9e20e18c47928db0f1530e0/sandbox/linux-sandbox/1280/execroot/_main/_tmp/c0008185402992cea4ecb54c46211ee6' and max_idle_secs default is '15'.
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/etc/bazel.bazelrc
Computing main repo mapping: 
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
Loading: 
Loading: 0 packages loaded
Analyzing: target //javatests/com/bin:test (1 packages loaded, 0 targets configured)
Analyzing: target //javatests/com/bin:test (1 packages loaded, 0 targets configured)
[0 / 1] checking cached actions
Analyzing: target //javatests/com/bin:test (5 packages loaded, 6 targets configured)
[1 / 1] checking cached actions
Analyzing: target //javatests/com/bin:test (62 packages loaded, 12 targets configured)
[1 / 1] checking cached actions
ERROR: /usr/local/google/home/jcater/.cache/bazel/_bazel_jcater/a85a0dacd9e20e18c47928db0f1530e0/sandbox/linux-sandbox/1280/execroot/_main/_tmp/c0008185402992cea4ecb54c46211ee6/workspace.FJHlJe57/javatests/com/bin/BUILD:5:19: While resolving toolchains for target //javatests/com/bin:test (d3e1c6f): No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@bazel_tools//tools/jdk:runtime_toolchain_type'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.
ERROR: Analysis of target '//javatests/com/bin:test' failed; build aborted
INFO: Elapsed time: 3.703s, Critical Path: 0.04s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: No test targets were found, yet testing was requested
------------------------------------------------------------------------
test_android_local_test FAILED: Tests for //javatests/com/bin:test failed.
/usr/local/google/home/jcater/.cache/bazel/_bazel_jcater/a85a0dacd9e20e18c47928db0f1530e0/sandbox/linux-sandbox/1280/execroot/_main/bazel-out/k8-fastbuild/bin/src/test/shell/bazel/android/android_local_test_integration_test_with_platforms.runfiles/_main/src/test/shell/bazel/android/android_local_test_integration_test_with_platforms:162: in call to test_android_local_test

Tear down:

INFO[android_local_test_integration_test_with_platforms 2023-11-06 21:16:31 (+0000)] Cleaning up workspace

FAILED: test_android_local_test

The problem (I think) is that the test sets --platforms to an Android platform (in android_helper.sh), but there's no JDK available for that platform.

@Wyverald
Copy link
Member

Wyverald commented Nov 9, 2023

Hullo! We're trying to get 7.0 blockers under control and this one seems to not have been investigated yet. Could we get an initial triage and an estimate on how long this'll take to fix?

@katre
Copy link
Member Author

katre commented Nov 10, 2023

@ahumesky was investigating, I'll ask him to update.

@ahumesky
Copy link
Contributor

I have a change out for review that should address this

bazel-io pushed a commit to bazel-io/bazel that referenced this issue Nov 15, 2023
1. Remove `target_compatible_with` from the Android toolchains generated in the Starlark and native `android_sdk_repository` rules so that they can be selected with a host JDK in android_local_test

1. Re-enable `android_local_test_integration_test.sh`

1. Switch `--platforms` to `--android_platforms` in the android integration test setup so that a host JDK can be selected in android_local_test

Fixes bazelbuild#19829

RELNOTES: None
PiperOrigin-RevId: 582716155
Change-Id: I49d6a9058218d522b9ebb7cc6842fe20c36e2798
keertk pushed a commit that referenced this issue Nov 15, 2023
…20215)

1. Remove `target_compatible_with` from the Android toolchains generated
in the Starlark and native `android_sdk_repository` rules so that they
can be selected with a host JDK in android_local_test

1. Re-enable `android_local_test_integration_test.sh`

1. Switch `--platforms` to `--android_platforms` in the android
integration test setup so that a host JDK can be selected in
android_local_test

Fixes #19829

RELNOTES: None
Commit
9bbc2cb

PiperOrigin-RevId: 582716155
Change-Id: I49d6a9058218d522b9ebb7cc6842fe20c36e2798

Co-authored-by: Googler <[email protected]>
copybara-service bot pushed a commit to bazelbuild/rules_android that referenced this issue Nov 15, 2023
…in (Starlark) android_sdk_repository so that it can be selected along with a host JDK in android_local_test.

bazelbuild/bazel#19829

PiperOrigin-RevId: 582777002
Change-Id: If480dce6c4d35e40934fe326c1362c8f446ff848
jylinv0 pushed a commit to jylinv0/rules_android that referenced this issue Jan 23, 2024
…in (Starlark) android_sdk_repository so that it can be selected along with a host JDK in android_local_test.

bazelbuild/bazel#19829

PiperOrigin-RevId: 582777002
Change-Id: If480dce6c4d35e40934fe326c1362c8f446ff848
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-Android Issues for Android team type: bug
Projects
None yet
Development

No branches or pull requests

6 participants