Skip to content

Commit 4afc78e

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 a4e3c68 commit 4afc78e

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
@@ -542,9 +542,15 @@ public void testUncommittedOperations() throws Exception {
542542
}
543543

544544
public void testTotalTests() {
545-
final TranslogStats total =
546-
new TranslogStats();
547-
final int n = randomIntBetween(0, 16);
545+
final TranslogStats total = new TranslogStats();
546+
547+
assertThat(total.estimatedNumberOfOperations(), equalTo(0));
548+
assertThat(total.getTranslogSizeInBytes(), equalTo(0L));
549+
assertThat(total.getUncommittedOperations(), equalTo(0));
550+
assertThat(total.getUncommittedSizeInBytes(), equalTo(0L));
551+
assertThat(total.getEarliestLastModifiedAge(), equalTo(0L));
552+
553+
final int n = randomIntBetween(1, 16);
548554
final List<TranslogStats> statsList = new ArrayList<>(n);
549555
long earliestLastModifiedAge = Long.MAX_VALUE;
550556
for (int i = 0; i < n; i++) {

0 commit comments

Comments
 (0)