From aab920f48cfb83fa9b61190845d35a72dc081c8b Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 13:19:45 -0700 Subject: [PATCH 01/21] Create new spatial-extras module and migrate geo_shape registration This commit introduces a new spatial-extras module that is intended to be contain all the geo-spatial-specific features in server. As a first step, the responsibility of registering the geo_shape field mapper is moved to this module. --- modules/spatial-extras/build.gradle | 23 ++++++++++ .../spatial/SpatialExtrasPlugin.java | 40 ++++++++++++++++ .../SpatialExtrasClientYamlTestSuiteIT.java | 39 ++++++++++++++++ .../rest-api-spec/test/geo_shape/10_basic.yml | 46 +++++++++++++++++++ .../elasticsearch/indices/IndicesModule.java | 3 -- .../index/mapper/DocumentParserTests.java | 3 +- .../mapper/FieldFilterMapperPluginTests.java | 4 +- .../mapper/GeoShapeFieldMapperTests.java | 3 +- .../LegacyGeoShapeFieldMapperTests.java | 3 +- .../query/TermsSetQueryBuilderTests.java | 3 +- .../FunctionScoreQueryBuilderTests.java | 3 +- .../search/geo/GeoQueryTests.java | 9 ++++ .../test/AbstractBuilderTestCase.java | 2 +- .../test/TestGeoShapeFieldMapperPlugin.java | 46 +++++++++++++++++++ 14 files changed, 216 insertions(+), 11 deletions(-) create mode 100644 modules/spatial-extras/build.gradle create mode 100644 modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java create mode 100644 modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java create mode 100644 modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml create mode 100644 test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java diff --git a/modules/spatial-extras/build.gradle b/modules/spatial-extras/build.gradle new file mode 100644 index 0000000000000..b95fd9495d6cc --- /dev/null +++ b/modules/spatial-extras/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +esplugin { + description 'Placeholder plugin for spatial features in ES. only registers geo-shape field mapper for now' + classname 'org.elasticsearch.spatial.SpatialExtrasPlugin' +} diff --git a/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java b/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java new file mode 100644 index 0000000000000..3f2b505cd5b06 --- /dev/null +++ b/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.spatial; + +import org.elasticsearch.index.mapper.AbstractGeometryFieldMapper; +import org.elasticsearch.index.mapper.GeoShapeFieldMapper; +import org.elasticsearch.index.mapper.Mapper; +import org.elasticsearch.plugins.MapperPlugin; +import org.elasticsearch.plugins.Plugin; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +public class SpatialExtrasPlugin extends Plugin implements MapperPlugin { + + @Override + public Map getMappers() { + Map mappers = new LinkedHashMap<>(); + mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); + return Collections.unmodifiableMap(mappers); + } +} diff --git a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java b/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java new file mode 100644 index 0000000000000..13bf47c2c202a --- /dev/null +++ b/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java @@ -0,0 +1,39 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.spatial; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; +import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; + +/** Runs yaml rest tests */ +public class SpatialExtrasClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { + + public SpatialExtrasClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws Exception { + return ESClientYamlSuiteTestCase.createParameters(); + } +} + diff --git a/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml b/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml new file mode 100644 index 0000000000000..6b4c85f107d1d --- /dev/null +++ b/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml @@ -0,0 +1,46 @@ +setup: + - do: + indices.create: + index: test + body: + settings: + number_of_replicas: 0 + mappings: + properties: + location: + type: geo_shape + + - do: + index: + index: test + id: 1 + body: + location: "POINT (1.0 1.0)" + + - do: + indices.refresh: {} + +--- +"Geo Shape Query": + + - do: + search: + rest_total_hits_as_int: true + body: + query: + bool: + filter: + geo_shape: + location: + shape: + type: Envelope + coordinates: + - [-80.0, 34.0] + - [43, -13.0] + relation: within + + - match: + hits.total: 1 + + - match: + hits.hits.0._id: "1" diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesModule.java b/server/src/main/java/org/elasticsearch/indices/IndicesModule.java index ea880110d52c1..15537a5f622b2 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -30,7 +30,6 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.engine.EngineFactory; -import org.elasticsearch.index.mapper.AbstractGeometryFieldMapper; import org.elasticsearch.index.mapper.BinaryFieldMapper; import org.elasticsearch.index.mapper.BooleanFieldMapper; import org.elasticsearch.index.mapper.CompletionFieldMapper; @@ -38,7 +37,6 @@ import org.elasticsearch.index.mapper.FieldAliasMapper; import org.elasticsearch.index.mapper.FieldNamesFieldMapper; import org.elasticsearch.index.mapper.GeoPointFieldMapper; -import org.elasticsearch.index.mapper.GeoShapeFieldMapper; import org.elasticsearch.index.mapper.IdFieldMapper; import org.elasticsearch.index.mapper.IgnoredFieldMapper; import org.elasticsearch.index.mapper.IndexFieldMapper; @@ -130,7 +128,6 @@ public static Map getMappers(List mappe mappers.put(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser()); mappers.put(FieldAliasMapper.CONTENT_TYPE, new FieldAliasMapper.TypeParser()); mappers.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser()); - mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); for (MapperPlugin mapperPlugin : mapperPlugins) { for (Map.Entry entry : mapperPlugin.getMappers().entrySet()) { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java index 8e54a92a22228..bc7741c2a78d9 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java @@ -36,6 +36,7 @@ import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.InternalSettingsPlugin; import java.io.IOException; @@ -61,7 +62,7 @@ public class DocumentParserTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class); + return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class); } public void testFieldDisabled() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java index 8d664e0c752d1..2fed099dc29f0 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java @@ -33,12 +33,12 @@ import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.junit.Before; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -54,7 +54,7 @@ public class FieldFilterMapperPluginTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return Collections.singleton(FieldFilterPlugin.class); + return List.of(FieldFilterPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Before diff --git a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java index e14d04eb7d664..00496acf1d012 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java @@ -28,6 +28,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.test.InternalSettingsPlugin; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.Collection; @@ -42,7 +43,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class); + return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class); } public void testDefaultConfiguration() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java index aaabf3f9edbf0..9236447b2f1cd 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java @@ -39,6 +39,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.test.InternalSettingsPlugin; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.Collection; @@ -56,7 +57,7 @@ public class LegacyGeoShapeFieldMapperTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class); + return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class); } public void testDefaultConfiguration() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java index 0244709388b08..db1af8d0baf95 100644 --- a/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java @@ -49,6 +49,7 @@ import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.rest.yaml.ObjectPath; import java.io.IOException; @@ -71,7 +72,7 @@ public class TermsSetQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(CustomScriptPlugin.class); + return List.of(CustomScriptPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java index b565778b35962..0410d544aa0d3 100644 --- a/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java @@ -53,6 +53,7 @@ import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.hamcrest.Matcher; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -88,7 +89,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(TestPlugin.class); + return List.of(TestPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java b/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java index 6b00f4a24ebb4..475ed0eec4ca9 100644 --- a/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java +++ b/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java @@ -25,9 +25,14 @@ import org.elasticsearch.common.geo.builders.EnvelopeBuilder; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.locationtech.jts.geom.Coordinate; +import java.util.Collection; +import java.util.Collections; + import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.geoIntersectionQuery; @@ -37,6 +42,10 @@ import static org.hamcrest.Matchers.nullValue; public abstract class GeoQueryTests extends ESSingleNodeTestCase { + @Override + protected Collection> getPlugins() { + return Collections.singleton(TestGeoShapeFieldMapperPlugin.class); + } protected abstract XContentBuilder createDefaultMapping() throws Exception; diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java index a424501a15296..22ccc0a5a3b29 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java @@ -148,7 +148,7 @@ protected static Index getIndex() { } protected Collection> getPlugins() { - return Collections.emptyList(); + return Collections.singletonList(TestGeoShapeFieldMapperPlugin.class); } protected void initializeAdditionalMappings(MapperService mapperService) throws IOException { diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java b/test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java new file mode 100644 index 0000000000000..a269ad437a99a --- /dev/null +++ b/test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java @@ -0,0 +1,46 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.test; + +import org.elasticsearch.index.mapper.AbstractGeometryFieldMapper; +import org.elasticsearch.index.mapper.GeoShapeFieldMapper; +import org.elasticsearch.index.mapper.Mapper; +import org.elasticsearch.plugins.MapperPlugin; +import org.elasticsearch.plugins.Plugin; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Some tests depend on the {@link org.elasticsearch.index.mapper.GeoShapeFieldMapper}. + * This mapper is registered in the spatial-extras module, but used in many integration + * tests in server code. The goal is to migrate all of the spatial/geo pieces to the spatial-extras + * module such that no tests in server depend on this test plugin + */ +@Deprecated +public class TestGeoShapeFieldMapperPlugin extends Plugin implements MapperPlugin { + + @Override + public Map getMappers() { + Map mappers = new LinkedHashMap<>(); + mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); + return Collections.unmodifiableMap(mappers); + } +} From fe11a26684d2e834877eaa3aca7e51dac3501384 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 13:43:38 -0700 Subject: [PATCH 02/21] cover more test cases and take ownership of exists yaml tests --- .../query/RankFeatureQueryBuilderTests.java | 4 +- .../join/aggregations/ChildrenTests.java | 5 +- .../join/aggregations/ParentTests.java | 5 +- .../join/query/HasChildQueryBuilderTests.java | 4 +- .../query/HasParentQueryBuilderTests.java | 4 +- .../join/query/ParentIdQueryBuilderTests.java | 5 +- .../rest-api-spec/test/geo_shape/10_basic.yml | 15 +++- .../test/search/160_exists_query.yml | 75 ------------------- 8 files changed, 31 insertions(+), 86 deletions(-) diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java b/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java index 78e130b0d00fe..1fb34a7d927d5 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java +++ b/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java @@ -30,11 +30,11 @@ import org.elasticsearch.index.query.RankFeatureQueryBuilder.ScoreFunction; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import static org.hamcrest.CoreMatchers.instanceOf; @@ -52,7 +52,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws @Override protected Collection> getPlugins() { - return Collections.singleton(MapperExtrasPlugin.class); + return List.of(MapperExtrasPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java index 58d315d2d43ed..66c11e25833bb 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java @@ -22,15 +22,16 @@ import org.elasticsearch.join.ParentJoinPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.aggregations.BaseAggregationTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.util.Collection; -import java.util.Collections; +import java.util.List; public class ChildrenTests extends BaseAggregationTestCase { @Override protected Collection> getPlugins() { - return Collections.singleton(ParentJoinPlugin.class); + return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java index 1df36d28b49e5..05c76833ab034 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java @@ -20,17 +20,18 @@ package org.elasticsearch.join.aggregations; import java.util.Collection; -import java.util.Collections; +import java.util.List; import org.elasticsearch.join.ParentJoinPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.aggregations.BaseAggregationTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; public class ParentTests extends BaseAggregationTestCase { @Override protected Collection> getPlugins() { - return Collections.singleton(ParentJoinPlugin.class); + return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java index d41acf75d1298..7c954771eda7c 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java @@ -56,12 +56,14 @@ import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.VersionUtils; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -85,7 +87,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singletonList(ParentJoinPlugin.class); + return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java index 53477e9e8349d..c8215cb8408d5 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java @@ -44,12 +44,14 @@ import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.VersionUtils; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -70,7 +72,7 @@ public class HasParentQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singletonList(ParentJoinPlugin.class); + return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java index 27fbce48d9fae..8b3fbbd85e6c8 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java @@ -38,11 +38,12 @@ import org.elasticsearch.join.ParentJoinPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.hamcrest.Matchers; import java.io.IOException; import java.util.Collection; -import java.util.Collections; +import java.util.List; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.CoreMatchers.containsString; @@ -61,7 +62,7 @@ public class ParentIdQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singletonList(ParentJoinPlugin.class); + return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml b/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml index 6b4c85f107d1d..7ddfa5832d4c5 100644 --- a/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml +++ b/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml @@ -21,7 +21,7 @@ setup: indices.refresh: {} --- -"Geo Shape Query": +"Test Geo Shape Query": - do: search: @@ -44,3 +44,16 @@ setup: - match: hits.hits.0._id: "1" + +--- +"Test Exists Query on geo_shape field": + - do: + search: + rest_total_hits_as_int: true + index: test + body: + query: + exists: + field: location + + - match: {hits.total: 1} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml index 183fefee80b96..4472e0674f265 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml @@ -18,8 +18,6 @@ setup: type: date geo_point: type: geo_point - geo_shape: - type: geo_shape ip: type: ip keyword: @@ -59,9 +57,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -87,9 +82,6 @@ setup: boolean: false date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -115,9 +107,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -157,8 +146,6 @@ setup: geo_point: type: geo_point doc_values: false - geo_shape: - type: geo_shape ip: type: ip doc_values: false @@ -210,9 +197,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -238,9 +222,6 @@ setup: boolean: false date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -266,9 +247,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -318,8 +296,6 @@ setup: type: date geo_point: type: geo_point - geo_shape: - type: geo_shape ip: type: ip keyword: @@ -404,19 +380,6 @@ setup: - match: {hits.total: 3} ---- -"Test exists query on mapped geo_shape field": - - do: - search: - rest_total_hits_as_int: true - index: test - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 3} - --- "Test exists query on mapped ip field": - do: @@ -718,19 +681,6 @@ setup: - match: {hits.total: 0} ---- -"Test exists query on unmapped geo_shape field": - - do: - search: - rest_total_hits_as_int: true - index: test-unmapped - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 0} - --- "Test exists query on unmapped ip field": - do: @@ -939,19 +889,6 @@ setup: - match: {hits.total: 0} ---- -"Test exists query on geo_shape field in empty index": - - do: - search: - rest_total_hits_as_int: true - index: test-empty - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 0} - --- "Test exists query on ip field in empty index": - do: @@ -1160,18 +1097,6 @@ setup: - match: {hits.total: 3} ---- -"Test exists query on mapped geo_shape field with no doc values": - - do: - search: - rest_total_hits_as_int: true - index: test-no-dv - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 3} --- "Test exists query on mapped ip field with no doc values": From fae51f52ba2fe002e63820b9f633857601c22133 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 14:06:31 -0700 Subject: [PATCH 03/21] more tests --- .../elasticsearch/percolator/PercolateQueryBuilderTests.java | 3 ++- x-pack/plugin/enrich/build.gradle | 1 + .../java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java index 48ca69b6b97a8..8d3f894846afe 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java @@ -42,6 +42,7 @@ import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.hamcrest.Matchers; import java.io.IOException; @@ -84,7 +85,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(PercolatorPlugin.class); + return List.of(PercolatorPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/x-pack/plugin/enrich/build.gradle b/x-pack/plugin/enrich/build.gradle index 12ca16115f8d6..02307d8c24093 100644 --- a/x-pack/plugin/enrich/build.gradle +++ b/x-pack/plugin/enrich/build.gradle @@ -14,6 +14,7 @@ dependencies { testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: ':modules:ingest-common') testCompile project(path: ':modules:lang-mustache') + testCompile project(path: ':modules:spatial-extras') testCompile project(path: xpackModule('monitoring'), configuration: 'testArtifacts') } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java index aaa0ef2b1392a..449fea2e09127 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.ingest.common.IngestCommonPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.mustache.MustachePlugin; +import org.elasticsearch.spatial.SpatialExtrasPlugin; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.xpack.core.enrich.EnrichPolicy; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction; @@ -50,7 +51,8 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return List.of(LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class); + return List.of(LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class, + SpatialExtrasPlugin.class); } @Override From e7d8efdc0820259dd987792b71f718721426b36c Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 15:22:36 -0700 Subject: [PATCH 04/21] more fixes --- .../org/elasticsearch/test/AbstractBuilderTestCase.java | 1 + .../org/elasticsearch/xpack/enrich/BasicEnrichTests.java | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java index 22ccc0a5a3b29..5f7c732d70db6 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java @@ -147,6 +147,7 @@ protected static Index getIndex() { return index; } + @SuppressWarnings("deprecation") // dependencies in server for geo_shape field should be decoupled protected Collection> getPlugins() { return Collections.singletonList(TestGeoShapeFieldMapperPlugin.class); } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java index 449fea2e09127..09ae404e08c10 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java @@ -51,8 +51,13 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return List.of(LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class, - SpatialExtrasPlugin.class); + return List.of( + LocalStateEnrich.class, + ReindexPlugin.class, + IngestCommonPlugin.class, + MustachePlugin.class, + SpatialExtrasPlugin.class + ); } @Override From ff1024d1acd96c4a17a628b83fd604ffe8cb67ac Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 15:38:03 -0700 Subject: [PATCH 05/21] fix enrich test --- .../xpack/enrich/EnrichPolicyRunnerTests.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index a4c2bd5ce60f8..ca0e68417863c 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -38,6 +38,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.spatial.SpatialExtrasPlugin; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskAwareRequest; import org.elasticsearch.tasks.TaskId; @@ -70,7 +71,11 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return List.of(ReindexPlugin.class, IngestCommonPlugin.class); + return List.of( + ReindexPlugin.class, + IngestCommonPlugin.class, + SpatialExtrasPlugin.class + ); } private static ThreadPool testThreadPool; From 99d4240eb9b54ad7afd360db78a30c5c183a81d9 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 15:43:55 -0700 Subject: [PATCH 06/21] add empty unit tests --- .../org/elasticsearch/spatial/SpatialExtrasTests.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java diff --git a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java b/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java new file mode 100644 index 0000000000000..fdb2a4147c379 --- /dev/null +++ b/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java @@ -0,0 +1,10 @@ +package org.elasticsearch.spatial; + +import org.elasticsearch.test.ESTestCase; + +public class SpatialExtrasTests extends ESTestCase { + + public void testStub() { + // the build expects unit tests to exist in a module, so here one is. + } +} From 3d9fb1227a1a21544454bb811f1de39fa7ba5a45 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 15:44:38 -0700 Subject: [PATCH 07/21] add license header --- .../spatial/SpatialExtrasTests.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java b/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java index fdb2a4147c379..ed86f111edebe 100644 --- a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java +++ b/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java @@ -1,3 +1,21 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.elasticsearch.spatial; import org.elasticsearch.test.ESTestCase; From 136a2cf2e7351b30c54d35cd68422293da2996aa Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 16:21:37 -0700 Subject: [PATCH 08/21] moar --- .../main/java/org/elasticsearch/test/ESIntegTestCase.java | 1 + .../elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 3116792c502d6..2fb48fbc6e7b7 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -1795,6 +1795,7 @@ protected Collection> getMockPlugins() { mocks.add(TestSeedPlugin.class); mocks.add(AssertActionNamePlugin.class); mocks.add(MockScriptService.TestPlugin.class); + mocks.add(TestGeoShapeFieldMapperPlugin.class); return Collections.unmodifiableList(mocks); } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index ca0e68417863c..a0b9d451e7079 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -71,11 +71,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return List.of( - ReindexPlugin.class, - IngestCommonPlugin.class, - SpatialExtrasPlugin.class - ); + return List.of(ReindexPlugin.class, IngestCommonPlugin.class, SpatialExtrasPlugin.class); } private static ThreadPool testThreadPool; From d7f2279943a71b176efad56bc274ce48ffd54fa9 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 16:25:05 -0700 Subject: [PATCH 09/21] singletonmap --- .../java/org/elasticsearch/spatial/SpatialExtrasPlugin.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java b/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java index 3f2b505cd5b06..3a8b96a144751 100644 --- a/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java +++ b/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java @@ -26,15 +26,12 @@ import org.elasticsearch.plugins.Plugin; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.Map; public class SpatialExtrasPlugin extends Plugin implements MapperPlugin { @Override public Map getMappers() { - Map mappers = new LinkedHashMap<>(); - mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); - return Collections.unmodifiableMap(mappers); + return Collections.singletonMap(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); } } From ad4a4bdd1f1cb7a3b6e33cdb4b289d22992c2a96 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 13 Mar 2020 16:44:40 -0700 Subject: [PATCH 10/21] List.of -> Arrays.asList --- .../index/query/RankFeatureQueryBuilderTests.java | 3 ++- .../org/elasticsearch/join/aggregations/ChildrenTests.java | 4 ++-- .../java/org/elasticsearch/join/aggregations/ParentTests.java | 4 ++-- .../elasticsearch/join/query/HasChildQueryBuilderTests.java | 4 ++-- .../elasticsearch/join/query/HasParentQueryBuilderTests.java | 4 ++-- .../elasticsearch/join/query/ParentIdQueryBuilderTests.java | 4 ++-- .../elasticsearch/percolator/PercolateQueryBuilderTests.java | 2 +- .../index/mapper/FieldFilterMapperPluginTests.java | 2 +- .../elasticsearch/index/query/TermsSetQueryBuilderTests.java | 2 +- .../query/functionscore/FunctionScoreQueryBuilderTests.java | 2 +- .../java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java | 3 ++- .../elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java | 3 ++- 12 files changed, 20 insertions(+), 17 deletions(-) diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java b/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java index 1fb34a7d927d5..2e12f58beda1a 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java +++ b/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -52,7 +53,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws @Override protected Collection> getPlugins() { - return List.of(MapperExtrasPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(MapperExtrasPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java index 66c11e25833bb..bf016291a166c 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java @@ -24,14 +24,14 @@ import org.elasticsearch.search.aggregations.BaseAggregationTestCase; import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; +import java.util.Arrays; import java.util.Collection; -import java.util.List; public class ChildrenTests extends BaseAggregationTestCase { @Override protected Collection> getPlugins() { - return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java index 05c76833ab034..a70af3fd2c28d 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java @@ -19,8 +19,8 @@ package org.elasticsearch.join.aggregations; +import java.util.Arrays; import java.util.Collection; -import java.util.List; import org.elasticsearch.join.ParentJoinPlugin; import org.elasticsearch.plugins.Plugin; @@ -31,7 +31,7 @@ public class ParentTests extends BaseAggregationTestCase> getPlugins() { - return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java index 7c954771eda7c..bd4788efc1603 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java @@ -60,10 +60,10 @@ import org.elasticsearch.test.VersionUtils; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -87,7 +87,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java index c8215cb8408d5..310072223beb7 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java @@ -48,10 +48,10 @@ import org.elasticsearch.test.VersionUtils; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -72,7 +72,7 @@ public class HasParentQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java index 8b3fbbd85e6c8..93b7edf1e8ddc 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java @@ -42,8 +42,8 @@ import org.hamcrest.Matchers; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; -import java.util.List; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.CoreMatchers.containsString; @@ -62,7 +62,7 @@ public class ParentIdQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return List.of(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java index 8d3f894846afe..644979b776f48 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java @@ -85,7 +85,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return List.of(PercolatorPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(PercolatorPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java index 2fed099dc29f0..0029a57fc5da0 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java @@ -54,7 +54,7 @@ public class FieldFilterMapperPluginTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return List.of(FieldFilterPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(FieldFilterPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Before diff --git a/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java index db1af8d0baf95..2d810fcac5ac5 100644 --- a/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java @@ -72,7 +72,7 @@ public class TermsSetQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return List.of(CustomScriptPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(CustomScriptPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java index 0410d544aa0d3..cae3cae5ee16b 100644 --- a/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java @@ -89,7 +89,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return List.of(TestPlugin.class, TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(TestPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java index 09ae404e08c10..eac277bb19a33 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java @@ -31,6 +31,7 @@ import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyStatus; import org.elasticsearch.xpack.core.enrich.action.PutEnrichPolicyAction; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -51,7 +52,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return List.of( + return Arrays.asList( LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index a0b9d451e7079..04325bd6017f0 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -51,6 +51,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -71,7 +72,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return List.of(ReindexPlugin.class, IngestCommonPlugin.class, SpatialExtrasPlugin.class); + return Arrays.asList(ReindexPlugin.class, IngestCommonPlugin.class, SpatialExtrasPlugin.class); } private static ThreadPool testThreadPool; From c954df7df5a5c502960e9330bfa9a3b36d3a8d3d Mon Sep 17 00:00:00 2001 From: Nicholas Knize Date: Wed, 18 Mar 2020 15:17:12 -0500 Subject: [PATCH 11/21] refactor spatial-extras to geo --- modules/{spatial-extras => geo}/build.gradle | 4 ++-- .../src/main/java/org/elasticsearch/geo/GeoPlugin.java} | 4 ++-- .../org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java} | 6 +++--- .../src/test/java/org/elasticsearch/geo/GeoTests.java} | 4 ++-- .../resources/rest-api-spec/test/geo_shape/10_basic.yml | 0 x-pack/plugin/enrich/build.gradle | 2 +- .../org/elasticsearch/xpack/enrich/BasicEnrichTests.java | 4 ++-- .../elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) rename modules/{spatial-extras => geo}/build.gradle (82%) rename modules/{spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java => geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java} (92%) rename modules/{spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java => geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java} (85%) rename modules/{spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java => geo/src/test/java/org/elasticsearch/geo/GeoTests.java} (91%) rename modules/{spatial-extras => geo}/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml (100%) diff --git a/modules/spatial-extras/build.gradle b/modules/geo/build.gradle similarity index 82% rename from modules/spatial-extras/build.gradle rename to modules/geo/build.gradle index b95fd9495d6cc..7a8ef467aa268 100644 --- a/modules/spatial-extras/build.gradle +++ b/modules/geo/build.gradle @@ -18,6 +18,6 @@ */ esplugin { - description 'Placeholder plugin for spatial features in ES. only registers geo-shape field mapper for now' - classname 'org.elasticsearch.spatial.SpatialExtrasPlugin' + description 'Placeholder plugin for geospatial features in ES. only registers geo_shape field mapper for now' + classname 'org.elasticsearch.geo.GeoPlugin' } diff --git a/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java b/modules/geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java similarity index 92% rename from modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java rename to modules/geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java index 3a8b96a144751..acb8690551096 100644 --- a/modules/spatial-extras/src/main/java/org/elasticsearch/spatial/SpatialExtrasPlugin.java +++ b/modules/geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.spatial; +package org.elasticsearch.geo; import org.elasticsearch.index.mapper.AbstractGeometryFieldMapper; import org.elasticsearch.index.mapper.GeoShapeFieldMapper; @@ -28,7 +28,7 @@ import java.util.Collections; import java.util.Map; -public class SpatialExtrasPlugin extends Plugin implements MapperPlugin { +public class GeoPlugin extends Plugin implements MapperPlugin { @Override public Map getMappers() { diff --git a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java b/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java similarity index 85% rename from modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java rename to modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java index 13bf47c2c202a..f644c2162a9e5 100644 --- a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasClientYamlTestSuiteIT.java +++ b/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.spatial; +package org.elasticsearch.geo; import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; @@ -25,9 +25,9 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; /** Runs yaml rest tests */ -public class SpatialExtrasClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { +public class GeoClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { - public SpatialExtrasClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { + public GeoClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { super(testCandidate); } diff --git a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java b/modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java similarity index 91% rename from modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java rename to modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java index ed86f111edebe..056b485393082 100644 --- a/modules/spatial-extras/src/test/java/org/elasticsearch/spatial/SpatialExtrasTests.java +++ b/modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.elasticsearch.spatial; +package org.elasticsearch.geo; import org.elasticsearch.test.ESTestCase; -public class SpatialExtrasTests extends ESTestCase { +public class GeoTests extends ESTestCase { public void testStub() { // the build expects unit tests to exist in a module, so here one is. diff --git a/modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml b/modules/geo/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml similarity index 100% rename from modules/spatial-extras/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml rename to modules/geo/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml diff --git a/x-pack/plugin/enrich/build.gradle b/x-pack/plugin/enrich/build.gradle index 02307d8c24093..95ed9b170b7b7 100644 --- a/x-pack/plugin/enrich/build.gradle +++ b/x-pack/plugin/enrich/build.gradle @@ -14,7 +14,7 @@ dependencies { testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: ':modules:ingest-common') testCompile project(path: ':modules:lang-mustache') - testCompile project(path: ':modules:spatial-extras') + testCompile project(path: ':modules:geo') testCompile project(path: xpackModule('monitoring'), configuration: 'testArtifacts') } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java index eac277bb19a33..fab01845aa5e4 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java @@ -19,11 +19,11 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.index.reindex.ReindexPlugin; import org.elasticsearch.ingest.common.IngestCommonPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.mustache.MustachePlugin; -import org.elasticsearch.spatial.SpatialExtrasPlugin; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.xpack.core.enrich.EnrichPolicy; import org.elasticsearch.xpack.core.enrich.action.EnrichStatsAction; @@ -57,7 +57,7 @@ protected Collection> getPlugins() { ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class, - SpatialExtrasPlugin.class + GeoPlugin.class ); } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index 04325bd6017f0..8c84d43a0d578 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -17,6 +17,7 @@ import org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest; import org.elasticsearch.action.admin.indices.segments.ShardSegments; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchRequest; @@ -38,7 +39,6 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.spatial.SpatialExtrasPlugin; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskAwareRequest; import org.elasticsearch.tasks.TaskId; @@ -72,7 +72,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return Arrays.asList(ReindexPlugin.class, IngestCommonPlugin.class, SpatialExtrasPlugin.class); + return Arrays.asList(ReindexPlugin.class, IngestCommonPlugin.class, GeoPlugin.class); } private static ThreadPool testThreadPool; From 3daf04645b39dacf408bd97b0198266154726864 Mon Sep 17 00:00:00 2001 From: Nicholas Knize Date: Wed, 18 Mar 2020 15:28:40 -0500 Subject: [PATCH 12/21] spotless apply --- .../org/elasticsearch/xpack/enrich/BasicEnrichTests.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java index fab01845aa5e4..27786d16888d8 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java @@ -52,13 +52,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return Arrays.asList( - LocalStateEnrich.class, - ReindexPlugin.class, - IngestCommonPlugin.class, - MustachePlugin.class, - GeoPlugin.class - ); + return Arrays.asList(LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class, GeoPlugin.class); } @Override From e45d92c30c797aec328adc3017d636e015000f9f Mon Sep 17 00:00:00 2001 From: Nicholas Knize Date: Mon, 23 Mar 2020 15:10:19 -0500 Subject: [PATCH 13/21] added TestGeoShapeFieldMapperPlugin to PinnedQueryBuilderTests --- .../xpack/searchbusinessrules/PinnedQueryBuilderTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java b/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java index e91ef3a5d76f9..73b076623054c 100644 --- a/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java +++ b/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java @@ -22,6 +22,7 @@ import org.elasticsearch.index.query.TermQueryBuilder; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.ArrayList; @@ -104,6 +105,7 @@ protected void doAssertLuceneQuery(PinnedQueryBuilder queryBuilder, Query query, protected Collection> getPlugins() { List> classpathPlugins = new ArrayList<>(); classpathPlugins.add(SearchBusinessRules.class); + classpathPlugins.add(TestGeoShapeFieldMapperPlugin.class); return classpathPlugins; } From 4329d0e5c5d9781e6697cefef10376e5f3708b0d Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Tue, 31 Mar 2020 16:10:32 -0700 Subject: [PATCH 14/21] fix checkstyle --- .../java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java b/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java index f644c2162a9e5..5835e2114b08d 100644 --- a/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java +++ b/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java @@ -36,4 +36,3 @@ public static Iterable parameters() throws Exception { return ESClientYamlSuiteTestCase.createParameters(); } } - From 40ce9d7335f27c709a23e81e2750546f18836bfd Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Tue, 31 Mar 2020 16:41:54 -0700 Subject: [PATCH 15/21] fix percolator query test --- .../elasticsearch/percolator/PercolatorQuerySearchIT.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index f7701bfa96be4..56aad3088b177 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -36,12 +36,15 @@ import org.elasticsearch.index.query.MultiMatchQueryBuilder; import org.elasticsearch.index.query.Operator; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -71,6 +74,11 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase { + @Override + protected Collection> nodePlugins() { + return Collections.singleton(TestGeoShapeFieldMapperPlugin.class); + } + public void testPercolatorQuery() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") .setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") From 64c0bea9caccbc6e5929e64ad5002ab295cae21e Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Wed, 1 Apr 2020 16:40:37 -0700 Subject: [PATCH 16/21] try to make Percolator test happy --- modules/percolator/build.gradle | 4 +++- .../percolator/PercolatorQuerySearchIT.java | 12 ++++++++---- .../java/org/elasticsearch/test/ESIntegTestCase.java | 9 ++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/percolator/build.gradle b/modules/percolator/build.gradle index ae19823db1542..cd873c88ef528 100644 --- a/modules/percolator/build.gradle +++ b/modules/percolator/build.gradle @@ -24,13 +24,15 @@ esplugin { dependencies { testCompile project(path: ':modules:parent-join', configuration: 'runtime') + testCompile project(path: ':modules:geo', configuration: 'runtime') } restResources { restApi { - includeCore '_common', 'indices', 'index', 'search', 'msearch' + includeCore '_common', 'indices', 'index', 'search', 'msearch' } } + dependencyLicenses { // Don't check the client's license. We know it. dependencies = project.configurations.runtime.fileCollection { diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index 56aad3088b177..ac859f7bf6169 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.query.MatchPhraseQueryBuilder; import org.elasticsearch.index.query.MultiMatchQueryBuilder; @@ -40,8 +41,6 @@ import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; - import java.io.IOException; import java.util.Arrays; import java.util.Collection; @@ -74,9 +73,14 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase { + @Override + protected boolean addMockGeoShapeFieldMapper() { + return false; + } + @Override protected Collection> nodePlugins() { - return Collections.singleton(TestGeoShapeFieldMapperPlugin.class); + return Arrays.asList(PercolatorPlugin.class, GeoPlugin.class); } public void testPercolatorQuery() throws Exception { @@ -964,7 +968,7 @@ public void testWrappedWithConstantScore() throws Exception { BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()), XContentType.JSON)).get(); assertEquals(1, response.getHits().getTotalHits().value); - + response = client().prepareSearch("test").setQuery(new PercolateQueryBuilder("q", BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()), XContentType.JSON)).addSort("_doc", SortOrder.ASC).get(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 34d016ca47bfa..7725e0efb67ec 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -1847,6 +1847,11 @@ protected boolean addMockInternalEngine() { return true; } + /** Returns {@code true} iff this test cluster should use a dummy geo_shape field mapper */ + protected boolean addMockGeoShapeFieldMapper() { + return true; + } + /** * Returns a function that allows to wrap / filter all clients that are exposed by the test cluster. This is useful * for debugging or request / response pre and post processing. It also allows to intercept all calls done by the test @@ -1889,7 +1894,9 @@ protected Collection> getMockPlugins() { mocks.add(TestSeedPlugin.class); mocks.add(AssertActionNamePlugin.class); mocks.add(MockScriptService.TestPlugin.class); - mocks.add(TestGeoShapeFieldMapperPlugin.class); + if (addMockGeoShapeFieldMapper()) { + mocks.add(TestGeoShapeFieldMapperPlugin.class); + } return Collections.unmodifiableList(mocks); } From 558d32df3250300df50869c7d167bf5e988db61c Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Wed, 1 Apr 2020 18:00:13 -0700 Subject: [PATCH 17/21] make gradle happy --- modules/percolator/build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/percolator/build.gradle b/modules/percolator/build.gradle index cd873c88ef528..42221a0780c03 100644 --- a/modules/percolator/build.gradle +++ b/modules/percolator/build.gradle @@ -27,6 +27,18 @@ dependencies { testCompile project(path: ':modules:geo', configuration: 'runtime') } +tasks.named('integTestRunner').configure { + exclude '**/PercolatorQuerySearchIT.class' +} + +tasks.register('internalClusterTest', Test) { + include '**/PercolatorQuerySearchIT.class' +} + +tasks.named('check').configure { + dependsOn 'internalClusterTest' +} + restResources { restApi { includeCore '_common', 'indices', 'index', 'search', 'msearch' From 252d8e101e15f5e54f1e82e553f9f3abb5c15144 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Wed, 1 Apr 2020 19:25:45 -0700 Subject: [PATCH 18/21] fix ShapeQueryBuilderTests --- x-pack/plugin/spatial/build.gradle | 1 + .../xpack/spatial/index/query/ShapeQueryBuilderTests.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/spatial/build.gradle b/x-pack/plugin/spatial/build.gradle index aa5f3ff932874..7daf9240cd503 100644 --- a/x-pack/plugin/spatial/build.gradle +++ b/x-pack/plugin/spatial/build.gradle @@ -12,6 +12,7 @@ esplugin { dependencies { compileOnly project(path: xpackModule('core'), configuration: 'default') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') + testCompile project(path: ':modules:geo', configuration: 'runtime') } licenseHeaders { diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java index a12bbcd5232bb..84a4062ce81e0 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.geometry.Geometry; import org.elasticsearch.geometry.ShapeType; import org.elasticsearch.index.get.GetResult; @@ -40,8 +41,8 @@ import org.junit.After; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.instanceOf; @@ -63,7 +64,7 @@ public class ShapeQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(SpatialPlugin.class); + return Arrays.asList(SpatialPlugin.class, GeoPlugin.class); } @Override From 4ccb497ba4e99e01a9ef901fefea5831aef4fba5 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Thu, 2 Apr 2020 13:27:25 -0700 Subject: [PATCH 19/21] no client-only nodes in percolator tests --- .../org/elasticsearch/percolator/PercolatorQuerySearchIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index ac859f7bf6169..f275423130533 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -71,6 +71,7 @@ import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.IsNull.notNullValue; +@ESIntegTestCase.ClusterScope(numClientNodes = 1) public class PercolatorQuerySearchIT extends ESIntegTestCase { @Override From f1a4136d2bbe36461cfdd5484dc41f6d67657623 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 3 Apr 2020 10:15:51 -0700 Subject: [PATCH 20/21] stop using smile in percolator test, no valid UTF8 --- .../org/elasticsearch/percolator/PercolatorQuerySearchIT.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index f275423130533..b238bc3ec453b 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -71,7 +71,6 @@ import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.IsNull.notNullValue; -@ESIntegTestCase.ClusterScope(numClientNodes = 1) public class PercolatorQuerySearchIT extends ESIntegTestCase { @Override @@ -852,7 +851,7 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { BytesReference.bytes(yamlBuilder().startObject().field("field1", "c").endObject()), XContentType.YAML))) .add(client().prepareSearch("test") .setQuery(new PercolateQueryBuilder("query", - BytesReference.bytes(smileBuilder().startObject().field("field1", "b c").endObject()), XContentType.SMILE))) + BytesReference.bytes(jsonBuilder().startObject().field("field1", "b c").endObject()), XContentType.JSON))) .add(client().prepareSearch("test") .setQuery(new PercolateQueryBuilder("query", BytesReference.bytes(jsonBuilder().startObject().field("field1", "d").endObject()), XContentType.JSON))) From 61f2b1357b3978eab337f6c24934dd18fa79b81f Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Fri, 3 Apr 2020 11:17:27 -0700 Subject: [PATCH 21/21] fix unsused imports --- .../org/elasticsearch/percolator/PercolatorQuerySearchIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index b238bc3ec453b..317fee82263ea 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -47,7 +47,6 @@ import java.util.Collections; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.common.xcontent.XContentFactory.smileBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.yamlBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;