use of org.sonar.db.ce.CeQueueDto 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.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueImplTest method submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_does_not_create_task_when_there_is_one_pending_task_for_same_main_component.
@Test
public void submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_does_not_create_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));
Optional<CeTask> task = underTest.submit(taskSubmit, UNIQUE_QUEUE_PER_MAIN_COMPONENT);
assertThat(task).isEmpty();
assertThat(db.getDbClient().ceQueueDao().selectAllInAscOrder(db.getSession())).extracting(CeQueueDto::getUuid).containsOnly(dto.getUuid());
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueImplTest method massSubmit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_does_not_create_task_when_there_is_one_pending_task_for_same_main_component.
@Test
public void massSubmit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_does_not_create_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));
List<CeTask> tasks = underTest.massSubmit(of(taskSubmit), UNIQUE_QUEUE_PER_MAIN_COMPONENT);
assertThat(tasks).isEmpty();
assertThat(db.getDbClient().ceQueueDao().selectAllInAscOrder(db.getSession())).extracting(CeQueueDto::getUuid).containsOnly(dto.getUuid());
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CeQueueImplTest method submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_creates_task_when_there_is_a_pending_task_for_another_main_component.
@Test
public void submit_with_UNIQUE_QUEUE_PER_MAIN_COMPONENT_creates_task_when_there_is_a_pending_task_for_another_main_component() {
String mainComponentUuid = randomAlphabetic(5);
String otherMainComponentUuid = randomAlphabetic(6);
CeTaskSubmit taskSubmit = createTaskSubmit("with_component", newComponent(mainComponentUuid), null);
CeQueueDto dto = insertPendingInQueue(newComponent(otherMainComponentUuid));
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.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CancelActionTest method cancel_pending_task_on_project.
@Test
public void cancel_pending_task_on_project() {
logInAsSystemAdministrator();
ComponentDto project = db.components().insertPrivateProject();
CeQueueDto queue = createTaskSubmit(project);
tester.newRequest().setParam("id", queue.getUuid()).execute();
assertThat(db.getDbClient().ceActivityDao().selectByUuid(db.getSession(), queue.getUuid()).get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
}
Aggregations