Skip to content

Commit

Permalink
Merge branch 'master' into ccr
Browse files Browse the repository at this point in the history
* master:
  Add hook to skip asserting x-content equivalence (#33114)
  Muted testListenersThrowingExceptionsDoNotCauseOtherListenersToBeSkipped
  [Rollup] Move getMetadata() methods out of rollup config objects (#32579)
  Muted testEmptyAuthorizedIndicesSearchForAllDisallowNoIndices
  Update Google Cloud Storage Library for Java (#32940)
  Remove unsupported Version.V_5_* (#32937)
  • Loading branch information
jasontedor committed Aug 24, 2018
2 parents b0f22d6 + 619e0b2 commit 91a052b
Show file tree
Hide file tree
Showing 250 changed files with 706 additions and 3,287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ class VersionCollection {
break
}
}
// caveat 0 - now dip back 2 versions to get the last supported snapshot version of the line
Version highestMinor = getHighestPreviousMinor(currentVersion.major - 1)
maintenanceBugfixSnapshot = replaceAsSnapshot(highestMinor)
// caveat 0 - the last supported snapshot of the line is on a version that we don't support (N-2)
maintenanceBugfixSnapshot = null
} else {
// caveat 3 did not apply. version is not a X.0.0, so we are somewhere on a X.Y line
// only check till minor == 0 of the major
Expand Down Expand Up @@ -293,7 +292,8 @@ class VersionCollection {
* If you have a list [5.0.2, 5.1.2, 6.0.1, 6.1.1] and pass in 6 for the nextMajorVersion, it will return you 5.1.2
*/
private Version getHighestPreviousMinor(Integer nextMajorVersion) {
return versionSet.headSet(Version.fromString("${nextMajorVersion}.0.0")).last()
SortedSet<Version> result = versionSet.headSet(Version.fromString("${nextMajorVersion}.0.0"))
return result.isEmpty() ? null : result.last()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class VersionCollectionTests extends GradleUnitTestCase {
assertEquals(vc.nextMinorSnapshot, Version.fromString("6.3.0-SNAPSHOT"))
assertEquals(vc.stagedMinorSnapshot, Version.fromString("6.2.0-SNAPSHOT"))
assertEquals(vc.nextBugfixSnapshot, Version.fromString("6.1.1-SNAPSHOT"))
assertEquals(vc.maintenanceBugfixSnapshot, Version.fromString("5.2.1-SNAPSHOT"))
assertNull(vc.maintenanceBugfixSnapshot)

vc.indexCompatible.containsAll(vc.versions)

Expand Down Expand Up @@ -65,7 +65,7 @@ class VersionCollectionTests extends GradleUnitTestCase {
assertEquals(vc.nextMinorSnapshot, Version.fromString("6.3.0-SNAPSHOT"))
assertEquals(vc.stagedMinorSnapshot, null)
assertEquals(vc.nextBugfixSnapshot, Version.fromString("6.2.1-SNAPSHOT"))
assertEquals(vc.maintenanceBugfixSnapshot, Version.fromString("5.2.1-SNAPSHOT"))
assertNull(vc.maintenanceBugfixSnapshot)

vc.indexCompatible.containsAll(vc.versions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testNGramDeprecationWarning() throws IOException {
public void testNGramNoDeprecationWarningPre6_4() throws IOException {
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.put(IndexMetaData.SETTING_VERSION_CREATED,
VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.V_6_3_0))
VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.V_6_3_0))
.build();

IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
Expand Down Expand Up @@ -104,7 +104,7 @@ public void testEdgeNGramDeprecationWarning() throws IOException {
public void testEdgeNGramNoDeprecationWarningPre6_4() throws IOException {
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.put(IndexMetaData.SETTING_VERSION_CREATED,
VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.V_6_3_0))
VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.V_6_3_0))
.build();

IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testDeprecationWarning() throws IOException {
public void testNoDeprecationWarningPre6_3() throws IOException {
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.put(IndexMetaData.SETTING_VERSION_CREATED,
VersionUtils.randomVersionBetween(random(), Version.V_5_0_0, Version.V_6_2_4))
VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.V_6_2_4))
.build();

IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.script.mustache;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.CompositeIndicesRequest;
Expand Down Expand Up @@ -120,21 +119,17 @@ public MultiSearchTemplateRequest indicesOptions(IndicesOptions indicesOptions)
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
if (in.getVersion().onOrAfter(Version.V_5_5_0)) {
maxConcurrentSearchRequests = in.readVInt();
}
maxConcurrentSearchRequests = in.readVInt();
requests = in.readStreamableList(SearchTemplateRequest::new);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_5_5_0)) {
out.writeVInt(maxConcurrentSearchRequests);
}
out.writeVInt(maxConcurrentSearchRequests);
out.writeStreamableList(requests);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -148,9 +143,9 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
return Objects.hash(maxConcurrentSearchRequests, requests, indicesOptions);
}
public static byte[] writeMultiLineFormat(MultiSearchTemplateRequest multiSearchTemplateRequest,
}

public static byte[] writeMultiLineFormat(MultiSearchTemplateRequest multiSearchTemplateRequest,
XContent xContent) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
for (SearchTemplateRequest templateRequest : multiSearchTemplateRequest.requests()) {
Expand All @@ -168,5 +163,5 @@ public static byte[] writeMultiLineFormat(MultiSearchTemplateRequest multiSearch
}
return output.toByteArray();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.lucene.search.join.JoinUtil;
import org.apache.lucene.search.join.ScoreMode;
import org.apache.lucene.search.similarities.Similarity;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -125,15 +124,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeInt(maxChildren);
out.writeVInt(scoreMode.ordinal());
out.writeNamedWriteable(query);
if (out.getVersion().before(Version.V_5_5_0)) {
final boolean hasInnerHit = innerHitBuilder != null;
out.writeBoolean(hasInnerHit);
if (hasInnerHit) {
innerHitBuilder.writeToParentChildBWC(out, query, type);
}
} else {
out.writeOptionalWriteable(innerHitBuilder);
}
out.writeOptionalWriteable(innerHitBuilder);
out.writeBoolean(ignoreUnmapped);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -97,15 +96,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
out.writeString(type);
out.writeBoolean(score);
out.writeNamedWriteable(query);
if (out.getVersion().before(Version.V_5_5_0)) {
final boolean hasInnerHit = innerHitBuilder != null;
out.writeBoolean(hasInnerHit);
if (hasInnerHit) {
innerHitBuilder.writeToParentChildBWC(out, query, type);
}
} else {
out.writeOptionalWriteable(innerHitBuilder);
}
out.writeOptionalWriteable(innerHitBuilder);
out.writeBoolean(ignoreUnmapped);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ protected void doAssertLuceneQuery(HasChildQueryBuilder queryBuilder, Query quer
public void testSerializationBWC() throws IOException {
for (Version version : VersionUtils.allReleasedVersions()) {
HasChildQueryBuilder testQuery = createTestQueryBuilder();
if (version.before(Version.V_5_2_0) && testQuery.innerHit() != null) {
// ignore unmapped for inner_hits has been added on 5.2
testQuery.innerHit().setIgnoreUnmapped(false);
}
assertSerialization(testQuery, version);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ protected void doAssertLuceneQuery(HasParentQueryBuilder queryBuilder, Query que
public void testSerializationBWC() throws IOException {
for (Version version : VersionUtils.allReleasedVersions()) {
HasParentQueryBuilder testQuery = createTestQueryBuilder();
if (version.before(Version.V_5_2_0) && testQuery.innerHit() != null) {
// ignore unmapped for inner_hits has been added on 5.2
testQuery.innerHit().setIgnoreUnmapped(false);
}
assertSerialization(testQuery, version);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,7 @@ public PercolateQueryBuilder(String field, String documentType, String indexedDo
documents = document != null ? Collections.singletonList(document) : Collections.emptyList();
}
if (documents.isEmpty() == false) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
documentXContentType = in.readEnum(XContentType.class);
} else {
documentXContentType = XContentHelper.xContentType(documents.iterator().next());
}
documentXContentType = in.readEnum(XContentType.class);
} else {
documentXContentType = null;
}
Expand Down Expand Up @@ -329,7 +325,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
BytesReference doc = documents.isEmpty() ? null : documents.iterator().next();
out.writeOptionalBytesReference(doc);
}
if (documents.isEmpty() == false && out.getVersion().onOrAfter(Version.V_5_3_0)) {
if (documents.isEmpty() == false) {
out.writeEnum(documentXContentType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
Expand All @@ -36,7 +35,6 @@
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
Expand All @@ -57,7 +55,6 @@
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -294,26 +291,6 @@ public void testCreateMultiDocumentSearcher() throws Exception {
assertThat(result.clauses().get(1).getOccur(), equalTo(BooleanClause.Occur.MUST_NOT));
}

public void testSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("P4AAAAAFZmllbGQEdHlwZQAAAAAAAA57ImZvbyI6ImJhciJ9AAAAAA==");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
PercolateQueryBuilder queryBuilder = new PercolateQueryBuilder(in);
assertEquals("type", queryBuilder.getDocumentType());
assertEquals("field", queryBuilder.getField());
assertEquals("{\"foo\":\"bar\"}", queryBuilder.getDocuments().iterator().next().utf8ToString());
assertEquals(XContentType.JSON, queryBuilder.getXContentType());

try (BytesStreamOutput out = new BytesStreamOutput()) {
out.setVersion(version);
queryBuilder.writeTo(out);
assertArrayEquals(data, out.bytes().toBytesRef().bytes);
}
}
}

private static BytesReference randomSource(Set<String> usedFields) {
try {
// If we create two source that have the same field, but these fields have different kind of values (str vs. lng) then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testStoringQueryBuilders() throws IOException {
BinaryFieldMapper fieldMapper = PercolatorFieldMapper.Builder.createQueryBuilderFieldBuilder(
new Mapper.BuilderContext(settings, new ContentPath(0)));

Version version = randomBoolean() ? Version.V_5_6_0 : Version.V_6_0_0_beta2;
Version version = Version.V_6_0_0_beta2;
try (IndexWriter indexWriter = new IndexWriter(directory, config)) {
for (int i = 0; i < queryBuilders.length; i++) {
queryBuilders[i] = new TermQueryBuilder(randomAlphaOfLength(4), randomAlphaOfLength(8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ static Request initialSearch(SearchRequest searchRequest, BytesReference query,

if (searchRequest.scroll() != null) {
TimeValue keepAlive = searchRequest.scroll().keepAlive();
if (remoteVersion.before(Version.V_5_0_0)) {
// V_5_0_0
if (remoteVersion.before(Version.fromId(5000099))) {
/* Versions of Elasticsearch before 5.0 couldn't parse nanos or micros
* so we toss out that resolution, rounding up because more scroll
* timeout seems safer than less. */
Expand Down Expand Up @@ -117,7 +118,8 @@ static Request initialSearch(SearchRequest searchRequest, BytesReference query,
for (int i = 1; i < searchRequest.source().storedFields().fieldNames().size(); i++) {
fields.append(',').append(searchRequest.source().storedFields().fieldNames().get(i));
}
String storedFieldsParamName = remoteVersion.before(Version.V_5_0_0_alpha4) ? "fields" : "stored_fields";
// V_5_0_0
String storedFieldsParamName = remoteVersion.before(Version.fromId(5000099)) ? "fields" : "stored_fields";
request.addParameter(storedFieldsParamName, fields.toString());
}

Expand Down Expand Up @@ -186,7 +188,8 @@ private static String sortToUri(SortBuilder<?> sort) {
static Request scroll(String scroll, TimeValue keepAlive, Version remoteVersion) {
Request request = new Request("POST", "/_search/scroll");

if (remoteVersion.before(Version.V_5_0_0)) {
// V_5_0_0
if (remoteVersion.before(Version.fromId(5000099))) {
/* Versions of Elasticsearch before 5.0 couldn't parse nanos or micros
* so we toss out that resolution, rounding up so we shouldn't end up
* with 0s. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,8 @@ private void assertRequestEquals(Version version, ReindexRequest request, Reinde
assertEquals(request.getRemoteInfo().getUsername(), tripped.getRemoteInfo().getUsername());
assertEquals(request.getRemoteInfo().getPassword(), tripped.getRemoteInfo().getPassword());
assertEquals(request.getRemoteInfo().getHeaders(), tripped.getRemoteInfo().getHeaders());
if (version.onOrAfter(Version.V_5_2_0)) {
assertEquals(request.getRemoteInfo().getSocketTimeout(), tripped.getRemoteInfo().getSocketTimeout());
assertEquals(request.getRemoteInfo().getConnectTimeout(), tripped.getRemoteInfo().getConnectTimeout());
} else {
assertEquals(RemoteInfo.DEFAULT_SOCKET_TIMEOUT, tripped.getRemoteInfo().getSocketTimeout());
assertEquals(RemoteInfo.DEFAULT_CONNECT_TIMEOUT, tripped.getRemoteInfo().getConnectTimeout());
}
assertEquals(request.getRemoteInfo().getSocketTimeout(), tripped.getRemoteInfo().getSocketTimeout());
assertEquals(request.getRemoteInfo().getConnectTimeout(), tripped.getRemoteInfo().getConnectTimeout());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ public void testInitialSearchParamsFields() {
// Test stored_fields for versions that support it
searchRequest = new SearchRequest().source(new SearchSourceBuilder());
searchRequest.source().storedField("_source").storedField("_id");
remoteVersion = Version.fromId(between(Version.V_5_0_0_alpha4_ID, Version.CURRENT.id));
// V_5_0_0_alpha4 => current
remoteVersion = Version.fromId(between(5000004, Version.CURRENT.id));
assertThat(initialSearch(searchRequest, query, remoteVersion).getParameters(), hasEntry("stored_fields", "_source,_id"));

// Test fields for versions that support it
searchRequest = new SearchRequest().source(new SearchSourceBuilder());
searchRequest.source().storedField("_source").storedField("_id");
remoteVersion = Version.fromId(between(2000099, Version.V_5_0_0_alpha4_ID - 1));
// V_2_0_0 => V_5_0_0_alpha3
remoteVersion = Version.fromId(between(2000099, 5000003));
assertThat(initialSearch(searchRequest, query, remoteVersion).getParameters(), hasEntry("fields", "_source,_id"));

// Test extra fields for versions that need it
Expand Down Expand Up @@ -190,7 +192,8 @@ public void testInitialSearchParamsMisc() {
}

private void assertScroll(Version remoteVersion, Map<String, String> params, TimeValue requested) {
if (remoteVersion.before(Version.V_5_0_0)) {
// V_5_0_0
if (remoteVersion.before(Version.fromId(5000099))) {
// Versions of Elasticsearch prior to 5.0 can't parse nanos or micros in TimeValue.
assertThat(params.get("scroll"), not(either(endsWith("nanos")).or(endsWith("micros"))));
if (requested.getStringRep().endsWith("nanos") || requested.getStringRep().endsWith("micros")) {
Expand Down Expand Up @@ -242,7 +245,7 @@ public void testScrollParams() {

public void testScrollEntity() throws IOException {
String scroll = randomAlphaOfLength(30);
HttpEntity entity = scroll(scroll, timeValueMillis(between(1, 1000)), Version.V_5_0_0).getEntity();
HttpEntity entity = scroll(scroll, timeValueMillis(between(1, 1000)), Version.fromString("5.0.0")).getEntity();
assertEquals(ContentType.APPLICATION_JSON.toString(), entity.getContentType().getValue());
assertThat(Streams.copyToString(new InputStreamReader(entity.getContent(), StandardCharsets.UTF_8)),
containsString("\"" + scroll + "\""));
Expand All @@ -255,7 +258,7 @@ public void testScrollEntity() throws IOException {

public void testClearScroll() throws IOException {
String scroll = randomAlphaOfLength(30);
Request request = clearScroll(scroll, Version.V_5_0_0);
Request request = clearScroll(scroll, Version.fromString("5.0.0"));
assertEquals(ContentType.APPLICATION_JSON.toString(), request.getEntity().getContentType().getValue());
assertThat(Streams.copyToString(new InputStreamReader(request.getEntity().getContent(), StandardCharsets.UTF_8)),
containsString("\"" + scroll + "\""));
Expand Down
Loading

0 comments on commit 91a052b

Please sign in to comment.