Search in sources :

Example 36 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldScheduleANewstageInALockedPipeline.

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

Example 37 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldNotPassCheckingIfPipelineIsPausedForManualTrigger.

@Test
public void shouldNotPassCheckingIfPipelineIsPausedForManualTrigger() 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.canManuallyTrigger(pipelineFixture.pipelineConfig(), 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 38 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldSkipSecurityCheckingForCruiseUserWhenTimerTriggersPipeline.

@Test
public void shouldSkipSecurityCheckingForCruiseUserWhenTimerTriggersPipeline() throws Exception {
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    schedulingChecker.canTriggerPipelineWithTimer(goConfigService.getAllPipelineConfigs().get(0), result);
    assertThat(result.canContinue(), is(true));
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) Test(org.junit.jupiter.api.Test)

Example 39 with ServerHealthStateOperationResult

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

the class SchedulingCheckerServiceIntegrationTest method shouldNotScheduleStageInLockedPipelineIfAnyStageIsActiveInAnyPipeline.

@Test
public void shouldNotScheduleStageInLockedPipelineIfAnyStageIsActiveInAnyPipeline() throws Exception {
    Pipeline completed = pipelineFixture.createdPipelineWithAllStagesPassed();
    Pipeline pipeline = pipelineFixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
    configFileHelper.lockPipeline(pipeline.getName());
    // to ensure locking happens(fixture uses the dao to directly save it to the db, hence lock is not taken)
    pipelineService.save(pipeline);
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    configFileHelper.addAuthorizedUserForStage(pipeline.getName(), pipelineFixture.devStage, APPROVED_USER);
    schedulingChecker.canScheduleStage(completed.getIdentifier(), pipelineFixture.devStage, 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 40 with ServerHealthStateOperationResult

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

the class ScheduleService method canRun.

public boolean canRun(PipelineIdentifier pipelineIdentifier, String stageName, String username, boolean hasPreviousStageBeenScheduled) {
    if (!goConfigService.hasStageConfigNamed(pipelineIdentifier.getName(), stageName)) {
        return false;
    }
    ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
    schedulingChecker.canScheduleStage(pipelineIdentifier, stageName, username, result);
    return result.getServerHealthState().isSuccess() && hasPreviousStageBeenScheduled;
}
Also used : ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)

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