diff options
Diffstat (limited to 'server/sonar-ce')
-rw-r--r-- | server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java | 2 | ||||
-rw-r--r-- | server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java | 27 |
2 files changed, 10 insertions, 19 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java index 2472d050004..5b093ff3156 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/queue/InternalCeQueueImpl.java @@ -52,7 +52,7 @@ import static java.util.Objects.requireNonNull; public class InternalCeQueueImpl extends CeQueueImpl implements InternalCeQueue { private static final org.sonar.api.utils.log.Logger LOG = Loggers.get(InternalCeQueueImpl.class); - private static final int MAX_EXECUTION_COUNT = 2; + private static final int MAX_EXECUTION_COUNT = 1; private final System2 system2; private final DbClient dbClient; diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java index fdb7b951f8a..28186aac046 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/queue/InternalCeQueueImplTest.java @@ -351,7 +351,7 @@ public class InternalCeQueueImplTest { } @Test - public void peek_peeks_pending_tasks_with_executionCount_equal_to_1_and_increases_it() { + public void peek_ignores_pending_tasks_with_executionCount_equal_to_1() { db.getDbClient().ceQueueDao().insert(session, new CeQueueDto() .setUuid("uuid") .setTaskType("foo") @@ -359,8 +359,7 @@ public class InternalCeQueueImplTest { .setExecutionCount(1)); db.commit(); - assertThat(underTest.peek(WORKER_UUID_1).get().getUuid()).isEqualTo("uuid"); - assertThat(db.getDbClient().ceQueueDao().selectByUuid(session, "uuid").get().getExecutionCount()).isEqualTo(2); + assertThat(underTest.peek(WORKER_UUID_1).isPresent()).isFalse(); } @Test @@ -423,30 +422,22 @@ public class InternalCeQueueImplTest { public void peek_resets_to_pending_any_task_in_progress_for_specified_worker_uuid_and_peeks_the_oldest_non_worn_out_no_matter_if_it_has_been_reset_or_not() { insertPending("u1", WORKER_UUID_1, 3); // won't be picked because worn out insertInProgress("u2", WORKER_UUID_1, 3); // will be reset but won't be picked because worn out - insertPending("u3", WORKER_UUID_1, 0); // will be picked first - insertInProgress("u4", WORKER_UUID_1, 1); // will be reset and picked on second call only + insertInProgress("u3", WORKER_UUID_1, 1); // will be reset but won't be picked because worn out + insertPending("u4", WORKER_UUID_1, 0); // will be picked Optional<CeTask> ceTask = underTest.peek(WORKER_UUID_1); - assertThat(ceTask.get().getUuid()).isEqualTo("u3"); - - // remove first task and do another peek: will pick the reset task since it's now the oldest one - underTest.remove(ceTask.get(), CeActivityDto.Status.SUCCESS, null, null); - assertThat(underTest.peek(WORKER_UUID_1).get().getUuid()).isEqualTo("u4"); + assertThat(ceTask.get().getUuid()).isEqualTo("u4"); } @Test public void peek_resets_to_pending_any_task_in_progress_for_specified_worker_uuid_and_peeks_reset_tasks_if_is_the_oldest_non_worn_out() { insertPending("u1", WORKER_UUID_1, 3); // won't be picked because worn out insertInProgress("u2", WORKER_UUID_1, 3); // will be reset but won't be picked because worn out - insertInProgress("u3", WORKER_UUID_1, 1); // will be reset and picked + insertInProgress("u3", WORKER_UUID_1, 1); // won't be picked because worn out insertPending("u4", WORKER_UUID_1, 0); // will be picked second Optional<CeTask> ceTask = underTest.peek(WORKER_UUID_1); - assertThat(ceTask.get().getUuid()).isEqualTo("u3"); - - // remove first task and do another peek: will pick the reset task since it's now the oldest one - underTest.remove(ceTask.get(), CeActivityDto.Status.SUCCESS, null, null); - assertThat(underTest.peek(WORKER_UUID_1).get().getUuid()).isEqualTo("u4"); + assertThat(ceTask.get().getUuid()).isEqualTo("u4"); } private void verifyResetTask(CeQueueDto originalDto) { @@ -551,7 +542,7 @@ public class InternalCeQueueImplTest { } @Test - public void cancelWornOuts_cancels_pending_tasks_with_executionCount_greater_or_equal_to_2() { + public void cancelWornOuts_cancels_pending_tasks_with_executionCount_greater_or_equal_to_1() { CeQueueDto u1 = insertCeQueueDto("u1", CeQueueDto.Status.PENDING, 0, "worker1"); CeQueueDto u2 = insertCeQueueDto("u2", CeQueueDto.Status.PENDING, 1, "worker1"); CeQueueDto u3 = insertCeQueueDto("u3", CeQueueDto.Status.PENDING, 2, "worker1"); @@ -564,7 +555,7 @@ public class InternalCeQueueImplTest { underTest.cancelWornOuts(); verifyUnmodified(u1); - verifyUnmodified(u2); + verifyCanceled(u2); verifyCanceled(u3); verifyCanceled(u4); verifyUnmodified(u5); |