|
14 | 14 | import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
|
15 | 15 |
|
16 | 16 | import java.util.List;
|
| 17 | +import java.util.Locale; |
17 | 18 |
|
18 | 19 | import static java.util.Collections.singletonList;
|
19 | 20 | import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTINGS_CHECKS;
|
@@ -76,4 +77,33 @@ public void testIndexNameCheck(){
|
76 | 77 | List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
|
77 | 78 | assertTrue(noIssues.isEmpty());
|
78 | 79 | }
|
| 80 | + |
| 81 | + public void testPercolatorUnmappedFieldsAsStringCheck() { |
| 82 | + boolean settingValue = randomBoolean(); |
| 83 | + Settings settings = settings( |
| 84 | + VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.CURRENT))) |
| 85 | + .put("index.percolator.map_unmapped_fields_as_text", settingValue).build(); |
| 86 | + final IndexMetaData badIndex = IndexMetaData.builder(randomAlphaOfLengthBetween(1,30).toLowerCase(Locale.ROOT)) |
| 87 | + .settings(settings) |
| 88 | + .numberOfShards(randomIntBetween(1,100)) |
| 89 | + .numberOfReplicas(randomIntBetween(1,15)) |
| 90 | + .build(); |
| 91 | + |
| 92 | + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, |
| 93 | + "Setting index.percolator.map_unmapped_fields_as_text has been renamed", |
| 94 | + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + |
| 95 | + "#_percolator", |
| 96 | + "The index setting [index.percolator.map_unmapped_fields_as_text] currently set to [" + settingValue + |
| 97 | + "] been removed in favor of [index.percolator.map_unmapped_fields_as_text]."); |
| 98 | + List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex)); |
| 99 | + assertEquals(singletonList(expected), issues); |
| 100 | + |
| 101 | + final IndexMetaData goodIndex = IndexMetaData.builder(randomAlphaOfLengthBetween(1,30).toLowerCase(Locale.ROOT)) |
| 102 | + .settings(settings(Version.CURRENT)) |
| 103 | + .numberOfShards(randomIntBetween(1,100)) |
| 104 | + .numberOfReplicas(randomIntBetween(1,15)) |
| 105 | + .build(); |
| 106 | + List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex)); |
| 107 | + assertTrue(noIssues.isEmpty()); |
| 108 | + } |
79 | 109 | }
|
0 commit comments