Skip to content

Commit

Permalink
Fix realPriority when nothing to repair
Browse files Browse the repository at this point in the history
  • Loading branch information
masokol committed Aug 14, 2023
1 parent 751844e commit d846264
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ public boolean runnable()
public final int getRealPriority()
{
RepairStateSnapshot repairStateSnapshot = myRepairState.getSnapshot();
int priority = -1;
// Default to lastRepairedAt, unless we have repairGroups that we can repair.
int priority = getRealPriority(getLastSuccessfulRun());
if (repairStateSnapshot.canRepair())
{
long minRepairedAt = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,15 @@ public void testGetRealPrioritySnapshotLastRepairedAtLowerThanRepairGroups()
assertThat(myRepairJob.getRealPriority()).isEqualTo(2);
}

@Test
public void testGetRealPriorityNothingToRepair()
{
long lastRepaired = System.currentTimeMillis() - (TimeUnit.DAYS.toMillis(RUN_INTERVAL_IN_DAYS));
doReturn(lastRepaired).when(myRepairStateSnapshot).lastRepairedAt();
doReturn(false).when(myRepairStateSnapshot).canRepair();
assertThat(myRepairJob.getRealPriority()).isEqualTo(1);
}

private void mockRepairGroup(long lastRepairedAt)
{
mockRepairGroup(getRepairGroup(new LongTokenRange(1, 2), lastRepairedAt));
Expand Down

0 comments on commit d846264

Please sign in to comment.