use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method setUp.
@Before
public void setUp() {
CeTask defaultOrgCeTask = createCeTask(PROJECT_KEY);
underTest = createStep(defaultOrgCeTask);
project = db.components().insertPublicProject(p -> p.setDbKey(PROJECT_KEY));
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_ISE_if_component_is_null_in_CE_task.
@Test
public void execute_fails_with_ISE_if_component_is_null_in_CE_task() {
CeTask res = mock(CeTask.class);
when(res.getComponent()).thenReturn(Optional.empty());
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
ComputationStep underTest = createStep(res);
assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(IllegalStateException.class).hasMessage("component missing on ce task");
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class ReportAnalysisFailureNotificationExecutionListener method onEnd.
@Override
public void onEnd(CeTask ceTask, CeActivityDto.Status status, Duration duration, @Nullable CeTaskResult taskResult, @Nullable Throwable error) {
if (status == CeActivityDto.Status.SUCCESS) {
return;
}
String projectUuid = ceTask.getComponent().map(CeTask.Component::getUuid).orElse(null);
if (!CeTaskTypes.REPORT.equals(ceTask.getType()) || projectUuid == null) {
return;
}
if (notificationService.hasProjectSubscribersForTypes(projectUuid, singleton(ReportAnalysisFailureNotification.class))) {
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto projectDto = dbClient.componentDao().selectOrFailByUuid(dbSession, projectUuid);
checkScopeAndQualifier(projectDto);
CeActivityDto ceActivityDto = dbClient.ceActivityDao().selectByUuid(dbSession, ceTask.getUuid()).orElseThrow(() -> new RowNotFoundException(format("CeActivity with uuid '%s' not found", ceTask.getUuid())));
ReportAnalysisFailureNotificationBuilder taskFailureNotification = buildNotification(ceActivityDto, projectDto, error);
ReportAnalysisFailureNotification notification = taskFailureNotificationSerializer.toNotification(taskFailureNotification);
notificationService.deliverEmails(singleton(notification));
// compatibility with old API
notificationService.deliver(notification);
}
}
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImpl method peek.
@Override
public Optional<CeTask> peek(String workerUuid, boolean excludeIndexationJob) {
requireNonNull(workerUuid, "workerUuid can't be null");
if (computeEngineStatus.getStatus() != ComputeEngineStatus.Status.STARTED || getWorkersPauseStatus() != WorkersPauseStatus.RESUMED) {
return Optional.empty();
}
try (DbSession dbSession = dbClient.openSession(false)) {
CeQueueDao ceQueueDao = dbClient.ceQueueDao();
int i = ceQueueDao.resetToPendingForWorker(dbSession, workerUuid);
if (i > 0) {
dbSession.commit();
LOG.debug("{} in progress tasks reset for worker uuid {}", i, workerUuid);
}
Optional<CeQueueDto> opt = findPendingTask(workerUuid, dbSession, ceQueueDao, excludeIndexationJob);
if (!opt.isPresent()) {
return Optional.empty();
}
CeQueueDto taskDto = opt.get();
Map<String, ComponentDto> componentsByUuid = loadComponentDtos(dbSession, taskDto);
Map<String, String> characteristics = dbClient.ceTaskCharacteristicsDao().selectByTaskUuids(dbSession, singletonList(taskDto.getUuid())).stream().collect(uniqueIndex(CeTaskCharacteristicDto::getKey, CeTaskCharacteristicDto::getValue));
CeTask task = convertToTask(dbSession, taskDto, characteristics, ofNullable(taskDto.getComponentUuid()).map(componentsByUuid::get).orElse(null), ofNullable(taskDto.getMainComponentUuid()).map(componentsByUuid::get).orElse(null));
queueStatus.addInProgress();
return Optional.of(task);
}
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class AuditPurgeTaskProcessorTest method newContainerPopulator.
@Test
public void newContainerPopulator() {
CeTask task = new CeTask.Builder().setUuid("TASK_UUID").setType("Type").build();
AuditPurgeTaskProcessor.newContainerPopulator(task).populateContainer(container);
Mockito.verify(container, Mockito.times(5)).add(any());
}
Aggregations