Fix TranslogTests.testTotalTests when n=0 (#65632)

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
This commit is contained in:
Przemko Robakowski 2020-11-30 23:27:39 +01:00 committed by Nhat Nguyen
parent 0137c1679b
commit bb0fcb150b
1 changed files with 9 additions and 3 deletions

View File

@ -528,9 +528,15 @@ public class TranslogTests extends ESTestCase {
}
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++) {