use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class MaterialDatabaseDependencyUpdaterTest method shouldUpdateServerHealthIfCheckFails.
@Test
public void shouldUpdateServerHealthIfCheckFails() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
RuntimeException runtimeException = new RuntimeException("Description of error");
Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name")), Pagination.pageStartingAt(0, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenThrow(runtimeException);
try {
updater.updateMaterial(dependencyMaterial);
fail("should have thrown exception " + runtimeException.getMessage());
} catch (Exception e) {
assertSame(e, runtimeException);
}
HealthStateType scope = HealthStateType.general(HealthStateScope.forMaterial(dependencyMaterial));
ServerHealthState state = ServerHealthState.error("Modification check failed for material: pipeline-name", "Description of error", scope);
Mockito.verify(healthService).update(state);
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class PipelineSchedulerIntegrationTest method shouldRemoveErrorLogForPipelineIfSchedulingSucceeded.
@Test
public void shouldRemoveErrorLogForPipelineIfSchedulingSucceeded() throws Exception {
serverHealthService.update(ServerHealthState.error("failed to connect to scm", "failed to connect to scm", HealthStateType.general(HealthStateScope.forPipeline(PIPELINE_MINGLE))));
ServerHealthState serverHealthState = scheduleHelper.manuallySchedulePipelineWithRealMaterials(PIPELINE_MINGLE, cruise);
assertThat(serverHealthState.isSuccess(), is(true));
assertCurrentErrorLogNumberIs(PIPELINE_MINGLE, 0);
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class HttpOperationResult method fullMessage.
public String fullMessage() {
ServerHealthState serverHealthState = serverHealthStateOperationResult.getServerHealthState();
String desc = serverHealthState == null ? BLANK_STRING : serverHealthState.getDescription();
return StringUtils.isBlank(desc) ? message : String.format("%s { %s }", message, desc);
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class ElasticAgentPluginServiceTest method shouldRetryCreateAgentForJobForWhichAssociatedPluginIsMissing.
@Test
public void shouldRetryCreateAgentForJobForWhichAssociatedPluginIsMissing() {
when(goConfigService.elasticJobStarvationThreshold()).thenReturn(0L);
JobPlan plan1 = plan(1, "missing");
service.createAgentsFor(new ArrayList<>(), Arrays.asList(plan1));
// invoke create again
service.createAgentsFor(Arrays.asList(plan1), Arrays.asList(plan1));
verifyZeroInteractions(createAgentQueue);
ArgumentCaptor<ServerHealthState> captorForHealthState = ArgumentCaptor.forClass(ServerHealthState.class);
verify(serverHealthService, times(2)).update(captorForHealthState.capture());
List<ServerHealthState> allValues = captorForHealthState.getAllValues();
for (ServerHealthState serverHealthState : allValues) {
assertThat(serverHealthState.getType().getScope().isForJob(), is(true));
assertThat(serverHealthState.getType().getScope().getScope(), is("pipeline-1/stage/job"));
}
}
use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.
the class ArtifactsDirHolder method onConfigChange.
public void onConfigChange(CruiseConfig newCruiseConfig) {
ServerHealthState serverHealthState;
if (isArtifactsDirChanged(newCruiseConfig)) {
serverHealthState = ServerHealthState.warning(ARTIFACTS_ROOT_CHANGED_MESSAGE, ARTIFACTS_ROOT_CHANGED_DESC, ARTIFACTS_ROOT_CHANGE_HEALTH_STATE_TYPE);
LOGGER.info("[Configuration Changed] Artifacts directory was changed.");
} else {
serverHealthState = ServerHealthState.success(ARTIFACTS_ROOT_CHANGE_HEALTH_STATE_TYPE);
}
serverHealthService.update(serverHealthState);
}
Aggregations