Skip to content

Commit 6e1bd95

Browse files
committed
Ignore warnings related to types deprecation in REST tests.
1 parent 5c2a5f2 commit 6e1bd95

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,21 @@ void checkWarningHeaders(final List<String> warningHeaders, final Version master
293293
if (matches) {
294294
final String message = matcher.group(1);
295295
// noinspection StatementWithEmptyBody
296-
if (masterVersion.before(Version.V_7_0_0)
296+
if ((masterVersion.before(Version.V_7_0_0)
297297
&& message.equals("the default number of shards will change from [5] to [1] in 7.0.0; "
298298
+ "if you wish to continue using the default of [5] shards, "
299-
+ "you must manage this on the create index request or with an index template")) {
299+
+ "you must manage this on the create index request or with an index template"))
300+
|| message.startsWith("[types removal]")) {
300301
/*
301-
* This warning header will come back in the vast majority of our tests that create an index when running against an
302-
* older master. Rather than rewrite our tests to assert this warning header, we assume that it is expected.
302+
* We ignore two classes of warning headers:
303+
* - The default number of shards warning will come back in the vast majority of our tests that
304+
* create an index when running against an older master. Rather than rewrite our tests to assert
305+
* this warning header, we assume that it is expected.
306+
* - We skip warnings related to types deprecation so that we can continue to run the many
307+
* mixed-version tests that used typed APIs.
303308
*/
304-
} else {
305-
if (expected.remove(message) == false) {
306-
unexpected.add(header);
307-
}
309+
} else if (expected.remove(message) == false) {
310+
unexpected.add(header);
308311
}
309312
} else {
310313
unmatched.add(header);

test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ public void testWarningHeaders() {
128128
}
129129
}
130130

131+
public void testIgnoreTypesWarnings() {
132+
String legitimateWarning = DeprecationLogger.formatWarning("warning");
133+
String typesWarning = DeprecationLogger.formatWarning("[types removal] " +
134+
"The endpoint /{index}/{type}/_count is deprecated, use /{index}/_count instead.");
135+
136+
DoSection section = new DoSection(new XContentLocation(1, 1));
137+
section.setExpectedWarningHeaders(singletonList("warning"));
138+
section.checkWarningHeaders(Arrays.asList(legitimateWarning, typesWarning), Version.CURRENT);
139+
}
140+
131141
public void testParseDoSectionNoBody() throws Exception {
132142
parser = createParser(YamlXContent.yamlXContent,
133143
"get:\n" +

0 commit comments

Comments
 (0)