use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method test_remove.
@Test
public void test_remove() {
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
Optional<CeTask> peek = underTest.peek(WORKER_UUID_1, true);
underTest.remove(peek.get(), CeActivityDto.Status.SUCCESS, null, null);
// queue is empty
assertThat(db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), task.getUuid())).isNotPresent();
assertThat(underTest.peek(WORKER_UUID_2, true)).isNotPresent();
// available in history
Optional<CeActivityDto> history = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), task.getUuid());
assertThat(history).isPresent();
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.SUCCESS);
assertThat(history.get().getIsLast()).isTrue();
assertThat(history.get().getAnalysisUuid()).isNull();
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class ExportAction method handle.
@Override
public void handle(Request request, Response response) {
String projectKey = request.mandatoryParam(PARAMETER_PROJECT_KEY);
projectDumpWsSupport.verifyAdminOfProjectByKey(projectKey);
CeTask task = exportSubmitter.submitProjectExport(projectKey, userSession.getUuid());
try (JsonWriter writer = response.newJsonWriter()) {
CeTask.Component component = task.getComponent().get();
writer.beginObject().prop("taskId", task.getUuid()).prop("projectId", component.getUuid()).prop("projectKey", component.getKey().orElse(null)).prop("projectName", component.getName().orElse(null)).endObject().close();
}
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CancelActionTest method createTaskSubmit.
private CeQueueDto createTaskSubmit(@Nullable ComponentDto componentDto) {
CeTaskSubmit.Builder submission = queue.prepareSubmit().setType(CeTaskTypes.REPORT).setSubmitterUuid(null).setCharacteristics(emptyMap());
if (componentDto != null) {
submission.setComponent(CeTaskSubmit.Component.fromDto(componentDto));
}
CeTask task = queue.submit(submission.build());
return db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), task.getUuid()).get();
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeQueueImpl method massSubmit.
@Override
public List<CeTask> massSubmit(Collection<CeTaskSubmit> submissions, SubmitOption... options) {
if (submissions.isEmpty()) {
return Collections.emptyList();
}
try (DbSession dbSession = dbClient.openSession(false)) {
List<CeQueueDto> taskDtos = submissions.stream().filter(filterBySubmitOptions(options, submissions, dbSession)).map(submission -> addToQueueInDb(dbSession, submission)).collect(Collectors.toList());
List<CeTask> tasks = loadTasks(dbSession, taskDtos);
dbSession.commit();
return tasks;
}
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeQueueImplTest method submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_does_not_create_task_when_there_is_one_pending_task_for_same_main_component.
@Test
public void submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_does_not_create_task_when_there_is_one_pending_task_for_same_main_component() {
String mainComponentUuid = randomAlphabetic(5);
CeTaskSubmit taskSubmit = createTaskSubmit("with_component", newComponent(mainComponentUuid), null);
CeQueueDto dto = insertPendingInQueue(newComponent(mainComponentUuid));
Optional<CeTask> task = underTest.submit(taskSubmit, UNIQUE_QUEUE_PER_MAIN_COMPONENT);
assertThat(task).isEmpty();
assertThat(db.getDbClient().ceQueueDao().selectAllInAscOrder(db.getSession())).extracting(CeQueueDto::getUuid).containsOnly(dto.getUuid());
}
Aggregations