use of build.bazel.remote.execution.v2.ActionCacheGrpc.ActionCacheImplBase 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.ActionCacheGrpc.ActionCacheImplBase in project bazel-buildfarm by bazelbuild.
the class StubInstanceTest method getActionResultReturnsNullForNotFound.
@Test
public void getActionResultReturnsNullForNotFound() throws Exception {
AtomicReference<GetActionResultRequest> reference = new AtomicReference<>();
serviceRegistry.addService(new ActionCacheImplBase() {
@Override
public void getActionResult(GetActionResultRequest request, StreamObserver<ActionResult> responseObserver) {
reference.set(request);
responseObserver.onError(Status.NOT_FOUND.asException());
}
});
Instance instance = newStubInstance("test");
ActionKey actionKey = DIGEST_UTIL.computeActionKey(Action.getDefaultInstance());
assertThat(instance.getActionResult(actionKey, RequestMetadata.getDefaultInstance()).get()).isNull();
GetActionResultRequest request = reference.get();
assertThat(request.getInstanceName()).isEqualTo(instance.getName());
assertThat(request.getActionDigest()).isEqualTo(actionKey.getDigest());
instance.stop();
}
use of build.bazel.remote.execution.v2.ActionCacheGrpc.ActionCacheImplBase in project bazel-buildfarm by bazelbuild.
the class GrpcActionCacheTest method getNotFoundIsNull.
@Test
public void getNotFoundIsNull() throws Exception {
Digest actionDigest = DIGEST_UTIL.compute(ByteString.copyFromUtf8("not-found"));
serviceRegistry.addService(new ActionCacheImplBase() {
@Override
public void getActionResult(GetActionResultRequest request, StreamObserver<ActionResult> responseObserver) {
responseObserver.onError(Status.NOT_FOUND.asException());
}
});
assertThat(ac.get(DigestUtil.asActionKey(actionDigest)).get()).isNull();
}
use of build.bazel.remote.execution.v2.ActionCacheGrpc.ActionCacheImplBase in project bazel-buildfarm by bazelbuild.
the class GrpcActionCacheTest method getSuppliesResponse.
@Test
public void getSuppliesResponse() throws Exception {
ActionResult result = ActionResult.newBuilder().setStdoutRaw(ByteString.copyFromUtf8("out")).build();
Digest actionDigest = DIGEST_UTIL.compute(ByteString.copyFromUtf8("in"));
serviceRegistry.addService(new ActionCacheImplBase() {
@Override
public void getActionResult(GetActionResultRequest request, StreamObserver<ActionResult> responseObserver) {
if (request.getInstanceName().equals(instanceName) && request.getActionDigest().equals(actionDigest)) {
responseObserver.onNext(result);
responseObserver.onCompleted();
} else {
responseObserver.onError(Status.NOT_FOUND.asException());
}
}
});
assertThat(ac.get(DigestUtil.asActionKey(actionDigest)).get()).isEqualTo(result);
}
use of build.bazel.remote.execution.v2.ActionCacheGrpc.ActionCacheImplBase 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