Search in sources :

Example 81 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldNotPassCheckingIfDiskSpaceIsFullForRerun.

@Test
public void shouldNotPassCheckingIfDiskSpaceIsFullForRerun() throws Exception {
    String limit = diskSpaceSimulator.simulateDiskFull();
    String pipelineName = pipelineFixture.pipelineName;
    String label = "LATEST";
    String stageName = CaseInsensitiveString.str(pipelineFixture.devStage().name());
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    configFileHelper.addAuthorizedUserForStage(pipelineName, stageName, APPROVED_USER);
    assertThat(schedulingChecker.canScheduleStage(new PipelineIdentifier(pipelineName, 1, label), stageName, APPROVED_USER, result), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString(String.format("GoCD has less than %sb of disk space", limit)));
}
Also used : PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) 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)

Example 82 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldNotPassCheckingWhenUserHasNoPermissionForRerun.

@Test
public void shouldNotPassCheckingWhenUserHasNoPermissionForRerun() throws Exception {
    Pipeline pipeline = pipelineFixture.createdPipelineWithAllStagesPassed();
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    assertThat(schedulingChecker.canScheduleStage(pipeline.getIdentifier(), pipelineFixture.ftStage, "gli", result), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString("does not have permission"));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.jupiter.api.Test)

Example 83 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldNotPassCheckingIfPipelineIsPausedForRerun.

@Test
public void shouldNotPassCheckingIfPipelineIsPausedForRerun() throws Exception {
    Pipeline pipeline = pipelineFixture.createdPipelineWithAllStagesPassed();
    Username userName = new Username(new CaseInsensitiveString("A humble developer"));
    configFileHelper.setOperatePermissionForGroup(pipelineFixture.groupName, userName.getUsername().toString(), APPROVED_USER);
    pipelinePauseService.pause(pipeline.getName(), "Upgrade scheduled", userName);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    assertThat(schedulingChecker.canScheduleStage(pipeline.getIdentifier(), pipelineFixture.ftStage, APPROVED_USER, result), is(false));
    assertThat(result.getServerHealthState().getDescription(), containsString(pipeline.getName() + " is paused"));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.jupiter.api.Test)

Example 84 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldReturnSuccessIfTheStageHasAllowOnlyOnSuccessUnSetAndPreviousStageFailed.

@Test
public void shouldReturnSuccessIfTheStageHasAllowOnlyOnSuccessUnSetAndPreviousStageFailed() {
    configFileHelper.lockPipeline(pipelineFixture.pipelineName);
    Pipeline pipeline = pipelineFixture.schedulePipeline();
    firstStageFailedAndSecondStageNotStarted(pipeline);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    schedulingChecker.canScheduleStage(pipeline.getIdentifier(), pipelineFixture.ftStage, APPROVED_USER, result);
    ServerHealthState serverHealthState = result.getServerHealthState();
    assertThat(serverHealthState.isSuccess(), is(true));
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.jupiter.api.Test)

Example 85 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldFailCheckIfTheStageHasAllowOnlyOnSuccessSetAndPreviousStageFailed.

@Test
public void shouldFailCheckIfTheStageHasAllowOnlyOnSuccessSetAndPreviousStageFailed() {
    configFileHelper.configureStageAsManualApproval(pipelineFixture.pipelineName, pipelineFixture.ftStage, true);
    configFileHelper.addAuthorizedUserForStage(pipelineFixture.pipelineName, pipelineFixture.ftStage, APPROVED_USER);
    configFileHelper.lockPipeline(pipelineFixture.pipelineName);
    Pipeline pipeline = pipelineFixture.schedulePipeline();
    firstStageFailedAndSecondStageNotStarted(pipeline);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    schedulingChecker.canScheduleStage(pipeline.getIdentifier(), pipelineFixture.ftStage, APPROVED_USER, result);
    ServerHealthState serverHealthState = result.getServerHealthState();
    assertThat(serverHealthState.isSuccess(), is(false));
    assertThat(serverHealthState.getDescription(), is("Cannot schedule ft as the previous stage dev has Failed!"));
    assertThat(serverHealthState.getMessage(), is("Cannot schedule ft as the previous stage dev has Failed!"));
    assertThat(serverHealthState.getType(), is(HealthStateType.forbidden()));
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Pipeline(com.thoughtworks.go.domain.Pipeline) 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