Search in sources :

Example 46 with CeQueueDto

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

the class InternalCeQueueImplTest method peek_ignores_in_progress_tasks.

@Test
public void peek_ignores_in_progress_tasks() {
    CeQueueDto dto = db.getDbClient().ceQueueDao().insert(session, new CeQueueDto().setUuid("uuid").setTaskType("foo").setStatus(CeQueueDto.Status.PENDING));
    makeInProgress(dto, "foo");
    db.commit();
    assertThat(underTest.peek(WORKER_UUID_1, true)).isEmpty();
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 47 with CeQueueDto

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

the class InternalCeQueueImplTest method insertInProgress.

private CeQueueDto insertInProgress(String uuid, String workerUuid) {
    CeQueueDto dto = new CeQueueDto().setUuid(uuid).setTaskType("foo").setStatus(CeQueueDto.Status.PENDING);
    db.getDbClient().ceQueueDao().insert(session, dto);
    makeInProgress(dto, workerUuid);
    db.commit();
    return db.getDbClient().ceQueueDao().selectByUuid(session, uuid).get();
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 48 with CeQueueDto

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

the class InternalCeQueueImplTest method peek_resets_to_pending_any_task_in_progress_for_specified_worker_uuid_and_updates_updatedAt.

@Test
public void peek_resets_to_pending_any_task_in_progress_for_specified_worker_uuid_and_updates_updatedAt() {
    // add a pending one that will be picked so that u1 isn't peek and status reset is visible in DB
    insertPending("u0");
    // will be picked-because older than any of the reset ones
    CeQueueDto u1 = insertPending("u1");
    // will be reset
    CeQueueDto u2 = insertInProgress("u2", WORKER_UUID_1);
    assertThat(underTest.peek(WORKER_UUID_1, true).get().getUuid()).isEqualTo("u0");
    verifyUnmodifiedTask(u1);
    verifyResetTask(u2);
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 49 with CeQueueDto

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

the class InternalCeQueueImplTest method verifyResetTask.

private void verifyResetTask(CeQueueDto originalDto) {
    CeQueueDto dto = db.getDbClient().ceQueueDao().selectByUuid(session, originalDto.getUuid()).get();
    assertThat(dto.getStatus()).isEqualTo(CeQueueDto.Status.PENDING);
    assertThat(dto.getCreatedAt()).isEqualTo(originalDto.getCreatedAt());
    assertThat(dto.getUpdatedAt()).isGreaterThan(originalDto.getUpdatedAt());
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 50 with CeQueueDto

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

the class ReportAnalysisFailureNotificationExecutionListenerTest method insertActivityDto.

private void insertActivityDto(String taskUuid, int createdAt, @Nullable Long executedAt, ComponentDto project) {
    dbClient.ceActivityDao().insert(dbTester.getSession(), new CeActivityDto(new CeQueueDto().setUuid(taskUuid).setTaskType(CeTaskTypes.REPORT).setComponentUuid(project.uuid()).setCreatedAt(createdAt)).setExecutedAt(executedAt).setStatus(CeActivityDto.Status.FAILED));
    dbTester.getSession().commit();
}
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