use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method remove_sets_snapshotId_in_CeActivity_when_CeTaskResult_has_no_snapshot_id.
@Test
public void remove_sets_snapshotId_in_CeActivity_when_CeTaskResult_has_no_snapshot_id() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
Optional<CeTask> peek = underTest.peek();
underTest.remove(peek.get(), CeActivityDto.Status.SUCCESS, newTaskResult(AN_ANALYSIS_UUID), null);
// available in history
Optional<CeActivityDto> history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), task.getUuid());
assertThat(history.isPresent()).isTrue();
assertThat(history.get().getAnalysisUuid()).isEqualTo("U1");
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method cancelAll_pendings_but_not_in_progress.
@Test
public void cancelAll_pendings_but_not_in_progress() throws Exception {
CeTask inProgressTask = submit(CeTaskTypes.REPORT, "PROJECT_1");
CeTask pendingTask1 = submit(CeTaskTypes.REPORT, "PROJECT_2");
CeTask pendingTask2 = submit(CeTaskTypes.REPORT, "PROJECT_3");
underTest.peek();
int canceledCount = underTest.cancelAll();
assertThat(canceledCount).isEqualTo(2);
Optional<CeActivityDto> history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), pendingTask1.getUuid());
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), pendingTask2.getUuid());
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), inProgressTask.getUuid());
assertThat(history.isPresent()).isFalse();
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method fail_to_cancel_if_in_progress.
@Test
public void fail_to_cancel_if_in_progress() throws Exception {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage(startsWith("Task is in progress and can't be canceled"));
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
underTest.peek();
underTest.cancel(task.getUuid());
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method set_branch.
@Test
public void set_branch() throws Exception {
reportReader.setMetadata(newBatchReportBuilder().setBranch(BRANCH).build());
CeTask ceTask = createCeTask(PROJECT_KEY + ":" + BRANCH, dbTester.getDefaultOrganization().getUuid());
ComputationStep underTest = createStep(ceTask);
underTest.execute();
assertThat(analysisMetadataHolder.getBranch()).isEqualTo(BRANCH);
}
use of org.sonar.ce.queue.CeTask in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_MessageException_if_projectKey_is_null_in_CE_task.
@Test
public void execute_fails_with_MessageException_if_projectKey_is_null_in_CE_task() {
CeTask res = mock(CeTask.class);
when(res.getComponentUuid()).thenReturn("prj_uuid");
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
ComputationStep underTest = createStep(res);
expectedException.expect(MessageException.class);
expectedException.expectMessage("Compute Engine task component key is null. Project with UUID prj_uuid must have been deleted since report was uploaded. Can not proceed.");
underTest.execute();
}
Aggregations