|
9 | 9 | import org.elasticsearch.cluster.metadata.IndexMetaData;
|
10 | 10 | import org.elasticsearch.cluster.routing.UnassignedInfo;
|
11 | 11 | import org.elasticsearch.common.settings.Settings;
|
| 12 | +import org.elasticsearch.index.IndexSettings; |
12 | 13 | import org.elasticsearch.test.ESTestCase;
|
13 | 14 | import org.elasticsearch.test.VersionUtils;
|
14 | 15 | import org.elasticsearch.xpack.core.deprecation.DeprecationInfoAction;
|
@@ -136,4 +137,29 @@ public void testNodeLeftDelayedTimeCheck() {
|
136 | 137 | List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
|
137 | 138 | assertTrue(noIssues.isEmpty());
|
138 | 139 | }
|
| 140 | + |
| 141 | + public void testShardOnStartupCheck() { |
| 142 | + String indexName = randomAlphaOfLengthBetween(0, 10); |
| 143 | + String setting = IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(); |
| 144 | + final IndexMetaData badIndex = IndexMetaData.builder(indexName) |
| 145 | + .settings(settings(Version.CURRENT).put(setting, "fix")) |
| 146 | + .numberOfShards(randomIntBetween(1, 100)) |
| 147 | + .numberOfReplicas(randomIntBetween(1, 15)) |
| 148 | + .build(); |
| 149 | + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, |
| 150 | + "The value [fix] for setting [" + setting + "] is no longer valid", |
| 151 | + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + |
| 152 | + "#_literal_fix_literal_value_for_literal_index_shard_check_on_startup_literal_is_removed", |
| 153 | + "The index [" + indexName + "] has the setting [" + setting + "] set to value [fix]" + |
| 154 | + ", but [fix] is no longer a valid value. Valid values are true, false, and checksum"); |
| 155 | + List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex)); |
| 156 | + assertEquals(singletonList(expected), issues); |
| 157 | + final IndexMetaData goodIndex = IndexMetaData.builder(indexName) |
| 158 | + .settings(settings(Version.CURRENT)) |
| 159 | + .numberOfShards(randomIntBetween(1, 100)) |
| 160 | + .numberOfReplicas(randomIntBetween(1, 15)) |
| 161 | + .build(); |
| 162 | + List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex)); |
| 163 | + assertTrue(noIssues.isEmpty()); |
| 164 | + } |
139 | 165 | }
|
0 commit comments