Search in sources :

Example 91 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class ComponentActionTest method insertQueue.

private CeQueueDto insertQueue(String taskUuid, ComponentDto component, CeQueueDto.Status status) {
    CeQueueDto queueDto = new CeQueueDto();
    queueDto.setTaskType(CeTaskTypes.REPORT);
    queueDto.setComponent(component);
    queueDto.setUuid(taskUuid);
    queueDto.setStatus(status);
    db.getDbClient().ceQueueDao().insert(db.getSession(), queueDto);
    db.getSession().commit();
    return queueDto;
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 92 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class ComponentActionTest method insertActivity.

private CeActivityDto insertActivity(String taskUuid, ComponentDto component, CeActivityDto.Status status, @Nullable SnapshotDto analysis) {
    CeQueueDto queueDto = new CeQueueDto();
    queueDto.setTaskType(CeTaskTypes.REPORT);
    queueDto.setComponent(component);
    queueDto.setUuid(taskUuid);
    CeActivityDto activityDto = new CeActivityDto(queueDto);
    activityDto.setStatus(status);
    activityDto.setExecutionTimeMs(500L);
    activityDto.setAnalysisUuid(analysis == null ? null : analysis.getUuid());
    db.getDbClient().ceActivityDao().insert(db.getSession(), activityDto);
    db.getSession().commit();
    return activityDto;
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 93 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class ActivityActionTest method pull_request_in_queue_analysis.

@Test
public void pull_request_in_queue_analysis() {
    logInAsSystemAdministrator();
    String branch = "pr-123";
    CeQueueDto queue1 = insertQueue("T1", null, IN_PROGRESS);
    insertCharacteristic(queue1, PULL_REQUEST, branch);
    CeQueueDto queue2 = insertQueue("T2", null, PENDING);
    insertCharacteristic(queue2, PULL_REQUEST, branch);
    ActivityResponse response = ws.newRequest().setParam("status", "FAILED,IN_PROGRESS,PENDING").executeProtobuf(ActivityResponse.class);
    assertThat(response.getTasksList()).extracting(Task::getId, Ce.Task::getPullRequest, Ce.Task::hasPullRequestTitle, Ce.Task::getStatus).containsExactlyInAnyOrder(tuple("T1", branch, false, Ce.TaskStatus.IN_PROGRESS), tuple("T2", branch, false, Ce.TaskStatus.PENDING));
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) Ce(org.sonarqube.ws.Ce) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 94 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class ActivityActionTest method branch_in_queue_analysis.

@Test
public void branch_in_queue_analysis() {
    logInAsSystemAdministrator();
    String branch = "ny_branch";
    CeQueueDto queue1 = insertQueue("T1", null, IN_PROGRESS);
    insertCharacteristic(queue1, BRANCH_KEY, branch);
    insertCharacteristic(queue1, BRANCH_TYPE_KEY, BRANCH.name());
    CeQueueDto queue2 = insertQueue("T2", null, PENDING);
    insertCharacteristic(queue2, BRANCH_KEY, branch);
    insertCharacteristic(queue2, BRANCH_TYPE_KEY, BRANCH.name());
    ActivityResponse response = ws.newRequest().setParam("status", "FAILED,IN_PROGRESS,PENDING").executeProtobuf(ActivityResponse.class);
    assertThat(response.getTasksList()).extracting(Task::getId, Ce.Task::getBranch, Ce.Task::getBranchType, Ce.Task::getStatus).containsExactlyInAnyOrder(tuple("T1", branch, Common.BranchType.BRANCH, Ce.TaskStatus.IN_PROGRESS), tuple("T2", branch, Common.BranchType.BRANCH, Ce.TaskStatus.PENDING));
}
Also used : ActivityResponse(org.sonarqube.ws.Ce.ActivityResponse) Ce(org.sonarqube.ws.Ce) CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 95 with CeQueueDto

use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.

the class RecentTasksDurationTaskTest method newCeActivityTask.

private CeActivityDto newCeActivityTask(CeActivityDto.Status status) {
    CeActivityDto dto = new CeActivityDto(new CeQueueDto());
    dto.setStatus(status);
    dto.setMainComponentUuid("0");
    dto.setExecutionTimeMs(1000L);
    return dto;
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Aggregations

CeQueueDto (org.sonar.db.ce.CeQueueDto)120 Test (org.junit.Test)58 CeActivityDto (org.sonar.db.ce.CeActivityDto)36 ComponentDto (org.sonar.db.component.ComponentDto)20 DbSession (org.sonar.db.DbSession)18 CeTask (org.sonar.ce.task.CeTask)17 UserDto (org.sonar.db.user.UserDto)17 Ce (org.sonarqube.ws.Ce)11 CeTaskCharacteristicDto (org.sonar.db.ce.CeTaskCharacteristicDto)6 List (java.util.List)5 Optional (java.util.Optional)5 Random (java.util.Random)5 Collectors (java.util.stream.Collectors)5 System2 (org.sonar.api.utils.System2)5 Arrays (java.util.Arrays)4 Arrays.asList (java.util.Arrays.asList)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Date (java.util.Date)4 IntStream (java.util.stream.IntStream)4