|
43 | 43 | import com.google.devtools.build.lib.exec.ExecutionOptions;
|
44 | 44 | import com.google.devtools.build.lib.pkgcache.PackageOptions;
|
45 | 45 | import com.google.devtools.build.lib.remote.circuitbreaker.FailureCircuitBreaker;
|
| 46 | +import com.google.devtools.build.lib.remote.downloader.GrpcRemoteDownloader; |
46 | 47 | import com.google.devtools.build.lib.remote.options.RemoteOptions;
|
47 | 48 | import com.google.devtools.build.lib.runtime.BlazeRuntime;
|
48 | 49 | import com.google.devtools.build.lib.runtime.BlazeServerStartupOptions;
|
@@ -221,6 +222,42 @@ public void initialize() {
|
221 | 222 | remoteOptions = Options.getDefaults(RemoteOptions.class);
|
222 | 223 | }
|
223 | 224 |
|
| 225 | + @Test |
| 226 | + public void testVerifyCapabilities_none() throws Exception { |
| 227 | + // Test that Bazel doesn't issue GetCapabilities calls if the requirement is NONE. |
| 228 | + // Regression test for https://github.com/bazelbuild/bazel/issues/20342. |
| 229 | + CapabilitiesImpl executionServerCapabilitiesImpl = new CapabilitiesImpl(EXEC_AND_CACHE_CAPS); |
| 230 | + Server executionServer = |
| 231 | + createFakeServer(EXECUTION_SERVER_NAME, executionServerCapabilitiesImpl); |
| 232 | + executionServer.start(); |
| 233 | + |
| 234 | + CapabilitiesImpl cacheCapabilitiesImpl = new CapabilitiesImpl(CACHE_ONLY_CAPS); |
| 235 | + Server cacheServer = createFakeServer(CACHE_SERVER_NAME, cacheCapabilitiesImpl); |
| 236 | + cacheServer.start(); |
| 237 | + |
| 238 | + try { |
| 239 | + remoteOptions.remoteExecutor = EXECUTION_SERVER_NAME; |
| 240 | + remoteOptions.remoteDownloader = CACHE_SERVER_NAME; |
| 241 | + |
| 242 | + beforeCommand(); |
| 243 | + |
| 244 | + // Wait for the channel to be connected. |
| 245 | + var downloader = (GrpcRemoteDownloader) remoteModule.getRemoteDownloaderSupplier().get(); |
| 246 | + var unused = downloader.getChannel().withChannelBlocking(ch -> new Object()); |
| 247 | + |
| 248 | + // Remote downloader uses Remote Asset API, and Bazel doesn't have any capability requirement |
| 249 | + // on the endpoint. Expecting the request count is 0. |
| 250 | + assertThat(cacheCapabilitiesImpl.getRequestCount()).isEqualTo(0); |
| 251 | + assertCircuitBreakerInstance(); |
| 252 | + } finally { |
| 253 | + executionServer.shutdownNow(); |
| 254 | + cacheServer.shutdownNow(); |
| 255 | + |
| 256 | + executionServer.awaitTermination(); |
| 257 | + cacheServer.awaitTermination(); |
| 258 | + } |
| 259 | + } |
| 260 | + |
224 | 261 | @Test
|
225 | 262 | public void testVerifyCapabilities_executionAndCacheForSingleEndpoint() throws Exception {
|
226 | 263 | CapabilitiesImpl executionServerCapabilitiesImpl = new CapabilitiesImpl(EXEC_AND_CACHE_CAPS);
|
|
0 commit comments