use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeQueueImplTest method submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row.
@Test
public void submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row() {
String componentUuid = randomAlphabetic(3);
String mainComponentUuid = randomAlphabetic(4);
CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, new Component(componentUuid, mainComponentUuid), "submitter uuid");
UserDto userDto = db.getDbClient().userDao().selectByUuid(db.getSession(), taskSubmit.getSubmitterUuid());
CeTask task = underTest.submit(taskSubmit);
verifyCeTask(taskSubmit, task, null, userDto);
verifyCeQueueDtoForTaskSubmit(taskSubmit);
}
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_one_pending_task_for_same_main_component.
@Test
public void submit_without_UNIQUE_QUEUE_PER_MAIN_COMPONENT_creates_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));
CeTask task = underTest.submit(taskSubmit);
assertThat(db.getDbClient().ceQueueDao().selectAllInAscOrder(db.getSession())).extracting(CeQueueDto::getUuid).containsOnly(dto.getUuid(), task.getUuid());
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeQueueImplTest method cancelAll_pendings_but_not_in_progress.
@Test
public void cancelAll_pendings_but_not_in_progress() {
CeTask inProgressTask = submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(12)));
CeTask pendingTask1 = submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(12)));
CeTask pendingTask2 = submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(12)));
db.getDbClient().ceQueueDao().peek(session, WORKER_UUID, false, false);
int canceledCount = underTest.cancelAll();
assertThat(canceledCount).isEqualTo(2);
Optional<CeActivityDto> ceActivityInProgress = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), pendingTask1.getUuid());
assertThat(ceActivityInProgress.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
Optional<CeActivityDto> ceActivityPending1 = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), pendingTask2.getUuid());
assertThat(ceActivityPending1.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
Optional<CeActivityDto> ceActivityPending2 = db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), inProgressTask.getUuid());
assertThat(ceActivityPending2).isNotPresent();
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeQueueImplTest method fail_throws_exception_if_task_is_pending.
@Test
public void fail_throws_exception_if_task_is_pending() {
CeTask task = submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(12)));
CeQueueDto queueDto = db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), task.getUuid()).get();
Throwable thrown = catchThrowable(() -> underTest.fail(db.getSession(), queueDto, "TIMEOUT", "Failed on timeout"));
assertThat(thrown).isInstanceOf(IllegalStateException.class).hasMessage("Task is not in-progress and can't be marked as failed [uuid=" + task.getUuid() + "]");
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class IgnoreOrphanBranchStepTest method fail_if_missing_main_component_in_task.
@Test
public void fail_if_missing_main_component_in_task() {
CeTask ceTask = new CeTask.Builder().setType("type").setUuid("uuid").setComponent(null).setMainComponent(null).build();
IgnoreOrphanBranchStep underTest = new IgnoreOrphanBranchStep(ceTask, dbClient);
assertThatThrownBy(() -> underTest.execute(() -> null)).isInstanceOf(UnsupportedOperationException.class).hasMessage("main component not found in task");
}
Aggregations