Skip to content

Commit

Permalink
Prepare to backport runtime_mappings (#64890)
Browse files Browse the repository at this point in the history
Prepare to backport #64374 by updating some versions constants so we can
send `runtime_mappings` to 7.11.0. Also disable bwc tests so they don't
fail until we finish the backport.
  • Loading branch information
nik9000 authored Nov 11, 2020
1 parent 19b5564 commit 945601e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ tasks.register("verifyVersions") {
* after the backport of the backcompat code is complete.
*/

boolean bwc_tests_enabled = true
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
boolean bwc_tests_enabled = false
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/64374" /* place a PR link here when committing bwc changes */
if (bwc_tests_enabled == false) {
if (bwc_tests_disabled_issue.isEmpty()) {
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public SearchSourceBuilder(StreamInput in) throws IOException {
}
pointInTimeBuilder = in.readOptionalWriteable(PointInTimeBuilder::new);
}
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
if (in.getVersion().onOrAfter(Version.V_7_11_0)) {
runtimeMappings = in.readMap();
}
}
Expand Down Expand Up @@ -320,12 +320,12 @@ public void writeTo(StreamOutput out) throws IOException {
}
out.writeOptionalWriteable(pointInTimeBuilder);
}
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
if (out.getVersion().onOrAfter(Version.V_7_11_0)) {
out.writeMap(runtimeMappings);
} else {
if (false == runtimeMappings.isEmpty()) {
throw new IllegalArgumentException(
"Versions before 8.0.0 don't support [runtime_mappings] and search was sent to [" + out.getVersion() + "]"
"Versions before 7.11.0 don't support [runtime_mappings] and search was sent to [" + out.getVersion() + "]"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public void testSerialization() throws Exception {
public void testRandomVersionSerialization() throws IOException {
SearchRequest searchRequest = createSearchRequest();
Version version = VersionUtils.randomVersion(random());
if (version.before(Version.V_8_0_0) && searchRequest.source() != null) {
// Versions before 8.0.0 don't support runtime mappings
if (version.before(Version.V_7_11_0) && searchRequest.source() != null) {
// Versions before 7.11.0 don't support runtime mappings
searchRequest.source().runtimeMappings(emptyMap());
}
SearchRequest deserializedRequest = copyWriteable(searchRequest, namedWriteableRegistry, SearchRequest::new, version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.EqualsHashCodeTestUtils;
import org.elasticsearch.test.VersionUtils;

import java.io.IOException;
import java.util.Map;
Expand Down Expand Up @@ -101,9 +102,9 @@ public void testSerialization() throws IOException {

public void testSerializingWithRuntimeFieldsBeforeSupportedThrows() {
SearchSourceBuilder original = new SearchSourceBuilder().runtimeMappings(randomRuntimeMappings());
Version v = Version.V_8_0_0.minimumCompatibilityVersion();
Version v = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, VersionUtils.getPreviousVersion(Version.V_7_11_0));
Exception e = expectThrows(IllegalArgumentException.class, () -> copyBuilder(original, v));
assertThat(e.getMessage(), equalTo("Versions before 8.0.0 don't support [runtime_mappings] and search was sent to [" + v + "]"));
assertThat(e.getMessage(), equalTo("Versions before 7.11.0 don't support [runtime_mappings] and search was sent to [" + v + "]"));
}

public void testShallowCopy() {
Expand Down

0 comments on commit 945601e

Please sign in to comment.