mirror of https://github.com/apache/lucene.git
LUCENE-10160: improve assert to be easier to debug
Instead of a vague: java.lang.AssertionError at..., include some basic information: java.lang.AssertionError: size=16252835,limit=15728640,maxSegmentSizeMb=10.0
This commit is contained in:
parent
6c6a3bd5bd
commit
c1fe9efb4b
|
@ -17,6 +17,7 @@
|
|||
package org.apache.lucene.index;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -494,18 +495,21 @@ public class TestTieredMergePolicy extends BaseMergePolicyTestCase {
|
|||
|
||||
private static void assertMaxSize(MergeSpecification specification, double maxSegmentSizeMb) {
|
||||
for (OneMerge merge : specification.merges) {
|
||||
assertTrue(
|
||||
long size =
|
||||
merge.segments.stream()
|
||||
.mapToLong(
|
||||
s -> {
|
||||
try {
|
||||
return s.sizeInBytes();
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
})
|
||||
.sum()
|
||||
< 1024 * 1024 * maxSegmentSizeMb * 1.5);
|
||||
.sum();
|
||||
long limit = (long) (1024 * 1024 * maxSegmentSizeMb * 1.5);
|
||||
assertTrue(
|
||||
"size=" + size + ",limit=" + limit + ",maxSegmentSizeMb=" + maxSegmentSizeMb,
|
||||
size < limit);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue