Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare to backport runtime_mappings #64890

Merged
merged 2 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:/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