use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method peek_is_paused_then_resumed.
@Test
public void peek_is_paused_then_resumed() {
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
underTest.pauseWorkers();
Optional<CeTask> peek = underTest.peek(WORKER_UUID_1, true);
assertThat(peek).isEmpty();
underTest.resumeWorkers();
peek = underTest.peek(WORKER_UUID_1, true);
assertThat(peek).isPresent();
assertThat(peek.get().getUuid()).isEqualTo(task.getUuid());
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method remove_saves_error_when_TypedMessageException_is_provided.
@Test
public void remove_saves_error_when_TypedMessageException_is_provided() {
Throwable error = new TypedExceptionImpl("aType", "aMessage");
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
Optional<CeTask> peek = underTest.peek(WORKER_UUID_1, true);
underTest.remove(peek.get(), CeActivityDto.Status.FAILED, null, error);
CeActivityDto activityDto = db.getDbClient().ceActivityDao().selectByUuid(session, task.getUuid()).get();
assertThat(activityDto.getErrorType()).isEqualTo("aType");
assertThat(activityDto.getErrorMessage()).isEqualTo("aMessage");
assertThat(activityDto.getErrorStacktrace()).isEqualToIgnoringWhitespace(stacktraceToString(error));
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method remove_updates_queueStatus_success_even_if_task_does_not_exist_in_DB.
@Test
public void remove_updates_queueStatus_success_even_if_task_does_not_exist_in_DB() {
CEQueueStatus queueStatus = mock(CEQueueStatus.class);
CeTask task = submit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"));
db.getDbClient().ceQueueDao().deleteByUuid(db.getSession(), task.getUuid());
db.commit();
InternalCeQueueImpl underTest = new InternalCeQueueImpl(system2, db.getDbClient(), null, queueStatus, null);
try {
underTest.remove(task, CeActivityDto.Status.SUCCESS, null, null);
fail("remove should have thrown a IllegalStateException");
} catch (IllegalStateException e) {
verify(queueStatus).addSuccess(anyLong());
}
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeTaskInterrupterWorkerExecutionListenerTest method onEnd_delegates_to_ceTaskInterrupter_onEnd.
@Test
public void onEnd_delegates_to_ceTaskInterrupter_onEnd() {
CeTask ceTask = mock(CeTask.class);
CeActivityDto.Status randomStatus = CeActivityDto.Status.values()[new Random().nextInt(CeActivityDto.Status.values().length)];
underTest.onEnd(ceTask, randomStatus, Duration.of(1, ChronoUnit.SECONDS), null, null);
verify(ceTaskInterrupter).onEnd(same(ceTask));
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeTaskInterrupterWorkerExecutionListenerTest method onStart_delegates_to_ceTaskInterrupter_onStart.
@Test
public void onStart_delegates_to_ceTaskInterrupter_onStart() {
CeTask ceTask = mock(CeTask.class);
underTest.onStart(ceTask);
verify(ceTaskInterrupter).onStart(same(ceTask));
}
Aggregations