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