use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class CeWorkerCallableImplTest method display_start_at_debug_level_stop_at_error_level_for_console_if_DEBUG_is_enabled_and_task_failed.
@Test
public void display_start_at_debug_level_stop_at_error_level_for_console_if_DEBUG_is_enabled_and_task_failed() throws Exception {
logTester.setLevel(LoggerLevel.DEBUG);
CeTask ceTask = createCeTask("FooBar");
when(queue.peek()).thenReturn(Optional.of(ceTask));
taskProcessorRepository.setProcessorForTask(CeTaskTypes.REPORT, taskProcessor);
makeTaskProcessorFail(ceTask);
underTest.call();
List<String> logs = logTester.logs(LoggerLevel.INFO);
assertThat(logs).hasSize(1);
assertThat(logs.iterator().next()).contains(" | submitter=FooBar");
logs = logTester.logs(LoggerLevel.ERROR);
assertThat(logs).hasSize(2);
assertThat(logs.get(0)).isEqualTo("Failed to execute task " + ceTask.getUuid());
assertThat(logs.get(1)).contains(" | submitter=FooBar | time=");
assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class SubmitAction method handle.
@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
String organizationKey = wsRequest.getParam(PARAM_ORGANIZATION_KEY).emptyAsNull().or(defaultOrganizationProvider.get()::getKey);
String projectKey = wsRequest.mandatoryParam(PARAM_PROJECT_KEY);
String projectBranch = wsRequest.param(PARAM_PROJECT_BRANCH);
String projectName = StringUtils.defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey);
CeTask task;
try (InputStream report = new BufferedInputStream(wsRequest.paramAsInputStream(PARAM_REPORT_DATA))) {
task = reportSubmitter.submit(organizationKey, projectKey, projectBranch, projectName, report);
}
WsCe.SubmitResponse submitResponse = WsCe.SubmitResponse.newBuilder().setTaskId(task.getUuid()).setProjectId(task.getComponentUuid()).build();
WsUtils.writeProtobuf(submitResponse, wsRequest, wsResponse);
}
Aggregations