Search in sources :

Example 6 with BuildDriverResult

use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.

the class StatusUpdatesTest method createBuildResult.

private BuildResult createBuildResult() {
    IndyRepositoryManagerResult repoManagerResult = new IndyRepositoryManagerResult(Collections.emptyList(), Collections.emptyList(), RandomStringUtils.randomNumeric(4));
    BuildDriverResult driverResult = new BuildDriverResult() {

        @Override
        public String getBuildLog() {
            return "";
        }

        @Override
        public BuildStatus getBuildStatus() {
            return BuildStatus.SUCCESS;
        }

        @Override
        public Optional<String> getOutputChecksum() {
            return Optional.of("3678bbe366b11f7216bd03ad33f583d9");
        }
    };
    return new BuildResult(CompletionStatus.SUCCESS, Optional.empty(), "", Optional.empty(), Optional.of(driverResult), Optional.of(repoManagerResult), Optional.empty(), Optional.empty());
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) IndyRepositoryManagerResult(org.jboss.pnc.indyrepositorymanager.IndyRepositoryManagerResult)

Example 7 with BuildDriverResult

use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.

the class BuildExecutionTest method testBuild.

@Test
public void testBuild() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException {
    BuildConfiguration buildConfiguration = configurationBuilder.build(1, "c1-java");
    Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
    ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
    runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper);
    List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesSuccess();
    // check build statuses
    checkBuildStatuses(statusChangedEvents, expectedStatuses);
    // check results
    BuildResult buildResult = buildExecutionResultWrapper.get();
    // check results: logs
    BuildDriverResult buildDriverResult = buildResult.getBuildDriverResult().get();
    String buildLog = buildDriverResult.getBuildLog();
    Assert.assertTrue("Invalid build log.", buildLog.contains("Finished: SUCCESS"));
    // check results: artifacts
    RepositoryManagerResult repositoryManagerResult = buildResult.getRepositoryManagerResult().get();
    Assert.assertTrue("Missing build artifacts.", repositoryManagerResult.getBuiltArtifacts().size() > 0);
    Assert.assertTrue("Missing build dependencies.", repositoryManagerResult.getDependencies().size() > 0);
    Artifact artifact = repositoryManagerResult.getBuiltArtifacts().iterator().next();
    Assert.assertTrue("Invalid built artifact in the result.", artifact.getIdentifier().startsWith(ArtifactBuilder.IDENTIFIER_PREFIX));
}
Also used : BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) BuildExecutionStatus(org.jboss.pnc.enums.BuildExecutionStatus) Artifact(org.jboss.pnc.model.Artifact) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildResult(org.jboss.pnc.spi.BuildResult) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with BuildDriverResult

use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.

the class BuildExecutorMock method cancel.

@Override
public void cancel(String executionConfigurationId) throws ExecutorException {
    BuildExecutionSession buildExecutionSession = runningExecutions.get(executionConfigurationId);
    if (buildExecutionSession == null) {
        log.error("Unable to cancel build {}. The build is not running.", executionConfigurationId);
        return;
    }
    log.info("Cancelling build {}.", executionConfigurationId);
    runningFutures.get(executionConfigurationId).cancel(true);
    BuildDriverResult driverResult = BuildDriverResultMock.mockResult(BuildStatus.CANCELLED);
    buildExecutionSession.setBuildDriverResult(driverResult);
}
Also used : BuildExecutionSession(org.jboss.pnc.spi.executor.BuildExecutionSession) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult)

Example 9 with BuildDriverResult

use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.

the class BuildResultMapper method toDTO.

public BuildResultRest toDTO(BuildResult buildResult) {
    CompletionStatus completionStatus = buildResult.getCompletionStatus();
    ProcessException processException = buildResult.getProcessException().orElse(null);
    String processLog = buildResult.getProcessLog();
    BuildExecutionConfigurationRest buildExecutionConfiguration;
    if (buildResult.getBuildExecutionConfiguration().isPresent()) {
        BuildExecutionConfiguration bec = buildResult.getBuildExecutionConfiguration().get();
        buildExecutionConfiguration = new BuildExecutionConfigurationRest(bec);
    } else {
        buildExecutionConfiguration = null;
    }
    BuildDriverResultRest buildDriverResult;
    if (buildResult.getBuildDriverResult().isPresent()) {
        BuildDriverResult result = buildResult.getBuildDriverResult().get();
        buildDriverResult = new BuildDriverResultRest(result);
    } else {
        buildDriverResult = null;
    }
    RepositoryManagerResultRest repositoryManagerResult;
    if (buildResult.getRepositoryManagerResult().isPresent()) {
        RepositoryManagerResult result = buildResult.getRepositoryManagerResult().get();
        repositoryManagerResult = repositoryManagerResultMapper.toDTO(result);
    } else {
        repositoryManagerResult = null;
    }
    EnvironmentDriverResult environmentDriverResult;
    if (buildResult.getEnvironmentDriverResult().isPresent()) {
        environmentDriverResult = buildResult.getEnvironmentDriverResult().get();
    } else {
        environmentDriverResult = null;
    }
    RepourResult repourResult = buildResult.getRepourResult().orElse(null);
    return new BuildResultRest(completionStatus, processException, processLog, buildExecutionConfiguration, buildDriverResult, repositoryManagerResult, environmentDriverResult, repourResult);
}
Also used : BuildResultRest(org.jboss.pnc.bpm.model.BuildResultRest) ProcessException(org.jboss.pnc.spi.coordinator.ProcessException) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResultRest(org.jboss.pnc.bpm.model.RepositoryManagerResultRest) EnvironmentDriverResult(org.jboss.pnc.spi.environment.EnvironmentDriverResult) CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult) BuildExecutionConfigurationRest(org.jboss.pnc.bpm.model.BuildExecutionConfigurationRest) RepourResult(org.jboss.pnc.spi.repour.RepourResult) BuildDriverResultRest(org.jboss.pnc.bpm.model.BuildDriverResultRest)

Example 10 with BuildDriverResult

use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.

the class BlockedBuildDriverMock method complete.

protected void complete(BuildExecutionSession buildExecutionSession, final RunningEnvironment runningEnvironment, Consumer<CompletedBuild> onComplete) throws InterruptedException {
    log.info("Running blocked build ...");
    semaphore.acquire();
    setBuildStatus(TestProjectConfigurationBuilder.CANCEL);
    log.info("Blocked build canceled.");
    onComplete.accept(new CompletedBuild() {

        @Override
        public BuildDriverResult getBuildResult() throws BuildDriverException {
            return getBuildResultMock(runningEnvironment);
        }

        @Override
        public RunningEnvironment getRunningEnvironment() {
            return runningEnvironment;
        }
    });
}
Also used : CompletedBuild(org.jboss.pnc.spi.builddriver.CompletedBuild) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) BuildDriverException(org.jboss.pnc.spi.builddriver.exception.BuildDriverException) RunningEnvironment(org.jboss.pnc.spi.environment.RunningEnvironment)

Aggregations

BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)15 RepositoryManagerResult (org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)7 BuildResult (org.jboss.pnc.spi.BuildResult)6 BuildExecutionConfiguration (org.jboss.pnc.spi.executor.BuildExecutionConfiguration)4 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 BuildDriverException (org.jboss.pnc.spi.builddriver.exception.BuildDriverException)3 CompletionStatus (org.jboss.pnc.spi.coordinator.CompletionStatus)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 BuildDriverResultRest (org.jboss.pnc.bpm.model.BuildDriverResultRest)2 BuildResultRest (org.jboss.pnc.bpm.model.BuildResultRest)2 ObjectWrapper (org.jboss.pnc.common.util.ObjectWrapper)2 BuildExecutionStatus (org.jboss.pnc.enums.BuildExecutionStatus)2 Artifact (org.jboss.pnc.model.Artifact)2 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)2 CompletedBuild (org.jboss.pnc.spi.builddriver.CompletedBuild)2 ProcessException (org.jboss.pnc.spi.coordinator.ProcessException)2 EnvironmentDriverResult (org.jboss.pnc.spi.environment.EnvironmentDriverResult)2 RunningEnvironment (org.jboss.pnc.spi.environment.RunningEnvironment)2 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)2