Search in sources :

Example 6 with StampedeId

use of com.facebook.buck.distributed.thrift.StampedeId in project buck by facebook.

the class DistBuildServiceTest method canUploadTargetGraph.

@Test
public void canUploadTargetGraph() throws IOException, ExecutionException, InterruptedException {
    Capture<FrontendRequest> request = EasyMock.newCapture();
    FrontendResponse response = new FrontendResponse();
    response.setType(FrontendRequestType.STORE_BUILD_GRAPH);
    response.setWasSuccessful(true);
    EasyMock.expect(frontendService.makeRequest(EasyMock.capture(request))).andReturn(response).once();
    EasyMock.replay(frontendService);
    BuildJobState buildJobState = new BuildJobState();
    List<BuildJobStateFileHashes> fileHashes = new ArrayList<>();
    buildJobState.setFileHashes(fileHashes);
    BuildJobStateTargetGraph graph = new BuildJobStateTargetGraph();
    graph.setNodes(new ArrayList<BuildJobStateTargetNode>());
    BuildJobStateTargetNode node1 = new BuildJobStateTargetNode();
    node1.setRawNode("node1");
    BuildJobStateTargetNode node2 = new BuildJobStateTargetNode();
    node2.setRawNode("node1");
    graph.addToNodes(node1);
    graph.addToNodes(node2);
    buildJobState.setTargetGraph(graph);
    StampedeId stampedeId = new StampedeId();
    stampedeId.setId("check-id");
    distBuildService.uploadTargetGraph(buildJobState, stampedeId, executor).get();
    Assert.assertTrue(request.getValue().isSetType());
    Assert.assertEquals(request.getValue().getType(), FrontendRequestType.STORE_BUILD_GRAPH);
    Assert.assertTrue(request.getValue().isSetStoreBuildGraphRequest());
    Assert.assertTrue(request.getValue().getStoreBuildGraphRequest().isSetStampedeId());
    Assert.assertEquals(request.getValue().getStoreBuildGraphRequest().getStampedeId(), stampedeId);
    Assert.assertTrue(request.getValue().getStoreBuildGraphRequest().isSetBuildGraph());
    BuildJobState sentState = BuildJobStateSerializer.deserialize(request.getValue().getStoreBuildGraphRequest().getBuildGraph());
    Assert.assertTrue(buildJobState.equals(sentState));
}
Also used : BuildJobStateTargetNode(com.facebook.buck.distributed.thrift.BuildJobStateTargetNode) BuildJobStateFileHashes(com.facebook.buck.distributed.thrift.BuildJobStateFileHashes) BuildJobStateTargetGraph(com.facebook.buck.distributed.thrift.BuildJobStateTargetGraph) StampedeId(com.facebook.buck.distributed.thrift.StampedeId) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) BuildJobState(com.facebook.buck.distributed.thrift.BuildJobState) ArrayList(java.util.ArrayList) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) Test(org.junit.Test)

Example 7 with StampedeId

use of com.facebook.buck.distributed.thrift.StampedeId in project buck by facebook.

the class DistBuildRunCommand method getBuildJobStateAndBuildName.

public Pair<BuildJobState, String> getBuildJobStateAndBuildName(ProjectFilesystem filesystem, Console console, DistBuildService service) throws IOException {
    if (buildStateFile != null) {
        Path buildStateFilePath = Paths.get(buildStateFile);
        console.getStdOut().println(String.format("Retrieving BuildJobState for from file [%s].", buildStateFilePath));
        return new Pair<>(BuildJobStateSerializer.deserialize(filesystem.newFileInputStream(buildStateFilePath)), String.format("LocalFile=[%s]", buildStateFile));
    } else {
        StampedeId stampedeId = getStampedeId();
        console.getStdOut().println(String.format("Retrieving BuildJobState for build [%s].", stampedeId));
        return new Pair<>(service.fetchBuildJobState(stampedeId), String.format("DistBuild=[%s]", stampedeId.toString()));
    }
}
Also used : Path(java.nio.file.Path) StampedeId(com.facebook.buck.distributed.thrift.StampedeId) Pair(com.facebook.buck.model.Pair)

Example 8 with StampedeId

use of com.facebook.buck.distributed.thrift.StampedeId in project buck by facebook.

the class DistBuildServiceTest method canPollBuild.

@Test
public void canPollBuild() throws Exception {
    final String idString = "poll id";
    Capture<FrontendRequest> request = EasyMock.newCapture();
    FrontendResponse response = new FrontendResponse();
    response.setType(FrontendRequestType.BUILD_STATUS);
    BuildStatusResponse buildStatusResponse = new BuildStatusResponse();
    BuildJob buildJob = new BuildJob();
    StampedeId stampedeId = new StampedeId();
    stampedeId.setId(idString);
    buildJob.setStampedeId(stampedeId);
    buildStatusResponse.setBuildJob(buildJob);
    response.setBuildStatusResponse(buildStatusResponse);
    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.getCurrentBuildJobState(id);
    Assert.assertEquals(request.getValue().getType(), FrontendRequestType.BUILD_STATUS);
    Assert.assertTrue(request.getValue().isSetBuildStatusRequest());
    Assert.assertTrue(request.getValue().getBuildStatusRequest().isSetStampedeId());
    Assert.assertEquals(request.getValue().getBuildStatusRequest().getStampedeId(), id);
    Assert.assertTrue(job.isSetStampedeId());
    Assert.assertEquals(job.getStampedeId(), id);
}
Also used : StampedeId(com.facebook.buck.distributed.thrift.StampedeId) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) BuildJob(com.facebook.buck.distributed.thrift.BuildJob) BuildStatusResponse(com.facebook.buck.distributed.thrift.BuildStatusResponse) Test(org.junit.Test)

Example 9 with StampedeId

use of com.facebook.buck.distributed.thrift.StampedeId 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);
}
Also used : StartBuildResponse(com.facebook.buck.distributed.thrift.StartBuildResponse) StampedeId(com.facebook.buck.distributed.thrift.StampedeId) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) BuildJob(com.facebook.buck.distributed.thrift.BuildJob) Test(org.junit.Test)

Example 10 with StampedeId

use of com.facebook.buck.distributed.thrift.StampedeId 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());
}
Also used : StampedeId(com.facebook.buck.distributed.thrift.StampedeId) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) Test(org.junit.Test)

Aggregations

StampedeId (com.facebook.buck.distributed.thrift.StampedeId)12 BuildJob (com.facebook.buck.distributed.thrift.BuildJob)6 FrontendRequest (com.facebook.buck.distributed.thrift.FrontendRequest)5 Test (org.junit.Test)5 FrontendResponse (com.facebook.buck.distributed.thrift.FrontendResponse)4 ArtifactCacheFactory (com.facebook.buck.artifact_cache.ArtifactCacheFactory)1 DistBuildService (com.facebook.buck.distributed.DistBuildService)1 DistBuildSlaveExecutor (com.facebook.buck.distributed.DistBuildSlaveExecutor)1 DistBuildState (com.facebook.buck.distributed.DistBuildState)1 MultiSourceContentsProvider (com.facebook.buck.distributed.MultiSourceContentsProvider)1 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)1 BuildJobStateFileHashes (com.facebook.buck.distributed.thrift.BuildJobStateFileHashes)1 BuildJobStateTargetGraph (com.facebook.buck.distributed.thrift.BuildJobStateTargetGraph)1 BuildJobStateTargetNode (com.facebook.buck.distributed.thrift.BuildJobStateTargetNode)1 BuildStatusResponse (com.facebook.buck.distributed.thrift.BuildStatusResponse)1 CreateBuildResponse (com.facebook.buck.distributed.thrift.CreateBuildResponse)1 LogLineBatchRequest (com.facebook.buck.distributed.thrift.LogLineBatchRequest)1 MultiGetBuildSlaveLogDirResponse (com.facebook.buck.distributed.thrift.MultiGetBuildSlaveLogDirResponse)1 MultiGetBuildSlaveRealTimeLogsResponse (com.facebook.buck.distributed.thrift.MultiGetBuildSlaveRealTimeLogsResponse)1 StartBuildResponse (com.facebook.buck.distributed.thrift.StartBuildResponse)1