Search in sources :

Example 11 with ServerHealthState

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);
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) HealthStateType(com.thoughtworks.go.serverhealth.HealthStateType) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 12 with ServerHealthState

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);
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState)

Example 13 with ServerHealthState

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);
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState)

Example 14 with ServerHealthState

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"));
    }
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) Test(org.junit.Test)

Example 15 with ServerHealthState

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);
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState)

Aggregations

ServerHealthState (com.thoughtworks.go.serverhealth.ServerHealthState)25 Test (org.junit.Test)10 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)3 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)3 Material (com.thoughtworks.go.domain.materials.Material)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 StaleMaterialsOnBuildCause (com.thoughtworks.go.server.materials.StaleMaterialsOnBuildCause)2 Gson (com.google.gson.Gson)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 TimerConfig (com.thoughtworks.go.config.TimerConfig)1 Materials (com.thoughtworks.go.config.materials.Materials)1 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1