use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class DiskSpaceFullCheckerTest method shouldNotSendMoreThanOneEmail.
@Test
public void shouldNotSendMoreThanOneEmail() {
CruiseConfig cruiseConfig = simulateFullDisk();
ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
fullChecker.check(result);
assertThat(result.canContinue(), is(false));
verify(sender).sendEmail(any(SendEmailMessage.class));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class DiskSpaceFullCheckerTest method shouldReturnTrueIfTheArtifactFolderHasSizeLimit.
@Test
public void shouldReturnTrueIfTheArtifactFolderHasSizeLimit() {
new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_FULL_SIZE_LIMIT, "1M");
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
fullChecker.check(result);
assertThat(result.canContinue(), is(true));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class PipelineHistoryService method populateCanRunStatus.
private void populateCanRunStatus(Username username, PipelineInstanceModel pipelineInstanceModel) {
for (StageInstanceModel stageHistoryItem : pipelineInstanceModel.getStageHistory()) {
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
boolean canRun = scheduleService.canRun(pipelineInstanceModel.getPipelineIdentifier(), stageHistoryItem.getName(), CaseInsensitiveString.str(username.getUsername()), pipelineInstanceModel.hasPreviousStageBeenScheduled(stageHistoryItem.getName()), result);
stageHistoryItem.setCanRun(canRun);
if (!canRun && result.getServerHealthState() != null && result.getServerHealthState().getType().equals(HealthStateType.forbidden())) {
stageHistoryItem.setErrorMessage(result.getServerHealthState().getMessage());
}
}
populatePipelineCanRunStatus(username, pipelineInstanceModel);
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class PipelineHistoryService method getPipelineStatus.
public PipelineStatusModel getPipelineStatus(String pipelineName, String username, OperationResult result) {
PipelineConfig pipelineConfig = goConfigService.currentCruiseConfig().getPipelineConfigByName(new CaseInsensitiveString(pipelineName));
if (pipelineConfig == null) {
result.notFound("Not Found", "Pipeline not found", HealthStateType.general(HealthStateScope.GLOBAL));
return null;
}
if (!securityService.hasViewPermissionForPipeline(Username.valueOf(username), pipelineName)) {
result.forbidden("Forbidden", NOT_AUTHORIZED_TO_VIEW_PIPELINE, HealthStateType.general(HealthStateScope.forPipeline(pipelineName)));
return null;
}
PipelinePauseInfo pipelinePauseInfo = pipelinePauseService.pipelinePauseInfo(pipelineName);
boolean isCurrentlyLocked = pipelineLockService.isLocked(pipelineName);
boolean isSchedulable = schedulingCheckerService.canManuallyTrigger(pipelineConfig, username, new ServerHealthStateOperationResult());
return new PipelineStatusModel(isCurrentlyLocked, isSchedulable, pipelinePauseInfo);
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class SchedulingCheckerService method canAutoTriggerConsumer.
public boolean canAutoTriggerConsumer(PipelineConfig pipelineConfig) {
OperationResult result = new ServerHealthStateOperationResult();
String pipelineName = CaseInsensitiveString.str(pipelineConfig.name());
String stageName = CaseInsensitiveString.str(pipelineConfig.getFirstStageConfig().name());
SchedulingChecker checker = buildScheduleCheckers(asList(new PipelinePauseChecker(pipelineName, pipelinePauseService), new PipelineLockChecker(pipelineName, pipelineLockService), new StageActiveChecker(pipelineName, stageName, stageService)));
checker.check(result);
return result.getServerHealthState().isSuccess();
}
Aggregations