use of build.bazel.remote.execution.v2.UpdateActionResultRequest in project bazel-buildfarm by bazelbuild.
the class StubInstanceTest method putActionResultCallsUpdateActionResult.
@Test
public void putActionResultCallsUpdateActionResult() throws InterruptedException {
AtomicReference<UpdateActionResultRequest> reference = new AtomicReference<>();
serviceRegistry.addService(new ActionCacheImplBase() {
@Override
public void updateActionResult(UpdateActionResultRequest request, StreamObserver<ActionResult> responseObserver) {
reference.set(request);
responseObserver.onNext(request.getActionResult());
responseObserver.onCompleted();
}
});
String instanceName = "putActionResult-test";
Instance instance = newStubInstance(instanceName);
ActionKey actionKey = DigestUtil.asActionKey(Digest.newBuilder().setHash("action-digest").setSizeBytes(1).build());
ActionResult actionResult = ActionResult.getDefaultInstance();
instance.putActionResult(actionKey, actionResult);
UpdateActionResultRequest request = reference.get();
assertThat(request.getInstanceName()).isEqualTo(instanceName);
assertThat(request.getActionDigest()).isEqualTo(actionKey.getDigest());
assertThat(request.getActionResult()).isEqualTo(actionResult);
instance.stop();
}
use of build.bazel.remote.execution.v2.UpdateActionResultRequest in project bazel-buildfarm by bazelbuild.
the class ActionCacheServiceTest method writeSucceedsWhenActionCacheIsWritable.
@Test
public void writeSucceedsWhenActionCacheIsWritable() throws Exception {
// If the ActionCache is configured to be read and write,
// then attempting to write to it should succeed.
// ARRANGE
Instance instance = mock(Instance.class);
ActionCacheService service = new ActionCacheService(instance, ActionCacheAccessPolicy.READ_AND_WRITE);
// ACT
StreamObserver<ActionResult> response = mock(StreamObserver.class);
UpdateActionResultRequest request = UpdateActionResultRequest.newBuilder().build();
service.updateActionResult(request, response);
// ASSERT
verify(response, times(0)).onError(any(Throwable.class));
}
use of build.bazel.remote.execution.v2.UpdateActionResultRequest in project bazel-buildfarm by bazelbuild.
the class ActionCacheService method updateActionResult.
@Override
public void updateActionResult(UpdateActionResultRequest request, StreamObserver<ActionResult> responseObserver) {
ActionResult actionResult = request.getActionResult();
try {
simpleBlobStore.putActionResult(request.getActionDigest().getHash(), actionResult.toByteArray());
responseObserver.onNext(actionResult);
responseObserver.onCompleted();
} catch (IOException e) {
responseObserver.onError(Status.fromThrowable(e).asException());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
use of build.bazel.remote.execution.v2.UpdateActionResultRequest in project bazel-buildfarm by bazelbuild.
the class ActionCacheServiceTest method writeFailsWhenActionCacheIsReadOnly.
@Test
public void writeFailsWhenActionCacheIsReadOnly() throws Exception {
// If the ActionCache is configured to be read-only,
// then attempting to write to it should result in an error.
// ARRANGE
Instance instance = mock(Instance.class);
ActionCacheService service = new ActionCacheService(instance, ActionCacheAccessPolicy.READ_ONLY);
// ACT
StreamObserver<ActionResult> response = mock(StreamObserver.class);
UpdateActionResultRequest request = UpdateActionResultRequest.newBuilder().build();
service.updateActionResult(request, response);
// ASSERT
verify(response, times(1)).onError(any(Throwable.class));
}
use of build.bazel.remote.execution.v2.UpdateActionResultRequest in project bazel-buildfarm by bazelbuild.
the class GrpcActionCacheTest method putUpdatesResult.
@Test
public void putUpdatesResult() throws InterruptedException {
ActionResult result = ActionResult.newBuilder().setStdoutRaw(ByteString.copyFromUtf8("out")).build();
Digest actionDigest = DIGEST_UTIL.compute(ByteString.copyFromUtf8("in"));
serviceRegistry.addService(new ActionCacheImplBase() {
@Override
public void updateActionResult(UpdateActionResultRequest request, StreamObserver<ActionResult> responseObserver) {
if (request.getInstanceName().equals(instanceName) && request.getActionDigest().equals(actionDigest) && request.getActionResult().equals(result)) {
responseObserver.onNext(result);
responseObserver.onCompleted();
} else {
responseObserver.onError(Status.UNAVAILABLE.asException());
}
}
});
ac.put(DigestUtil.asActionKey(actionDigest), result);
}
Aggregations