From 40824e1813445fd05a97152a95ed704ef731577b Mon Sep 17 00:00:00 2001
From: Googler <chiwang@google.com>
Date: Mon, 11 Mar 2024 02:38:48 -0700
Subject: [PATCH] Update rbe config to pick up JDK21

PiperOrigin-RevId: 614590443
Change-Id: I480373360786330d2ade3a916b92261f4e2c91b4
---
 .bazelci/postsubmit.yml | 19 ++++++++++---------
 .bazelci/presubmit.yml  | 19 ++++++++++---------
 .bazelrc                | 16 ++++++++--------
 BUILD                   |  2 +-
 MODULE.bazel            |  2 +-
 MODULE.bazel.lock       | 22 ++++++++++++++--------
 rbe_extension.bzl       |  4 ++--
 7 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/.bazelci/postsubmit.yml b/.bazelci/postsubmit.yml
index 731ff75382fd1c..be5201dd5e1ae6 100644
--- a/.bazelci/postsubmit.yml
+++ b/.bazelci/postsubmit.yml
@@ -320,28 +320,34 @@ tasks:
   rbe_ubuntu2004:
     platform: ubuntu2004
     name: "RBE"
+    environment:
+      # Use last_green to pickup the fix for https://github.com/bazelbuild/bazel/issues/21604.
+      # TODO(chiwang): Remove this after Bazel 7.2.0 is released.
+      USE_BAZEL_VERSION: last_green
     shell_commands:
       - sed -i.bak
         -e 's/^# android_sdk_repository/android_sdk_repository/'
         -e 's/^# android_ndk_repository/android_ndk_repository/' WORKSPACE.bzlmod
       - rm -f WORKSPACE.bzlmod.bak
     build_flags:
-      - "--config=ubuntu2004_java11"
+      - "--config=remote"
       - "--remote_executor=grpcs://remotebuildexecution.googleapis.com"
       - "--jobs=200"
       - "--experimental_remote_cache_async"
-      - "--experimental_remote_merkle_tree_cache"
+      # https://github.com/bazelbuild/bazel/issues/21628
+      # - "--experimental_remote_merkle_tree_cache"
       - "--remote_download_minimal"
     build_targets:
       - "//src:bazel"
       - "//src:bazel_jdk_minimal"
       - "//src/main/java/..."
     test_flags:
-      - "--config=ubuntu2004_java11"
+      - "--config=remote"
       - "--remote_executor=grpcs://remotebuildexecution.googleapis.com"
       - "--jobs=200"
       - "--experimental_remote_cache_async"
-      - "--experimental_remote_merkle_tree_cache"
+      # https://github.com/bazelbuild/bazel/issues/21628
+      # - "--experimental_remote_merkle_tree_cache"
       - "--remote_download_minimal"
     test_targets:
       - "//scripts/..."
@@ -371,11 +377,6 @@ tasks:
       - "-//src/test/py/bazel:bzlmod_query_test"
       - "-//src/test/py/bazel:mod_command_test"
       - "-//src/test/shell/bazel:verify_workspace"
-      # TODO(pcloudy): Re-enable after rbe platform switch to JDK 21
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:AllTests"
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:antxmlresultwriter_integration_test"
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:junit4_testbridge_integration_test"
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:utf8_test_log_test"
     include_json_profile:
       - build
       - test
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 623da649772965..68c6f3a314ffa5 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -378,28 +378,34 @@ tasks:
   rbe_ubuntu2004:
     platform: ubuntu2004
     name: "RBE"
+    environment:
+      # Use last_green to pickup the fix for https://github.com/bazelbuild/bazel/issues/21604.
+      # TODO(chiwang): Remove this after Bazel 7.2.0 is released.
+      USE_BAZEL_VERSION: last_green
     shell_commands:
       - sed -i.bak
         -e 's/^# android_sdk_repository/android_sdk_repository/'
         -e 's/^# android_ndk_repository/android_ndk_repository/' WORKSPACE.bzlmod
       - rm -f WORKSPACE.bzlmod.bak
     build_flags:
-      - "--config=ubuntu2004_java11"
+      - "--config=remote"
       - "--remote_executor=grpcs://remotebuildexecution.googleapis.com"
       - "--jobs=200"
       - "--experimental_remote_cache_async"
-      - "--experimental_remote_merkle_tree_cache"
+      # https://github.com/bazelbuild/bazel/issues/21628
+      # - "--experimental_remote_merkle_tree_cache"
       - "--remote_download_minimal"
     build_targets:
       - "//src:bazel"
       - "//src:bazel_jdk_minimal"
       - "//src/main/java/..."
     test_flags:
-      - "--config=ubuntu2004_java11"
+      - "--config=remote"
       - "--remote_executor=grpcs://remotebuildexecution.googleapis.com"
       - "--jobs=200"
       - "--experimental_remote_cache_async"
-      - "--experimental_remote_merkle_tree_cache"
+      # https://github.com/bazelbuild/bazel/issues/21628
+      # - "--experimental_remote_merkle_tree_cache"
       - "--remote_download_minimal"
     test_targets:
       - "//scripts/..."
@@ -432,11 +438,6 @@ tasks:
       # Flaky on rbe_ubuntu2004
       # https://github.com/bazelbuild/continuous-integration/issues/1631
       - "-//src/test/shell/bazel:bazel_sandboxing_networking_test"
-      # TODO(pcloudy): Re-enable after rbe platform switch to JDK 21
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:AllTests"
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:antxmlresultwriter_integration_test"
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:junit4_testbridge_integration_test"
-      - "-//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner:utf8_test_log_test"
     include_json_profile:
       - build
       - test
diff --git a/.bazelrc b/.bazelrc
index bf913e4327f1f6..5ec1ee1bea97a4 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -12,16 +12,16 @@ build:remote_shared --java_runtime_version=rbe_jdk
 build:remote_shared --tool_java_runtime_version=rbe_jdk
 
 # Configuration to build and test Bazel on RBE on Ubuntu 18.04 with Java 11
-build:ubuntu2004_java11 --extra_toolchains=@rbe_ubuntu2004_java11//java:all
-build:ubuntu2004_java11 --crosstool_top=@rbe_ubuntu2004_java11//cc:toolchain
-build:ubuntu2004_java11 --extra_toolchains=@rbe_ubuntu2004_java11//config:cc-toolchain
-build:ubuntu2004_java11 --extra_execution_platforms=//:rbe_ubuntu2004_java11_platform,//:rbe_ubuntu2004_java11_highcpu_platform
-build:ubuntu2004_java11 --host_platform=//:rbe_ubuntu2004_java11_platform
-build:ubuntu2004_java11 --platforms=//:rbe_ubuntu2004_java11_platform
-build:ubuntu2004_java11 --config=remote_shared
+build:ubuntu2004 --extra_toolchains=@rbe_ubuntu2004//java:all
+build:ubuntu2004 --crosstool_top=@rbe_ubuntu2004//cc:toolchain
+build:ubuntu2004 --extra_toolchains=@rbe_ubuntu2004//config:cc-toolchain
+build:ubuntu2004 --extra_execution_platforms=//:rbe_ubuntu2004_platform,//:rbe_ubuntu2004_highcpu_platform
+build:ubuntu2004 --host_platform=//:rbe_ubuntu2004_platform
+build:ubuntu2004 --platforms=//:rbe_ubuntu2004_platform
+build:ubuntu2004 --config=remote_shared
 
 # Alias
-build:remote --config=ubuntu2004_java11
+build:remote --config=ubuntu2004
 
 build:macos --macos_minimum_os=10.11
 
diff --git a/BUILD b/BUILD
index e4ee25b722469a..db478cd38019ca 100644
--- a/BUILD
+++ b/BUILD
@@ -282,7 +282,7 @@ platform(
     ],
 )
 
-REMOTE_PLATFORMS = ("rbe_ubuntu2004_java11",)
+REMOTE_PLATFORMS = ("rbe_ubuntu2004",)
 
 [
     platform(
diff --git a/MODULE.bazel b/MODULE.bazel
index 8c2d9084c6ffa2..b87629a6dc90ec 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -311,7 +311,7 @@ use_repo(
 )
 
 bazel_rbe_deps = use_extension("//:rbe_extension.bzl", "bazel_rbe_deps")
-use_repo(bazel_rbe_deps, "rbe_ubuntu2004_java11")
+use_repo(bazel_rbe_deps, "rbe_ubuntu2004")
 
 remote_coverage_tools_extension = use_extension("//tools/test:extensions.bzl", "remote_coverage_tools_extension")
 use_repo(remote_coverage_tools_extension, "remote_coverage_tools")
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index cb5326046a9fd7..245bfa4eeb7989 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -1,6 +1,6 @@
 {
   "lockFileVersion": 3,
-  "moduleFileHash": "14bba83eb932a2d1e95652677a2b9c697eb9d59b7e170f8bde7032f88c80a9d7",
+  "moduleFileHash": "53d9b29b1ed318eb4f6f5f24b0a2165f9ff8af8b796e152817813a1437bd709a",
   "flags": {
     "cmdRegistries": [
       "https://bcr.bazel.build/"
@@ -549,7 +549,7 @@
             "column": 31
           },
           "imports": {
-            "rbe_ubuntu2004_java11": "rbe_ubuntu2004_java11"
+            "rbe_ubuntu2004": "rbe_ubuntu2004"
           },
           "devImports": [],
           "tags": [],
@@ -2766,7 +2766,7 @@
         "bzlTransitiveDigest": "r8gQnSLwon27gWD77J8mb3DIe4v3gtn7J/rsic53Qyw=",
         "accumulatedFileDigests": {
           "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "36be85298605cd87b305a9e552db380313888139c1b040c29ced0132ae544416",
-          "@@//:MODULE.bazel": "14bba83eb932a2d1e95652677a2b9c697eb9d59b7e170f8bde7032f88c80a9d7"
+          "@@//:MODULE.bazel": "53d9b29b1ed318eb4f6f5f24b0a2165f9ff8af8b796e152817813a1437bd709a"
         },
         "envVariables": {},
         "generatedRepoSpecs": {
@@ -3301,20 +3301,26 @@
     },
     "//:rbe_extension.bzl%bazel_rbe_deps": {
       "general": {
-        "bzlTransitiveDigest": "oNMQ9KtzGcqNHdpe8zMO3lRAVIKWWDmz8n5SMubtIIc=",
+        "bzlTransitiveDigest": "3Qxu4ylcYD3RTWLhk5k/59p/CwZ4tLdSgYnmBXYgAtc=",
         "accumulatedFileDigests": {},
         "envVariables": {},
         "generatedRepoSpecs": {
-          "rbe_ubuntu2004_java11": {
+          "rbe_ubuntu2004": {
             "bzlFile": "@@_main~bazel_test_deps~bazelci_rules//:rbe_repo.bzl",
             "ruleClassName": "rbe_preconfig",
             "attributes": {
-              "name": "_main~bazel_rbe_deps~rbe_ubuntu2004_java11",
-              "toolchain": "ubuntu2004-bazel-java11"
+              "name": "_main~bazel_rbe_deps~rbe_ubuntu2004",
+              "toolchain": "ubuntu2004"
             }
           }
         },
-        "recordedRepoMappingEntries": []
+        "recordedRepoMappingEntries": [
+          [
+            "",
+            "bazelci_rules",
+            "_main~bazel_test_deps~bazelci_rules"
+          ]
+        ]
       }
     },
     "//tools/android:android_extensions.bzl%android_sdk_proxy_extensions": {
diff --git a/rbe_extension.bzl b/rbe_extension.bzl
index 90dea5fc73218f..7e8e1a12a8da6a 100644
--- a/rbe_extension.bzl
+++ b/rbe_extension.bzl
@@ -20,8 +20,8 @@ load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig")
 
 def _bazel_rbe_deps(_ctx):
     rbe_preconfig(
-        name = "rbe_ubuntu2004_java11",
-        toolchain = "ubuntu2004-bazel-java11",
+        name = "rbe_ubuntu2004",
+        toolchain = "ubuntu2004",
     )
 
 bazel_rbe_deps = module_extension(implementation = _bazel_rbe_deps)