Search in sources :

Example 31 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class PipelineActiveCheckerTest method shouldFailIfPipelineIsActive.

@Test
public void shouldFailIfPipelineIsActive() {
    when(service.isAnyStageActiveForPipeline(pipelineIdentifier)).thenReturn(true);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    checker.check(result);
    assertThat(result.getServerHealthState().isSuccess(), is(false));
    assertThat(result.getServerHealthState().getDescription(), is("Pipeline[name='cruise', counter='1', label='label-1'] is still in progress"));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.jupiter.api.Test)

Example 32 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class ScheduleCheckListener method onMessage.

@Override
public void onMessage(ScheduleCheckMessage message) {
    LOGGER.debug("ScheduleCheckMessage for {} is received", message.getPipelineName());
    try {
        schedulingPerformanceLogger.pickedUpPipelineForScheduleCheck(message.trackingId(), message.getPipelineName());
        producer.autoSchedulePipeline(message.getPipelineName(), new ServerHealthStateOperationResult(), message.trackingId());
        LOGGER.debug("Finished checking for pipeline {}", message.getPipelineName());
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        checkCompletedTopic.post(new ScheduleCheckCompletedMessage(message.getPipelineName(), message.trackingId()));
        schedulingPerformanceLogger.postingMessageAboutScheduleCheckCompletion(message.trackingId(), message.getPipelineName());
        LOGGER.debug("Finished posting materialCheckCompletedMessage for pipeline {}", message.getPipelineName());
    }
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)

Example 33 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class ScheduleServiceIntegrationTest method manualSchedule.

private Pipeline manualSchedule(String pipelineName) {
    final HashMap<String, String> revisions = new HashMap<>();
    final HashMap<String, String> environmentVariables = new HashMap<>();
    final HashMap<String, String> secureEnvironmentVariables = new HashMap<>();
    buildCauseProducer.manualProduceBuildCauseAndSave(pipelineName, new Username(new CaseInsensitiveString("some user name")), new ScheduleOptions(revisions, environmentVariables, secureEnvironmentVariables), new ServerHealthStateOperationResult());
    scheduleService.autoSchedulePipelinesFromRequestBuffer();
    return pipelineService.mostRecentFullPipelineByName(pipelineName);
}
Also used : ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) Username(com.thoughtworks.go.server.domain.Username) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)

Example 34 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class SchedulingCheckerServiceIntegrationTest method shouldNotScheduleLockedPipelineIfAnyStageIsActiveInAnyPipeline.

@Test
public void shouldNotScheduleLockedPipelineIfAnyStageIsActiveInAnyPipeline() throws Exception {
    configFileHelper.lockPipeline(pipelineFixture.pipelineName);
    Pipeline pipeline = pipelineFixture.schedulePipeline();
    firstStagePassedAndSecondStageBuilding(pipeline);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    schedulingChecker.canTriggerManualPipeline(pipeline.getName(), APPROVED_USER, result);
    assertThat(result.getServerHealthState().isSuccess(), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString("is locked"));
    assertThat(result.getServerHealthState().getDescription(), containsString(pipeline.getName()));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.jupiter.api.Test)

Example 35 with ServerHealthStateOperationResult

use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.

the class SchedulingCheckerServiceIntegrationTest method shouldNotPassCheckingIfDiskSpaceIsFullForManualTrigger.

@Test
public void shouldNotPassCheckingIfDiskSpaceIsFullForManualTrigger() throws Exception {
    String limit = diskSpaceSimulator.simulateDiskFull();
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    assertThat(schedulingChecker.canManuallyTrigger(pipelineFixture.pipelineConfig(), APPROVED_USER, result), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString(String.format("GoCD has less than %sb of disk space", limit)));
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Matchers.containsString(org.hamcrest.Matchers.containsString) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.jupiter.api.Test)

Aggregations

ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)89 Test (org.junit.jupiter.api.Test)78 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)28 ScheduleOptions (com.thoughtworks.go.server.scheduling.ScheduleOptions)17 HashMap (java.util.HashMap)17 Pipeline (com.thoughtworks.go.domain.Pipeline)16 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)12 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)12 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)11 Modification (com.thoughtworks.go.domain.materials.Modification)10 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)8 Username (com.thoughtworks.go.server.domain.Username)8 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)6 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)6 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)6 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)6 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5 Materials (com.thoughtworks.go.config.materials.Materials)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)5