use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.
the class DistBuildServiceTest method canStartBuild.
@Test
public void canStartBuild() throws Exception {
final String idString = "start id";
Capture<FrontendRequest> request = EasyMock.newCapture();
FrontendResponse response = new FrontendResponse();
response.setType(FrontendRequestType.START_BUILD);
StartBuildResponse startBuildResponse = new StartBuildResponse();
BuildJob buildJob = new BuildJob();
StampedeId stampedeId = new StampedeId();
stampedeId.setId(idString);
buildJob.setStampedeId(stampedeId);
startBuildResponse.setBuildJob(buildJob);
response.setStartBuildResponse(startBuildResponse);
response.setWasSuccessful(true);
EasyMock.expect(frontendService.makeRequest(EasyMock.capture(request))).andReturn(response).once();
EasyMock.replay(frontendService);
StampedeId id = new StampedeId();
id.setId(idString);
BuildJob job = distBuildService.startBuild(id);
Assert.assertEquals(request.getValue().getType(), FrontendRequestType.START_BUILD);
Assert.assertTrue(request.getValue().isSetStartBuildRequest());
Assert.assertTrue(request.getValue().getStartBuildRequest().isSetStampedeId());
Assert.assertEquals(request.getValue().getStartBuildRequest().getStampedeId(), id);
Assert.assertTrue(job.isSetStampedeId());
Assert.assertEquals(job.getStampedeId(), id);
}
use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.
the class DistBuildServiceTest method testRequestContainsStampedeId.
@Test
public void testRequestContainsStampedeId() {
StampedeId stampedeId = createStampedeId("topspin");
FrontendRequest request = DistBuildService.createFrontendBuildStatusRequest(stampedeId);
Assert.assertEquals(stampedeId, request.getBuildStatusRequest().getStampedeId());
}
use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.
the class ThriftOverHttpServiceTest method testSendValidMessageAndReturnError.
@Test
public void testSendValidMessageAndReturnError() throws IOException {
// TODO(ruibm): Add jetty end to end integration tests for this API.
FrontendRequest request = new FrontendRequest();
request.setType(FrontendRequestType.BUILD_STATUS);
FrontendResponse response = new FrontendResponse();
response.setType(FrontendRequestType.START_BUILD);
Capture<Request.Builder> requestBuilder = EasyMock.newCapture();
HttpResponse httpResponse = EasyMock.createMock(HttpResponse.class);
EasyMock.expect(httpResponse.statusCode()).andReturn(404).atLeastOnce();
EasyMock.expect(httpResponse.statusMessage()).andReturn("topspin").atLeastOnce();
EasyMock.expect(httpResponse.requestUrl()).andReturn("super url").atLeastOnce();
EasyMock.expect(httpService.makeRequest(EasyMock.eq("/thrift"), EasyMock.capture(requestBuilder))).andReturn(httpResponse).times(1);
EasyMock.replay(httpResponse, httpService);
try {
service.makeRequest(request, response);
Assert.fail("This should've thrown an IOException.");
} catch (IOException e) {
Assert.assertNotNull(e);
}
Request actualHttpRequest = requestBuilder.getValue().url("http://localhost").build();
Assert.assertEquals(ThriftOverHttpService.THRIFT_CONTENT_TYPE, actualHttpRequest.body().contentType());
EasyMock.verify(httpResponse, httpService);
}
use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.
the class ThriftOverHttpServiceTest method testSendValidMessageAndReturnValidResponse.
@Test
public void testSendValidMessageAndReturnValidResponse() throws IOException, TException {
FrontendRequest request = new FrontendRequest();
request.setType(FrontendRequestType.BUILD_STATUS);
FrontendResponse expectedResponse = new FrontendResponse();
expectedResponse.setType(FrontendRequestType.START_BUILD);
Capture<Request.Builder> requestBuilder = EasyMock.newCapture();
TSerializer serializer = new TSerializer(config.getThriftProtocol().getFactory());
final byte[] responseBuffer = serializer.serialize(expectedResponse);
HttpResponse httpResponse = new HttpResponse() {
@Override
public int statusCode() {
return 200;
}
@Override
public String statusMessage() {
return "super cool msg";
}
@Override
public long contentLength() throws IOException {
return responseBuffer.length;
}
@Override
public InputStream getBody() {
return new ByteArrayInputStream(responseBuffer);
}
@Override
public String requestUrl() {
return "super url";
}
@Override
public void close() throws IOException {
// do nothing.
}
};
EasyMock.expect(httpService.makeRequest(EasyMock.eq("/thrift"), EasyMock.capture(requestBuilder))).andReturn(httpResponse).times(1);
EasyMock.replay(httpService);
FrontendResponse actualResponse = new FrontendResponse();
service.makeRequest(request, actualResponse);
Assert.assertEquals(expectedResponse, actualResponse);
EasyMock.verify(httpService);
}
use of com.facebook.buck.distributed.thrift.FrontendRequest in project buck by facebook.
the class DistBuildService method setBuckDotFiles.
public void setBuckDotFiles(StampedeId id, List<PathInfo> dotFiles) throws IOException {
SetBuckDotFilePathsRequest storeBuckDotFilesRequest = new SetBuckDotFilePathsRequest();
storeBuckDotFilesRequest.setStampedeId(id);
storeBuckDotFilesRequest.setDotFiles(dotFiles);
FrontendRequest request = new FrontendRequest();
request.setType(FrontendRequestType.SET_DOTFILE_PATHS);
request.setSetBuckDotFilePathsRequest(storeBuckDotFilesRequest);
makeRequestChecked(request);
}
Aggregations