use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class CancelActionTest method throw_ForbiddenException_if_not_enough_permission_when_canceling_task_on_project.
@Test
public void throw_ForbiddenException_if_not_enough_permission_when_canceling_task_on_project() {
userSession.logIn().setNonSystemAdministrator();
ComponentDto project = db.components().insertPrivateProject();
CeQueueDto queue = createTaskSubmit(project);
assertThatThrownBy(() -> {
tester.newRequest().setParam("id", queue.getUuid()).execute();
}).isInstanceOf(ForbiddenException.class).hasMessage("Insufficient privileges");
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class AnalysisStatusActionTest method insertActivity.
private CeActivityDto insertActivity(String taskUuid, ComponentDto component, CeActivityDto.Status status, @Nullable SnapshotDto analysis, String taskType) {
CeQueueDto queueDto = new CeQueueDto();
queueDto.setTaskType(taskType);
queueDto.setComponent(component);
queueDto.setUuid(taskUuid);
CeActivityDto activityDto = new CeActivityDto(queueDto);
activityDto.setStatus(status);
activityDto.setExecutionTimeMs(500L);
activityDto.setAnalysisUuid(analysis == null ? null : analysis.getUuid());
activityDto.setExecutedAt((long) counter++);
activityDto.setTaskType(taskType);
activityDto.setComponentUuid(component.uuid());
db.getDbClient().ceActivityDao().insert(db.getSession(), activityDto);
db.getSession().commit();
return activityDto;
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class TaskFormatterTest method formatQueue_do_not_fail_if_component_not_found.
@Test
public void formatQueue_do_not_fail_if_component_not_found() {
CeQueueDto dto = new CeQueueDto();
dto.setUuid("UUID");
dto.setTaskType("TYPE");
dto.setStatus(CeQueueDto.Status.IN_PROGRESS);
dto.setCreatedAt(1_450_000_000_000L);
dto.setComponentUuid("DOES_NOT_EXIST");
Ce.Task wsTask = underTest.formatQueue(db.getSession(), dto);
assertThat(wsTask.getComponentId()).isEqualTo("DOES_NOT_EXIST");
assertThat(wsTask.hasComponentKey()).isFalse();
assertThat(wsTask.hasComponentName()).isFalse();
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class TaskFormatterTest method formatQueues.
@Test
public void formatQueues() {
CeQueueDto dto1 = new CeQueueDto();
dto1.setUuid("UUID1");
dto1.setTaskType("TYPE1");
dto1.setStatus(CeQueueDto.Status.IN_PROGRESS);
dto1.setCreatedAt(1_450_000_000_000L);
CeQueueDto dto2 = new CeQueueDto();
dto2.setUuid("UUID2");
dto2.setTaskType("TYPE2");
dto2.setStatus(CeQueueDto.Status.PENDING);
dto2.setCreatedAt(1_451_000_000_000L);
Iterable<Ce.Task> wsTasks = underTest.formatQueue(db.getSession(), asList(dto1, dto2));
assertThat(wsTasks).extracting("id").containsExactly("UUID1", "UUID2");
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class TaskFormatterTest method formatQueue_compute_execute_time_if_in_progress.
@Test
public void formatQueue_compute_execute_time_if_in_progress() {
long startedAt = 1_450_000_001_000L;
long now = 1_450_000_003_000L;
CeQueueDto dto = new CeQueueDto();
dto.setUuid("UUID");
dto.setTaskType("TYPE");
dto.setStatus(CeQueueDto.Status.PENDING);
dto.setCreatedAt(1_450_000_000_000L);
db.getDbClient().ceQueueDao().insert(db.getSession(), dto);
makeInProgress(db.getSession(), "workerUuid", startedAt, dto);
CeQueueDto inProgress = db.getDbClient().ceQueueDao().selectByUuid(db.getSession(), dto.getUuid()).get();
when(system2.now()).thenReturn(now);
Ce.Task wsTask = underTest.formatQueue(db.getSession(), inProgress);
assertThat(wsTask.getExecutionTimeMs()).isEqualTo(now - startedAt);
}
Aggregations