use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeQueueImplTest method submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_creates_task_without_component_when_there_is_a_pending_task_without_component.
@Test
public void submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_creates_task_without_component_when_there_is_a_pending_task_without_component() {
CeTaskSubmit taskSubmit = createTaskSubmit("no_component");
CeQueueDto dto = insertPendingInQueue(null);
Optional<CeTask> task = underTest.submit(taskSubmit, UNIQUE_QUEUE_PER_MAIN_COMPONENT);
assertThat(task).isNotEmpty();
assertThat(db.getDbClient().ceQueueDao().selectAllInAscOrder(db.getSession())).extracting(CeQueueDto::getUuid).containsOnly(dto.getUuid(), task.get().getUuid());
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeQueueImplTest method submit_without_UNIQUE_QUEUE_PER_MAIN_COMPONENT_creates_task_when_there_is_many_pending_task_for_same_main_component.
@Test
public void submit_without_UNIQUE_QUEUE_PER_MAIN_COMPONENT_creates_task_when_there_is_many_pending_task_for_same_main_component() {
String mainComponentUuid = randomAlphabetic(5);
CeTaskSubmit taskSubmit = createTaskSubmit("with_component", newComponent(mainComponentUuid), null);
String[] uuids = IntStream.range(0, 2 + new Random().nextInt(5)).mapToObj(i -> insertPendingInQueue(newComponent(mainComponentUuid))).map(CeQueueDto::getUuid).toArray(String[]::new);
CeTask task = underTest.submit(taskSubmit);
assertThat(db.getDbClient().ceQueueDao().selectAllInAscOrder(db.getSession())).extracting(CeQueueDto::getUuid).hasSize(uuids.length + 1).contains(uuids).contains(task.getUuid());
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class ProjectExportTaskProcessor method processProjectExport.
private void processProjectExport(CeTask task) {
CeTask.Component exportComponent = mandatoryComponent(task, PROJECT_EXPORT);
failIfNotMain(exportComponent, task);
ProjectDescriptor projectExportDescriptor = new ProjectDescriptor(exportComponent.getUuid(), mandatoryKey(exportComponent), mandatoryName(exportComponent));
try (TaskContainer taskContainer = new TaskContainerImpl(componentContainer, new ProjectExportContainerPopulator(projectExportDescriptor))) {
taskContainer.bootup();
taskContainer.getComponentByType(ProjectExportProcessor.class).process();
}
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method createCeTask.
private CeTask createCeTask(String projectKey) {
CeTask res = mock(CeTask.class);
Optional<CeTask.Component> component = Optional.of(new CeTask.Component(projectKey + "_uuid", projectKey, projectKey + "_name"));
when(res.getComponent()).thenReturn(component);
when(res.getMainComponent()).thenReturn(component);
return res;
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_MessageException_if_main_projectKey_is_null_in_CE_task.
@Test
public void execute_fails_with_MessageException_if_main_projectKey_is_null_in_CE_task() {
CeTask res = mock(CeTask.class);
Optional<CeTask.Component> component = Optional.of(new CeTask.Component("main_prj_uuid", null, null));
when(res.getComponent()).thenReturn(component);
when(res.getMainComponent()).thenReturn(component);
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
ComputationStep underTest = createStep(res);
assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(MessageException.class).hasMessage("Compute Engine task main component key is null. Project with UUID main_prj_uuid must have been deleted since report was uploaded. Can not proceed.");
}
Aggregations