diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2018-01-23 09:31:21 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2018-01-23 09:31:21 +0100 |
commit | 0ef6fee997436227e1d092473ba11613d089a669 (patch) | |
tree | a0e884d9de775cc2f206dbe89110a1a0e3d6d4cd /server/sonar-ce | |
parent | 972720602e2f510ad84b2f5d9e6808ca641fc902 (diff) | |
parent | 0948aa136a89c9178ce4a81058ecf89f7d9993b3 (diff) | |
download | sonarqube-0ef6fee997436227e1d092473ba11613d089a669.tar.gz sonarqube-0ef6fee997436227e1d092473ba11613d089a669.zip |
Merge branch 'branch-6.7'
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); |