Skip to content

Commit

Permalink
Fix TranslogTests.testTotalTests when n=0 (#65632)
Browse files Browse the repository at this point in the history
When n=0 in TranslogTests.testTotalTests we never update earliestLastModifiedAge so it fails comparison with default value of total.getEarliestLastModifiedAge() which is 0.
In this change we always check this special case and then select n>0

Closes #65629
  • Loading branch information
probakowski authored and dnhatn committed Nov 30, 2020
1 parent 0137c16 commit bb0fcb1
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,15 @@ public void testUncommittedOperations() throws Exception {
}

public void testTotalTests() {
final TranslogStats total =
new TranslogStats();
final int n = randomIntBetween(0, 16);
final TranslogStats total = new TranslogStats();

assertThat(total.estimatedNumberOfOperations(), equalTo(0));
assertThat(total.getTranslogSizeInBytes(), equalTo(0L));
assertThat(total.getUncommittedOperations(), equalTo(0));
assertThat(total.getUncommittedSizeInBytes(), equalTo(0L));
assertThat(total.getEarliestLastModifiedAge(), equalTo(0L));

final int n = randomIntBetween(1, 16);
final List<TranslogStats> statsList = new ArrayList<>(n);
long earliestLastModifiedAge = Long.MAX_VALUE;
for (int i = 0; i < n; i++) {
Expand Down

0 comments on commit bb0fcb1

Please sign in to comment.