Search in sources :

Example 6 with ServerHealthState

use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.

the class ElasticAgentPluginServiceTest method shouldReportMissingElasticPlugin.

@Test
public void shouldReportMissingElasticPlugin() {
    JobPlan plan1 = plan(1, "missing");
    ArgumentCaptor<ServerHealthState> captorForHealthState = ArgumentCaptor.forClass(ServerHealthState.class);
    service.createAgentsFor(new ArrayList<>(), Arrays.asList(plan1));
    verify(serverHealthService).update(captorForHealthState.capture());
    ServerHealthState serverHealthState = captorForHealthState.getValue();
    assertThat(serverHealthState.getDescription(), is("Plugin [missing] associated with JobConfigIdentifier[pipeline-1:stage:job] is missing. Either the plugin is not installed or could not be registered. Please check plugins tab and server logs for more details."));
    assertThat(serverHealthState.getLogLevel(), is(HealthStateLevel.ERROR));
    assertThat(serverHealthState.getMessage(), is("Unable to find agent for JobConfigIdentifier[pipeline-1:stage:job]"));
    verifyZeroInteractions(createAgentQueue);
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) Test(org.junit.Test)

Example 7 with ServerHealthState

use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.

the class ServerHealthRequestProcessorTest method shouldAddDeserializedServerHealthMessages.

@Test
public void shouldAddDeserializedServerHealthMessages() {
    String requestBody = new Gson().toJson(asList(new PluginHealthMessage("warning", "message 1"), new PluginHealthMessage("error", "message 2")));
    GoApiResponse response = processor.process(descriptor, createRequest("1.0", requestBody));
    assertThat(response.responseCode()).isEqualTo(SUCCESS_RESPONSE_CODE);
    ArgumentCaptor<ServerHealthState> argumentCaptor = ArgumentCaptor.forClass(ServerHealthState.class);
    InOrder inOrder = inOrder(serverHealthService);
    inOrder.verify(serverHealthService, times(1)).removeByScope(HealthStateScope.fromPlugin(PLUGIN_ID));
    inOrder.verify(serverHealthService, times(2)).update(argumentCaptor.capture());
    assertThat(argumentCaptor.getAllValues().get(0).getDescription()).isEqualTo("message 1");
    assertThat(argumentCaptor.getAllValues().get(1).getDescription()).isEqualTo("message 2");
}
Also used : GoApiResponse(com.thoughtworks.go.plugin.api.response.GoApiResponse) InOrder(org.mockito.InOrder) Gson(com.google.gson.Gson) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState) Test(org.junit.Test)

Example 8 with ServerHealthState

use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.

the class DiskSpaceOperationResult method success.

public ServerHealthState success(HealthStateType healthStateType) {
    ServerHealthState state = ServerHealthState.success(healthStateType);
    serverHealthService.update(state);
    return state;
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState)

Example 9 with ServerHealthState

use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.

the class DiskSpaceOperationResult method warning.

public ServerHealthState warning(String message, String description, HealthStateType type) {
    ServerHealthState state = ServerHealthState.warning(message, description, type);
    serverHealthService.update(state);
    canContinue = false;
    return state;
}
Also used : ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState)

Example 10 with ServerHealthState

use of com.thoughtworks.go.serverhealth.ServerHealthState in project gocd by gocd.

the class TimedBuild method canProduce.

public void canProduce(PipelineConfig pipelineConfig, SchedulingCheckerService schedulingChecker, ServerHealthService serverHealthService, OperationResult operationResult) {
    schedulingChecker.canTriggerPipelineWithTimer(pipelineConfig, operationResult);
    if (!operationResult.canContinue()) {
        ServerHealthState serverHealthState = operationResult.getServerHealthState();
        LOGGER.info("'{}'  because '{}'", serverHealthState.getMessage(), serverHealthState.getDescription());
    } else {
        TimerConfig timer = pipelineConfig.getTimer();
        String timerSpec = timer == null ? "Missing timer spec" : timer.getTimerSpec();
        LOGGER.info("Timer scheduling pipeline '{}' using spec '{}'", pipelineConfig.name(), timerSpec);
    }
}
Also used : TimerConfig(com.thoughtworks.go.config.TimerConfig) 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