Skip to content

Commit bb0fcb1

Browse files
probakowskidnhatn
authored andcommitted
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
1 parent 0137c16 commit bb0fcb1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

server/src/test/java/org/elasticsearch/index/translog/TranslogTests.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,15 @@ public void testUncommittedOperations() throws Exception {
528528
}
529529

530530
public void testTotalTests() {
531-
final TranslogStats total =
532-
new TranslogStats();
533-
final int n = randomIntBetween(0, 16);
531+
final TranslogStats total = new TranslogStats();
532+
533+
assertThat(total.estimatedNumberOfOperations(), equalTo(0));
534+
assertThat(total.getTranslogSizeInBytes(), equalTo(0L));
535+
assertThat(total.getUncommittedOperations(), equalTo(0));
536+
assertThat(total.getUncommittedSizeInBytes(), equalTo(0L));
537+
assertThat(total.getEarliestLastModifiedAge(), equalTo(0L));
538+
539+
final int n = randomIntBetween(1, 16);
534540
final List<TranslogStats> statsList = new ArrayList<>(n);
535541
long earliestLastModifiedAge = Long.MAX_VALUE;
536542
for (int i = 0; i < n; i++) {

0 commit comments

Comments
 (0)