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);
}
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;
}
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);
}
Aggregations