Skip to content

Commit 8bef36d

Browse files
authored
Adjust BWC version for dynamic templates in bulk requests (#71537)
Relates #69948
1 parent ee69f19 commit 8bef36d

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ tasks.register("verifyVersions") {
189189
* after the backport of the backcompat code is complete.
190190
*/
191191

192-
boolean bwc_tests_enabled = false
192+
boolean bwc_tests_enabled = true
193193
// place a PR link here when committing bwc changes:
194-
String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/69948"
194+
String bwc_tests_disabled_issue = ""
195195
/*
196196
* FIPS 140-2 behavior was fixed in 7.11.0. Before that there is no way to run elasticsearch in a
197197
* JVM that is properly configured to be in fips mode with BCFIPS. For now we need to disable

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/bulk/11_dynamic_templates.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
"Dynamic templates":
33
- skip:
4-
version: " - 7.99.99"
5-
reason: "Dynamic templates parameter is added to bulk requests in 8.0"
4+
version: " - 7.12.99"
5+
reason: "Dynamic templates parameter is added to bulk requests in 7.13"
66

77
- do:
88
indices.create:

server/src/main/java/org/elasticsearch/action/index/IndexRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio
148148
} else {
149149
requireAlias = false;
150150
}
151-
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
151+
if (in.getVersion().onOrAfter(Version.V_7_13_0)) {
152152
dynamicTemplates = in.readMap(StreamInput::readString, StreamInput::readString);
153153
}
154154
}
@@ -660,11 +660,11 @@ private void writeBody(StreamOutput out) throws IOException {
660660
if (out.getVersion().onOrAfter(Version.V_7_10_0)) {
661661
out.writeBoolean(requireAlias);
662662
}
663-
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
663+
if (out.getVersion().onOrAfter(Version.V_7_13_0)) {
664664
out.writeMap(dynamicTemplates, StreamOutput::writeString, StreamOutput::writeString);
665665
} else {
666666
if (dynamicTemplates.isEmpty() == false) {
667-
throw new IllegalArgumentException("[dynamic_templates] parameter requires all nodes on " + Version.V_8_0_0 + " or later");
667+
throw new IllegalArgumentException("[dynamic_templates] parameter requires all nodes on " + Version.V_7_13_0 + " or later");
668668
}
669669
}
670670
}

server/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,19 @@ public void testSerializeDynamicTemplates() throws Exception {
206206
Map<String, String> dynamicTemplates = IntStream.range(0, randomIntBetween(1, 10))
207207
.boxed().collect(Collectors.toMap(n -> "field-" + n, n -> "name-" + n));
208208
indexRequest.setDynamicTemplates(dynamicTemplates);
209-
Version ver = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, VersionUtils.getPreviousVersion(Version.V_8_0_0));
209+
Version ver = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, VersionUtils.getPreviousVersion(Version.V_7_13_0));
210210
BytesStreamOutput out = new BytesStreamOutput();
211211
out.setVersion(ver);
212212
IllegalArgumentException error = expectThrows(IllegalArgumentException.class, () -> indexRequest.writeTo(out));
213213
assertThat(error.getMessage(),
214-
equalTo("[dynamic_templates] parameter requires all nodes on " + Version.V_8_0_0 + " or later"));
214+
equalTo("[dynamic_templates] parameter requires all nodes on " + Version.V_7_13_0 + " or later"));
215215
}
216216
// new version
217217
{
218218
Map<String, String> dynamicTemplates = IntStream.range(0, randomIntBetween(0, 10))
219219
.boxed().collect(Collectors.toMap(n -> "field-" + n, n -> "name-" + n));
220220
indexRequest.setDynamicTemplates(dynamicTemplates);
221-
Version ver = VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT);
221+
Version ver = VersionUtils.randomVersionBetween(random(), Version.V_7_13_0, Version.CURRENT);
222222
BytesStreamOutput out = new BytesStreamOutput();
223223
out.setVersion(ver);
224224
indexRequest.writeTo(out);

0 commit comments

Comments
 (0)