Skip to content

Commit bccc19e

Browse files
GalLalouchecraigtaverner
authored andcommitted
ESQL: Fix ShapeGeometryFieldMapperTests (and rename) (elastic#122871) (elastic#124251)
Fixes elastic#122661. The issue was caused by RandomIndexWriter (randomly) reshuffling the document writing order. Since this test also ensures that the documents are read in the input order, I've opted to use a regular IndexWriter instead. I've also renamed the class to AbstractShapeGeometryFieldMapperTests since it was originally renamed due to a misunderstanding of muted tests (which caused it to be muted again! Busted 😅).
1 parent c5be126 commit bccc19e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,6 @@ tests:
332332
issue: https://github.com/elastic/elasticsearch/issues/119396
333333
- class: org.elasticsearch.xpack.security.authc.ldap.ADLdapUserSearchSessionFactoryTests
334334
issue: https://github.com/elastic/elasticsearch/issues/119882
335-
- class: org.elasticsearch.index.mapper.AbstractShapeGeometryFieldMapperTests
336-
method: testCartesianBoundsBlockLoader
337-
issue: https://github.com/elastic/elasticsearch/issues/119201
338335
- class: org.elasticsearch.xpack.security.operator.OperatorPrivilegesIT
339336
method: testEveryActionIsEitherOperatorOnlyOrNonOperator
340337
issue: https://github.com/elastic/elasticsearch/issues/119911
@@ -450,9 +447,6 @@ tests:
450447
- class: org.elasticsearch.oldrepos.OldRepositoryAccessIT
451448
method: testOldRepoAccess
452449
issue: https://github.com/elastic/elasticsearch/issues/120148
453-
- class: org.elasticsearch.index.mapper.ShapeGeometryFieldMapperTests
454-
method: testCartesianBoundsBlockLoader
455-
issue: https://github.com/elastic/elasticsearch/issues/125129
456450
- class: org.elasticsearch.xpack.ilm.history.ILMHistoryItemTests
457451
method: testTruncateLongError
458452
issue: https://github.com/elastic/elasticsearch/issues/125216

server/src/test/java/org/elasticsearch/index/mapper/ShapeGeometryFieldMapperTests.java renamed to server/src/test/java/org/elasticsearch/index/mapper/AbstractShapeGeometryFieldMapperTests.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import org.apache.lucene.document.Document;
1313
import org.apache.lucene.geo.GeoEncodingUtils;
1414
import org.apache.lucene.index.DirectoryReader;
15+
import org.apache.lucene.index.IndexWriter;
16+
import org.apache.lucene.index.IndexWriterConfig;
1517
import org.apache.lucene.index.LeafReader;
1618
import org.apache.lucene.store.Directory;
17-
import org.apache.lucene.tests.index.RandomIndexWriter;
1819
import org.elasticsearch.common.geo.GeometryNormalizer;
1920
import org.elasticsearch.core.Strings;
2021
import org.elasticsearch.geo.GeometryTestUtils;
@@ -39,14 +40,14 @@
3940
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLongitude;
4041
import static org.elasticsearch.common.geo.Orientation.RIGHT;
4142

42-
public class ShapeGeometryFieldMapperTests extends ESTestCase {
43+
public class AbstractShapeGeometryFieldMapperTests extends ESTestCase {
4344
public void testCartesianBoundsBlockLoader() throws IOException {
4445
testBoundsBlockLoader(
4546
CoordinateEncoder.CARTESIAN,
4647
() -> ShapeTestUtils.randomGeometryWithoutCircle(0, false),
4748
CartesianShapeIndexer::new,
4849
SpatialEnvelopeVisitor::visitCartesian,
49-
ShapeGeometryFieldMapperTests::makeCartesianRectangle
50+
AbstractShapeGeometryFieldMapperTests::makeCartesianRectangle
5051
);
5152
}
5253

@@ -58,7 +59,7 @@ public void ignoreTestGeoBoundsBlockLoader() throws IOException {
5859
() -> normalize(GeometryTestUtils.randomGeometryWithoutCircle(0, false)),
5960
field -> new GeoShapeIndexer(RIGHT, field),
6061
g -> SpatialEnvelopeVisitor.visitGeo(g, SpatialEnvelopeVisitor.WrapLongitude.WRAP),
61-
ShapeGeometryFieldMapperTests::makeGeoRectangle
62+
AbstractShapeGeometryFieldMapperTests::makeGeoRectangle
6263
);
6364
}
6465

@@ -72,7 +73,7 @@ public void ignoreTestRectangleCrossingDateline() throws IOException {
7273
geometries,
7374
field -> new GeoShapeIndexer(RIGHT, field),
7475
g -> SpatialEnvelopeVisitor.visitGeo(g, SpatialEnvelopeVisitor.WrapLongitude.WRAP),
75-
ShapeGeometryFieldMapperTests::makeGeoRectangle
76+
AbstractShapeGeometryFieldMapperTests::makeGeoRectangle
7677
);
7778
}
7879

@@ -100,7 +101,9 @@ private static void testBoundsBlockLoaderAux(
100101
) throws IOException {
101102
var loader = new AbstractShapeGeometryFieldMapper.AbstractShapeGeometryFieldType.BoundsBlockLoader("field");
102103
try (Directory directory = newDirectory()) {
103-
try (var iw = new RandomIndexWriter(random(), directory)) {
104+
// Since we also test that the documents are loaded in the correct order, we need to write them in order, so we can't use
105+
// RandomIndexWriter here.
106+
try (var iw = new IndexWriter(directory, new IndexWriterConfig(null /* analyzer */))) {
104107
for (Geometry geometry : geometries) {
105108
var shape = new BinaryShapeDocValuesField("field", encoder);
106109
shape.add(indexerFactory.apply("field").indexShape(geometry), geometry);

0 commit comments

Comments
 (0)