Search in sources :

Example 1 with ByteStreamUploader

use of build.buildfarm.instance.stub.ByteStreamUploader in project bazel-buildfarm by bazelbuild.

the class GrpcCASTest method putAddsExpiration.

@Test
public void putAddsExpiration() throws IOException, InterruptedException {
    ByteString uploadContent = ByteString.copyFromUtf8("uploaded");
    Digest digest = DIGEST_UTIL.compute(uploadContent);
    String instanceName = "test";
    ListMultimap<Digest, Runnable> onExpirations = MultimapBuilder.hashKeys().arrayListValues().build();
    Channel channel = InProcessChannelBuilder.forName(fakeServerName).directExecutor().build();
    ByteStreamUploader uploader = mock(ByteStreamUploader.class);
    GrpcCAS cas = new GrpcCAS(instanceName, channel, uploader, onExpirations);
    Runnable onExpiration = mock(Runnable.class);
    cas.put(new Blob(uploadContent, digest), onExpiration);
    verify(uploader, times(1)).uploadBlob(eq(HashCode.fromString(digest.getHash())), any(Chunker.class));
    assertThat(onExpirations.get(digest)).containsExactly(onExpiration);
    verifyZeroInteractions(onExpiration);
}
Also used : ByteStreamUploader(build.buildfarm.instance.stub.ByteStreamUploader) Blob(build.buildfarm.cas.ContentAddressableStorage.Blob) Digest(build.bazel.remote.execution.v2.Digest) ByteString(com.google.protobuf.ByteString) Channel(io.grpc.Channel) Chunker(build.buildfarm.instance.stub.Chunker) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 2 with ByteStreamUploader

use of build.buildfarm.instance.stub.ByteStreamUploader in project bazel-buildfarm by bazelbuild.

the class BuildFarmServerTest method createAction.

private Digest createAction(Action.Builder actionBuilder) throws IOException, InterruptedException {
    DigestUtil digestUtil = new DigestUtil(HashFunction.SHA256);
    Command command = Command.newBuilder().addArguments("echo").build();
    Digest commandDigest = digestUtil.compute(command);
    Directory root = Directory.getDefaultInstance();
    Digest rootBlobDigest = digestUtil.compute(root);
    Action action = actionBuilder.setCommandDigest(commandDigest).setInputRootDigest(rootBlobDigest).build();
    Digest actionDigest = digestUtil.compute(action);
    ByteStreamUploader uploader = new ByteStreamUploader(INSTANCE_NAME, inProcessChannel, null, 60, Retrier.NO_RETRIES);
    uploader.uploadBlobs(ImmutableMap.of(HashCode.fromString(actionDigest.getHash()), Chunker.builder().setInput(action.toByteString()).build(), HashCode.fromString(commandDigest.getHash()), Chunker.builder().setInput(command.toByteString()).build()));
    return actionDigest;
}
Also used : ByteStreamUploader(build.buildfarm.instance.stub.ByteStreamUploader) Action(build.bazel.remote.execution.v2.Action) Command(build.bazel.remote.execution.v2.Command) Digest(build.bazel.remote.execution.v2.Digest) DigestUtil(build.buildfarm.common.DigestUtil) Directory(build.bazel.remote.execution.v2.Directory)

Example 3 with ByteStreamUploader

use of build.buildfarm.instance.stub.ByteStreamUploader in project bazel-buildfarm by bazelbuild.

the class ContentAddressableStorages method createGrpcCAS.

public static ContentAddressableStorage createGrpcCAS(GrpcCASConfig config) {
    Channel channel = createChannel(config.getTarget());
    ByteStreamUploader byteStreamUploader = new ByteStreamUploader("", channel, null, 300, NO_RETRIES);
    ListMultimap<Digest, Runnable> onExpirations = synchronizedListMultimap(MultimapBuilder.hashKeys().arrayListValues().build());
    return new GrpcCAS(config.getInstanceName(), channel, byteStreamUploader, onExpirations);
}
Also used : ByteStreamUploader(build.buildfarm.instance.stub.ByteStreamUploader) Digest(build.bazel.remote.execution.v2.Digest) Channel(io.grpc.Channel)

Aggregations

Digest (build.bazel.remote.execution.v2.Digest)3 ByteStreamUploader (build.buildfarm.instance.stub.ByteStreamUploader)3 Channel (io.grpc.Channel)2 Action (build.bazel.remote.execution.v2.Action)1 Command (build.bazel.remote.execution.v2.Command)1 Directory (build.bazel.remote.execution.v2.Directory)1 Blob (build.buildfarm.cas.ContentAddressableStorage.Blob)1 DigestUtil (build.buildfarm.common.DigestUtil)1 Chunker (build.buildfarm.instance.stub.Chunker)1 ByteString (com.google.protobuf.ByteString)1 Test (org.junit.Test)1