use of alluxio.grpc.BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub in project alluxio by Alluxio.
the class BlockWorkerRegisterStreamIntegrationTest method masterHangsInStream.
@Test
public void masterHangsInStream() throws Exception {
// Create the stream and control the request/response observers
BlockMasterWorkerServiceStub asyncClient = PowerMockito.mock(BlockMasterWorkerServiceStub.class);
when(asyncClient.withDeadlineAfter(anyLong(), any())).thenReturn(asyncClient);
ManualRegisterStreamObserver requestObserver = new ManualRegisterStreamObserver(MasterMode.HANG_IN_STREAM);
when(asyncClient.registerWorkerStream(any())).thenReturn(requestObserver);
RegisterStreamer registerStreamer = new RegisterStreamer(asyncClient, WORKER_ID, mTierAliases, mCapacityMap, mUsedMap, mBlockMap, LOST_STORAGE, EMPTY_CONFIG);
StreamObserver<RegisterWorkerPResponse> responseObserver = getResponseObserver(registerStreamer);
requestObserver.setResponseObserver(responseObserver);
// The master will hang during the stream which exceeds the deadline between messages
assertThrows(DeadlineExceededException.class, () -> {
registerStreamer.registerWithMaster();
});
}
use of alluxio.grpc.BlockMasterWorkerServiceGrpc.BlockMasterWorkerServiceStub in project alluxio by Alluxio.
the class BlockWorkerRegisterStreamIntegrationTest method registerWorkerErrorAtStreamStart.
/**
* Tests below cover various failure cases.
*/
@Test
public void registerWorkerErrorAtStreamStart() throws Exception {
// Create the stream and control the request/response observers
BlockMasterWorkerServiceStub asyncClient = PowerMockito.mock(BlockMasterWorkerServiceStub.class);
when(asyncClient.withDeadlineAfter(anyLong(), any())).thenReturn(asyncClient);
ManualRegisterStreamObserver requestObserver = new ManualRegisterStreamObserver(MasterMode.FIRST_REQUEST);
when(asyncClient.registerWorkerStream(any())).thenReturn(requestObserver);
RegisterStreamer registerStreamer = new RegisterStreamer(asyncClient, WORKER_ID, mTierAliases, mCapacityMap, mUsedMap, mBlockMap, LOST_STORAGE, EMPTY_CONFIG);
StreamObserver<RegisterWorkerPResponse> responseObserver = getResponseObserver(registerStreamer);
requestObserver.setResponseObserver(responseObserver);
assertThrows(InternalException.class, () -> {
// An error received from the master side will be InternalException
registerStreamer.registerWithMaster();
});
}
Aggregations