Search in sources :

Example 26 with CeTask

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();
}
Also used : CeTask(org.sonar.ce.queue.CeTask) Test(org.junit.Test)

Example 27 with CeTask

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);
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) WsCe(org.sonarqube.ws.WsCe) CeTask(org.sonar.ce.queue.CeTask)

Aggregations

CeTask (org.sonar.ce.queue.CeTask)27 Test (org.junit.Test)22 CeActivityDto (org.sonar.db.ce.CeActivityDto)6 CeTaskSubmit (org.sonar.ce.queue.CeTaskSubmit)5 ComponentDto (org.sonar.db.component.ComponentDto)2 ComputationStep (org.sonar.server.computation.task.step.ComputationStep)2 BufferedInputStream (java.io.BufferedInputStream)1 InputStream (java.io.InputStream)1 Before (org.junit.Before)1 DbSession (org.sonar.db.DbSession)1 CeQueueDto (org.sonar.db.ce.CeQueueDto)1 WsCe (org.sonarqube.ws.WsCe)1