Skip to content

Commit 9872f90

Browse files
committed
Fixup test
1 parent 2bf9269 commit 9872f90

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

server/src/test/java/org/elasticsearch/index/mapper/blockloader/docvalues/AbstractFromOrdsBlockLoaderTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ public AbstractFromOrdsBlockLoaderTests(boolean blockAtATime, boolean highCardin
5656
this.missingValues = missingValues;
5757
}
5858

59-
protected abstract void innerTest(LeafReaderContext ctx) throws IOException;
59+
protected abstract void innerTest(LeafReaderContext ctx, int mvCount) throws IOException;
6060

6161
public void test() throws IOException {
62+
int mvCount = 0;
6263
try (Directory dir = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), dir)) {
6364
int docCount = 10_000;
6465
int cardinality = lowCardinality ? between(1, LOW_CARDINALITY) : between(LOW_CARDINALITY + 1, LOW_CARDINALITY * 2);
@@ -67,6 +68,7 @@ public void test() throws IOException {
6768
doc.add(field(i % cardinality));
6869
if (multiValues && i % cardinality == 0) {
6970
doc.add(field((i % cardinality) + 1));
71+
mvCount++;
7072
}
7173
iw.addDocument(doc);
7274
}
@@ -76,7 +78,7 @@ public void test() throws IOException {
7678
iw.forceMerge(1);
7779
try (DirectoryReader dr = iw.getReader()) {
7880
LeafReaderContext ctx = getOnlyLeafReader(dr).getContext();
79-
innerTest(ctx);
81+
innerTest(ctx, mvCount);
8082
}
8183
}
8284
}

server/src/test/java/org/elasticsearch/index/mapper/blockloader/docvalues/MvMaxBytesRefsFromOrdsBlockLoaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public MvMaxBytesRefsFromOrdsBlockLoaderTests(
3333
}
3434

3535
@Override
36-
protected void innerTest(LeafReaderContext ctx) throws IOException {
36+
protected void innerTest(LeafReaderContext ctx, int mvCount) throws IOException {
3737
var stringsLoader = new BytesRefsFromOrdsBlockLoader("field");
3838
var mvMaxLoader = new MvMaxBytesRefsFromOrdsBlockLoader("field");
3939

server/src/test/java/org/elasticsearch/index/mapper/blockloader/docvalues/MvMinBytesRefsFromOrdsBlockLoaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public MvMinBytesRefsFromOrdsBlockLoaderTests(
3333
}
3434

3535
@Override
36-
protected void innerTest(LeafReaderContext ctx) throws IOException {
36+
protected void innerTest(LeafReaderContext ctx, int mvCount) throws IOException {
3737
var stringsLoader = new BytesRefsFromOrdsBlockLoader("field");
3838
var mvMinLoader = new MvMinBytesRefsFromOrdsBlockLoader("field");
3939

server/src/test/java/org/elasticsearch/index/mapper/blockloader/docvalues/Utf8CodePointsFromOrdsBlockLoaderTests.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,12 @@ public Utf8CodePointsFromOrdsBlockLoaderTests(
3636
}
3737

3838
@Override
39-
protected void innerTest(LeafReaderContext ctx) throws IOException {
39+
protected void innerTest(LeafReaderContext ctx, int mvCount) throws IOException {
4040
List<MockWarnings.MockWarning> expectedWarnings = new ArrayList<>();
41-
int docCount = 10_000;
42-
int cardinality = lowCardinality ? between(1, LOW_CARDINALITY) : between(LOW_CARDINALITY + 1, LOW_CARDINALITY * 2);
43-
for (int i = 0; i < docCount; i++) {
44-
if (multiValues && i % cardinality == 0) {
45-
expectedWarnings.add(
46-
new MockWarnings.MockWarning(IllegalArgumentException.class, "single-value function encountered multi-value")
47-
);
48-
}
41+
for (int i = 0; i < mvCount; i++) {
42+
expectedWarnings.add(
43+
new MockWarnings.MockWarning(IllegalArgumentException.class, "single-value function encountered multi-value")
44+
);
4945
}
5046

5147
var warnings = new MockWarnings();

0 commit comments

Comments
 (0)