|
8 | 8 | import org.elasticsearch.Version;
|
9 | 9 | import org.elasticsearch.cluster.metadata.IndexMetaData;
|
10 | 10 | import org.elasticsearch.common.settings.Settings;
|
| 11 | +import org.elasticsearch.index.IndexSettings; |
11 | 12 | import org.elasticsearch.test.ESTestCase;
|
12 | 13 | import org.elasticsearch.test.VersionUtils;
|
13 | 14 | import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
|
@@ -76,4 +77,29 @@ 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 testShardOnStartupCheck() { |
| 82 | + String indexName = randomAlphaOfLengthBetween(0, 10); |
| 83 | + final IndexMetaData badIndex = IndexMetaData.builder(indexName) |
| 84 | + .settings(settings(Version.CURRENT).put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), "fix")) |
| 85 | + .numberOfShards(randomIntBetween(1, 100)) |
| 86 | + .numberOfReplicas(randomIntBetween(1, 15)) |
| 87 | + .build(); |
| 88 | + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, |
| 89 | + "The value 'fix' for setting index.shard.check_on_startup is no longer valid", |
| 90 | + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + |
| 91 | + "#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed", |
| 92 | + "The index [" + indexName + "] has the setting index.shard.check_on_startup = 'fix'. " + |
| 93 | + "Valid values are 'true', 'false', and 'checksum'"); |
| 94 | + List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex)); |
| 95 | + assertEquals(singletonList(expected), issues); |
| 96 | + final IndexMetaData goodIndex = IndexMetaData.builder(indexName) |
| 97 | + .settings(settings(Version.CURRENT)) |
| 98 | + .numberOfShards(randomIntBetween(1, 100)) |
| 99 | + .numberOfReplicas(randomIntBetween(1, 15)) |
| 100 | + .build(); |
| 101 | + List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex)); |
| 102 | + assertTrue(noIssues.isEmpty()); |
| 103 | + } |
| 104 | + |
79 | 105 | }
|
0 commit comments