use of build.buildfarm.cas.cfc.CASFileCache.PutDirectoryException in project bazel-buildfarm by bazelbuild.
the class CASFileCacheTest method putDirectoryIOExceptionRollsBack.
@Test
public void putDirectoryIOExceptionRollsBack() throws IOException, InterruptedException {
ByteString file = ByteString.copyFromUtf8("Peanut Butter");
Digest fileDigest = DIGEST_UTIL.compute(file);
// omitting blobs.put to incur IOException
Directory subDirectory = Directory.getDefaultInstance();
Digest subdirDigest = DIGEST_UTIL.compute(subDirectory);
Directory directory = Directory.newBuilder().addFiles(FileNode.newBuilder().setName("file").setDigest(fileDigest).build()).addDirectories(DirectoryNode.newBuilder().setName("subdir").setDigest(subdirDigest).build()).build();
Digest dirDigest = DIGEST_UTIL.compute(directory);
Map<Digest, Directory> directoriesIndex = ImmutableMap.of(dirDigest, directory, subdirDigest, subDirectory);
boolean exceptionHandled = false;
try {
getInterruptiblyOrIOException(fileCache.putDirectory(dirDigest, directoriesIndex, putService));
} catch (PutDirectoryException e) {
exceptionHandled = true;
}
assertThat(exceptionHandled).isTrue();
assertThat(Files.exists(fileCache.getDirectoryPath(dirDigest))).isFalse();
}
Aggregations