Ensure all query builder tests consider older versions. (#66401)

This PR removes outdated overrides in some tests that prevent them from testing
older index versions. Also removes an old comment + logic from
AggregatorFactoriesTests.
This commit is contained in:
Julie Tibshirani 2020-12-16 09:19:26 -08:00
parent a370104535
commit 24c0f01543
5 changed files with 1 additions and 43 deletions

View File

@ -33,7 +33,6 @@ import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
import org.apache.lucene.search.similarities.Similarity;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
@ -90,14 +89,6 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase<HasChildQue
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
}
@Override
protected Settings createTestIndexSettings() {
return Settings.builder()
.put(super.createTestIndexSettings())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
}
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
similarity = randomFrom("boolean", "BM25");

View File

@ -24,10 +24,8 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.IdsQueryBuilder;
@ -75,14 +73,6 @@ public class HasParentQueryBuilderTests extends AbstractQueryTestCase<HasParentQ
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
}
@Override
protected Settings createTestIndexSettings() {
return Settings.builder()
.put(super.createTestIndexSettings())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
}
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
XContentBuilder mapping = jsonBuilder().startObject().startObject("_doc").startObject("properties")

View File

@ -26,11 +26,8 @@ import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.QueryShardContext;
@ -65,14 +62,6 @@ public class ParentIdQueryBuilderTests extends AbstractQueryTestCase<ParentIdQue
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
}
@Override
protected Settings createTestIndexSettings() {
return Settings.builder()
.put(super.createTestIndexSettings())
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
}
@Override
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
XContentBuilder mapping = jsonBuilder().startObject().startObject("_doc").startObject("properties")

View File

@ -48,10 +48,8 @@ import org.locationtech.jts.geom.Coordinate;
import java.io.IOException;
import static org.apache.lucene.util.LuceneTestCase.random;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;

View File

@ -64,23 +64,13 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
public class AggregatorFactoriesTests extends ESTestCase {
private String[] currentTypes;
private NamedXContentRegistry xContentRegistry;
@Override
public void setUp() throws Exception {
super.setUp();
// we have to prefer CURRENT since with the range of versions we support
// it's rather unlikely to get the current actually.
Settings settings = Settings.builder().put("node.name", AbstractQueryTestCase.class.toString())
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
// create some random type with some default field, those types will
// stick around for all of the subclasses
currentTypes = new String[randomIntBetween(0, 5)];
for (int i = 0; i < currentTypes.length; i++) {
String type = randomAlphaOfLengthBetween(1, 10);
currentTypes[i] = type;
}
xContentRegistry = new NamedXContentRegistry(new SearchModule(settings, false, emptyList()).getNamedXContents());
}