Search in sources :

Example 16 with CeQueueDto

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

the class TaskActionTest method get_project_queue_task_with_scan_permission_on_project.

@Test
public void get_project_queue_task_with_scan_permission_on_project() {
    userSession.logIn().addProjectUuidPermissions(GlobalPermissions.SCAN_EXECUTION, project.uuid());
    CeQueueDto task = createAndPersistQueueTask(project);
    call(task.getUuid());
}
Also used : CeQueueDto(org.sonar.db.ce.CeQueueDto) Test(org.junit.Test)

Example 17 with CeQueueDto

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

the class TaskFormatterTest method newActivity.

private CeActivityDto newActivity(String taskUuid, String componentUuid, CeActivityDto.Status status) {
    CeQueueDto queueDto = new CeQueueDto();
    queueDto.setCreatedAt(1_450_000_000_000L);
    queueDto.setTaskType(CeTaskTypes.REPORT);
    queueDto.setComponentUuid(componentUuid);
    queueDto.setUuid(taskUuid);
    CeActivityDto activityDto = new CeActivityDto(queueDto);
    activityDto.setStatus(status);
    activityDto.setExecutionTimeMs(500L);
    activityDto.setAnalysisUuid("U1");
    return activityDto;
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 18 with CeQueueDto

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

the class CeQueueImpl method cancelAll.

protected int cancelAll(boolean includeInProgress) {
    int count = 0;
    try (DbSession dbSession = dbClient.openSession(false)) {
        for (CeQueueDto queueDto : dbClient.ceQueueDao().selectAllInAscOrder(dbSession)) {
            if (includeInProgress || !queueDto.getStatus().equals(CeQueueDto.Status.IN_PROGRESS)) {
                cancelImpl(dbSession, queueDto);
                count++;
            }
        }
        return count;
    }
}
Also used : DbSession(org.sonar.db.DbSession) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 19 with CeQueueDto

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

the class CeQueueImpl method submit.

@Override
public CeTask submit(CeTaskSubmit submission) {
    checkState(!submitPaused.get(), "Compute Engine does not currently accept new tasks");
    try (DbSession dbSession = dbClient.openSession(false)) {
        CeQueueDto dto = new CeTaskSubmitToInsertedCeQueueDto(dbSession, dbClient).apply(submission);
        CeTask task = loadTask(dbSession, dto);
        dbSession.commit();
        return task;
    }
}
Also used : DbSession(org.sonar.db.DbSession) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Example 20 with CeQueueDto

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

the class CeQueueImpl method cancel.

@Override
public boolean cancel(String taskUuid) {
    try (DbSession dbSession = dbClient.openSession(false)) {
        Optional<CeQueueDto> queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, taskUuid);
        if (queueDto.isPresent()) {
            checkState(CeQueueDto.Status.PENDING.equals(queueDto.get().getStatus()), "Task is in progress and can't be canceled [uuid=%s]", taskUuid);
            cancelImpl(dbSession, queueDto.get());
            return true;
        }
        return false;
    }
}
Also used : DbSession(org.sonar.db.DbSession) CeQueueDto(org.sonar.db.ce.CeQueueDto)

Aggregations

CeQueueDto (org.sonar.db.ce.CeQueueDto)32 Test (org.junit.Test)11 CeActivityDto (org.sonar.db.ce.CeActivityDto)11 DbSession (org.sonar.db.DbSession)8 WsCe (org.sonarqube.ws.WsCe)5 ComponentDto (org.sonar.db.component.ComponentDto)2 Date (java.util.Date)1 StringUtils.defaultString (org.apache.commons.lang.StringUtils.defaultString)1 CeTask (org.sonar.ce.queue.CeTask)1 Status (org.sonar.db.ce.CeQueueDto.Status)1 CeTaskQuery (org.sonar.db.ce.CeTaskQuery)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 TestResponse (org.sonar.server.ws.TestResponse)1 ProjectResponse (org.sonarqube.ws.WsCe.ProjectResponse)1