Search in sources :

Example 1 with BuildDriverResult

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

the class DefaultBuildCoordinatorTest method mockBuildResult.

private BuildResult mockBuildResult(boolean withSshCredentials) {
    BuildResult result = mock(BuildResult.class);
    BuildDriverResult driverResult = mock(BuildDriverResult.class);
    when(driverResult.getBuildStatus()).thenReturn(BuildStatus.FAILED);
    when(result.getBuildDriverResult()).thenReturn(Optional.of(driverResult));
    RepositoryManagerResult repoManagerResult = mock(RepositoryManagerResult.class);
    when(repoManagerResult.getCompletionStatus()).thenReturn(CompletionStatus.SUCCESS);
    when(result.getRepositoryManagerResult()).thenReturn(Optional.of(repoManagerResult));
    when(result.getBuildExecutionConfiguration()).thenReturn(Optional.of(mock(BuildExecutionConfiguration.class)));
    return result;
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)

Example 2 with BuildDriverResult

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

the class AbstractDependentBuildTest method buildDriverResult.

private static BuildDriverResult buildDriverResult() {
    BuildDriverResult mock = mock(BuildDriverResult.class);
    when(mock.getBuildStatus()).thenReturn(BuildStatus.SUCCESS);
    return mock;
}
Also used : BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult)

Example 3 with BuildDriverResult

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

the class DefaultBuildExecutor method retrieveBuildDriverResults.

private Void retrieveBuildDriverResults(BuildExecutionSession buildExecutionSession, CompletedBuild completedBuild) {
    if (completedBuild == null) {
        userLog.warn("Unable to retrieve build driver results. Most likely due to cancelled operation.");
        return null;
    }
    try {
        buildExecutionSession.setStatus(BuildExecutionStatus.COLLECTING_RESULTS_FROM_BUILD_DRIVER);
        BuildDriverResult buildResult = completedBuild.getBuildResult();
        BuildStatus buildStatus = buildResult.getBuildStatus();
        buildExecutionSession.setBuildDriverResult(buildResult);
        if (buildStatus.completedSuccessfully()) {
            userLog.info("Build successfully completed.");
            buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_COMPLETED_SUCCESS);
        } else if (buildStatus.equals(BuildStatus.CANCELLED)) {
            userLog.info("Build has been canceled.");
            buildExecutionSession.setStatus(BuildExecutionStatus.CANCELLED);
        } else {
            userLog.warn("Build completed with errors.");
            buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_COMPLETED_WITH_ERROR);
        }
        return null;
    } catch (Throwable e) {
        throw new BuildProcessException(e, completedBuild.getRunningEnvironment());
    }
}
Also used : BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) BuildStatus(org.jboss.pnc.enums.BuildStatus) BuildProcessException(org.jboss.pnc.executor.exceptions.BuildProcessException)

Example 4 with BuildDriverResult

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

the class BuildExecutionCancellationTest method testBuild.

@Test(timeout = 3000)
public void testBuild() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException, ConfigurationParseException {
    BuildConfiguration buildConfiguration = configurationBuilder.build(1, "c1-java");
    Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
    ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
    DefaultBuildExecutor executor = new DefaultBuildExecutor(repositoryManagerFactory, buildDriverFactory, environmentDriverFactory, new Configuration(), null);
    Consumer<BuildExecutionStatusChangedEvent> cancel = (e) -> {
        if (BuildExecutionStatus.BUILD_WAITING.equals(e.getNewStatus())) {
            try {
                log.info("Cancelling build ...");
                Thread.sleep(100);
                executor.cancel(e.getBuildTaskId());
            } catch (ExecutorException | InterruptedException e0) {
                e0.printStackTrace();
            }
        }
    };
    runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper, cancel, executor);
    List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesBase();
    expectedStatuses.add(BuildExecutionStatus.CANCELLED);
    // check build statuses
    checkBuildStatuses(statusChangedEvents, expectedStatuses);
    // check results
    BuildResult buildResult = buildExecutionResultWrapper.get();
    BuildDriverResult buildDriverResult = buildResult.getBuildDriverResult().get();
    Assert.assertEquals(BuildStatus.CANCELLED, buildDriverResult.getBuildStatus());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildDriverException(org.jboss.pnc.spi.builddriver.exception.BuildDriverException) Arquillian(org.jboss.arquillian.junit.Arquillian) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) RepositoryManagerFactory(org.jboss.pnc.executor.servicefactories.RepositoryManagerFactory) Inject(javax.inject.Inject) HashSet(java.util.HashSet) ConfigurationParseException(org.jboss.pnc.common.json.ConfigurationParseException) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) ExecutorException(org.jboss.pnc.spi.executor.exceptions.ExecutorException) Logger(org.slf4j.Logger) BuildDriverFactory(org.jboss.pnc.executor.servicefactories.BuildDriverFactory) BuildResult(org.jboss.pnc.spi.BuildResult) Set(java.util.Set) Test(org.junit.Test) Configuration(org.jboss.pnc.common.Configuration) BuildStatus(org.jboss.pnc.enums.BuildStatus) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) Consumer(java.util.function.Consumer) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) List(java.util.List) Deployment(org.jboss.arquillian.container.test.api.Deployment) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Assert(org.junit.Assert) EnvironmentDriverFactory(org.jboss.pnc.executor.servicefactories.EnvironmentDriverFactory) BuildExecutionStatus(org.jboss.pnc.enums.BuildExecutionStatus) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Configuration(org.jboss.pnc.common.Configuration) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) BuildExecutionStatus(org.jboss.pnc.enums.BuildExecutionStatus) 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 5 with BuildDriverResult

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

the class DatastoreAdapterTest method storeResult.

private void storeResult(DatastoreAdapter datastoreAdapter, BuildStatus buildStatus, CompletionStatus completionStatus) throws DatastoreException {
    BuildDriverResult buildDriverResult = mock(BuildDriverResult.class);
    when(buildDriverResult.getBuildStatus()).thenReturn(buildStatus);
    when(buildDriverResult.getBuildLog()).thenReturn(BUILD_LOG);
    RepositoryManagerResult repositoryManagerResult = mock(RepositoryManagerResult.class);
    when(repositoryManagerResult.getCompletionStatus()).thenReturn(completionStatus);
    when(repositoryManagerResult.getLog()).thenReturn(REPOSITORY_MANAGER_LOG);
    BuildExecutionConfiguration buildExecutionConfiguration = mock(BuildExecutionConfiguration.class);
    BuildResult buildResult = new BuildResult(CompletionStatus.SUCCESS, Optional.empty(), "", Optional.of(buildExecutionConfiguration), Optional.of(buildDriverResult), Optional.of(repositoryManagerResult), Optional.of(EnvironmentDriverResultMock.mock()), Optional.of(RepourResultMock.mock()));
    BuildTask buildTask = mockBuildTask();
    datastoreAdapter.storeResult(buildTask, buildResult);
}
Also used : BuildResult(org.jboss.pnc.spi.BuildResult) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildExecutionConfiguration(org.jboss.pnc.spi.executor.BuildExecutionConfiguration) BuildDriverResult(org.jboss.pnc.spi.builddriver.BuildDriverResult) RepositoryManagerResult(org.jboss.pnc.spi.repositorymanager.RepositoryManagerResult)

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