소스 검색

Tests ignore longitude=180 when index Legacy point (#87364)

* Tests ignore longitude=180 when index Legacy point

It turns out that LegacyGeoShape has an issue indexing points with
longitude=180, but since this is legacy, rather than fix that,
we just skip it from tests.

See https://github.com/elastic/elasticsearch/issues/86118
Craig Taverner 3 년 전
부모
커밋
900690d529

+ 8 - 9
modules/legacy-geo/src/test/java/org/elasticsearch/legacygeo/search/LegacyGeoShapeQueryTests.java

@@ -25,6 +25,7 @@ import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.XContentFactory;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 
@@ -176,15 +177,13 @@ public class LegacyGeoShapeQueryTests extends GeoShapeQueryTestCase {
         assertEquals(1, response.getHits().getTotalHits().value);
     }
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/86118")
+    /**
+     * It turns out that LegacyGeoShape has an issue indexing points with longitude=180,
+     * but since this is legacy, rather than fix that, we just skip it from tests.
+     * See https://github.com/elastic/elasticsearch/issues/86118
+     */
     @Override
-    public void testIndexPointsFromLine() throws Exception {
-        super.testIndexPointsFromLine();
-    }
-
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/86118")
-    @Override
-    public void testIndexPointsFromPolygon() throws Exception {
-        super.testIndexPointsFromPolygon();
+    protected boolean ignoreLons(double[] lons) {
+        return Arrays.stream(lons).anyMatch(v -> v == 180);
     }
 }

+ 7 - 2
test/framework/src/main/java/org/elasticsearch/search/geo/GeoPointShapeQueryTestCase.java

@@ -704,7 +704,7 @@ public abstract class GeoPointShapeQueryTestCase extends ESSingleNodeTestCase {
         ensureGreen();
 
         Line line = randomValueOtherThanMany(
-            l -> GeometryNormalizer.needsNormalize(Orientation.CCW, l),
+            l -> GeometryNormalizer.needsNormalize(Orientation.CCW, l) || ignoreLons(l.getLons()),
             () -> GeometryTestUtils.randomLine(false)
         );
         for (int i = 0; i < line.length(); i++) {
@@ -729,7 +729,7 @@ public abstract class GeoPointShapeQueryTestCase extends ESSingleNodeTestCase {
         ensureGreen();
 
         Polygon polygon = randomValueOtherThanMany(
-            p -> GeometryNormalizer.needsNormalize(Orientation.CCW, p),
+            p -> GeometryNormalizer.needsNormalize(Orientation.CCW, p) || ignoreLons(p.getPolygon().getLons()),
             () -> GeometryTestUtils.randomPolygon(false)
         );
         LinearRing linearRing = polygon.getPolygon();
@@ -749,4 +749,9 @@ public abstract class GeoPointShapeQueryTestCase extends ESSingleNodeTestCase {
         SearchHits searchHits = searchResponse.getHits();
         assertThat(searchHits.getTotalHits().value, equalTo((long) linearRing.length()));
     }
+
+    /** Only LegacyGeoShape has limited support, so other tests will ignore nothing */
+    protected boolean ignoreLons(double[] lons) {
+        return false;
+    }
 }