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));
}
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"));
}
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));
}
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()));
}
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;
}
Aggregations