Search in sources :

Example 1 with PutDirectoryException

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();
}
Also used : Digest(build.bazel.remote.execution.v2.Digest) PutDirectoryException(build.buildfarm.cas.cfc.CASFileCache.PutDirectoryException) ByteString(com.google.protobuf.ByteString) Directory(build.bazel.remote.execution.v2.Directory) Test(org.junit.Test)

Aggregations

Digest (build.bazel.remote.execution.v2.Digest)1 Directory (build.bazel.remote.execution.v2.Directory)1 PutDirectoryException (build.buildfarm.cas.cfc.CASFileCache.PutDirectoryException)1 ByteString (com.google.protobuf.ByteString)1 Test (org.junit.Test)1