use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImpl method peek.
@Override
public Optional<CeTask> peek() {
if (peekPaused.get()) {
return Optional.absent();
}
try (DbSession dbSession = dbClient.openSession(false)) {
Optional<CeQueueDto> dto = dbClient.ceQueueDao().peek(dbSession);
CeTask task = null;
if (dto.isPresent()) {
task = loadTask(dbSession, dto.get());
queueStatus.addInProgress();
}
return Optional.fromNullable(task);
}
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class CeLoggingTest method createCeTask.
private CeTask createCeTask(String uuid) {
CeTask ceTask = Mockito.mock(CeTask.class);
when(ceTask.getUuid()).thenReturn(uuid);
return ceTask;
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row.
@Test
public void submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row() {
CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, "PROJECT_1", "rob");
CeTask task = underTest.submit(taskSubmit);
verifyCeTask(taskSubmit, task, null);
verifyCeQueueDtoForTaskSubmit(taskSubmit);
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method cancel_pending.
@Test
public void cancel_pending() throws Exception {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
// ignore
boolean canceled = underTest.cancel("UNKNOWN");
assertThat(canceled).isFalse();
canceled = underTest.cancel(task.getUuid());
assertThat(canceled).isTrue();
Optional<CeActivityDto> activity = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), task.getUuid());
assertThat(activity.isPresent()).isTrue();
assertThat(activity.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method remove_saves_error_message_and_stacktrace_when_exception_is_provided.
@Test
public void remove_saves_error_message_and_stacktrace_when_exception_is_provided() {
Throwable error = new NullPointerException("Fake NPE to test persistence to DB");
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
Optional<CeTask> peek = underTest.peek();
underTest.remove(peek.get(), CeActivityDto.Status.FAILED, null, error);
Optional<CeActivityDto> activityDto = dbTester.getDbClient().ceActivityDao().selectByUuid(session, task.getUuid());
assertThat(activityDto).isPresent();
assertThat(activityDto.get().getErrorMessage()).isEqualTo(error.getMessage());
assertThat(activityDto.get().getErrorStacktrace()).isEqualToIgnoringWhitespace(stacktraceToString(error));
}
Aggregations