Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
SrodriguezO committed Jul 19, 2019
1 parent 1f17262 commit e88ed86
Showing 1 changed file with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,29 +382,40 @@ public void noRemoteCacheSpawns() throws Exception {
// Checks that spawns satisfying Spawns.mayBeCachedRemotely=false are not looked up in the
// remote cache, and that the results/artifacts are not uploaded to the remote cache.

RemoteOptions remoteOptions = Options.getDefaults(RemoteOptions.class);
remoteOptions.remoteCache = "https://somecache.com";
cache = remoteSpawnCacheWithOptions(remoteOptions);
for (String requirement : ImmutableList.of(
ExecutionRequirements.NO_CACHE,
ExecutionRequirements.LOCAL,
ExecutionRequirements.NO_REMOTE_CACHE,
ExecutionRequirements.NO_REMOTE)
RemoteOptions remoteCacheOptions = Options.getDefaults(RemoteOptions.class);
remoteCacheOptions.remoteCache = "https://somecache.com";

// For the purposes of execution requirements, a combined cache with a remote component
// is considered a remote cache
RemoteOptions combinedCacheOptions = Options.getDefaults(RemoteOptions.class);
combinedCacheOptions.remoteCache = "https://somecache.com";
combinedCacheOptions.diskCache = PathFragment.create("/etc/something/cache/here");

for (RemoteSpawnCache _cache: ImmutableList.of(
remoteSpawnCacheWithOptions(remoteCacheOptions),
remoteSpawnCacheWithOptions(combinedCacheOptions))
) {
SimpleSpawn uncacheableSpawn =
simpleSpawnWithExecutionInfo(ImmutableMap.of(requirement, ""));
CacheHandle entry = cache.lookup(uncacheableSpawn, simplePolicy);
verify(remoteCache, never()).getCachedActionResult(any(ActionKey.class));
assertThat(entry.hasResult()).isFalse();
SpawnResult result =
new SpawnResult.Builder()
.setExitCode(0)
.setStatus(Status.SUCCESS)
.setRunnerName("test")
.build();
entry.store(result);
verifyNoMoreInteractions(remoteCache);
assertThat(progressUpdates).containsExactly();
for (String requirement : ImmutableList.of(
ExecutionRequirements.NO_CACHE,
ExecutionRequirements.LOCAL,
ExecutionRequirements.NO_REMOTE_CACHE,
ExecutionRequirements.NO_REMOTE)
) {
SimpleSpawn uncacheableSpawn =
simpleSpawnWithExecutionInfo(ImmutableMap.of(requirement, ""));
CacheHandle entry = _cache.lookup(uncacheableSpawn, simplePolicy);
verify(remoteCache, never()).getCachedActionResult(any(ActionKey.class));
assertThat(entry.hasResult()).isFalse();
SpawnResult result =
new SpawnResult.Builder()
.setExitCode(0)
.setStatus(Status.SUCCESS)
.setRunnerName("test")
.build();
entry.store(result);
verifyNoMoreInteractions(remoteCache);
assertThat(progressUpdates).containsExactly();
}
}
}

Expand Down

0 comments on commit e88ed86

Please sign in to comment.