|
7 | 7 |
|
8 | 8 | import org.elasticsearch.Version;
|
9 | 9 | import org.elasticsearch.cluster.metadata.IndexMetaData;
|
| 10 | +import org.elasticsearch.cluster.routing.UnassignedInfo; |
10 | 11 | import org.elasticsearch.common.settings.Settings;
|
11 | 12 | import org.elasticsearch.test.ESTestCase;
|
12 | 13 | import org.elasticsearch.test.VersionUtils;
|
@@ -76,4 +77,31 @@ 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 testNodeLeftDelayedTimeCheck() { |
| 82 | + String negativeTimeValue = "-" + randomPositiveTimeValue(); |
| 83 | + String indexName = randomAlphaOfLengthBetween(0, 10); |
| 84 | + |
| 85 | + final IndexMetaData badIndex = IndexMetaData.builder(indexName) |
| 86 | + .settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), negativeTimeValue)) |
| 87 | + .numberOfShards(randomIntBetween(1, 100)) |
| 88 | + .numberOfReplicas(randomIntBetween(1, 15)) |
| 89 | + .build(); |
| 90 | + DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING, |
| 91 | + "Negative values for index.unassigned.node_left.delayed_timeout are deprecated and should be set to 0", |
| 92 | + "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" + |
| 93 | + "#_literal_index_unassigned_node_left_delayed_timeout_literal_may_no_longer_be_negative", |
| 94 | + "The index " + indexName + " is set to " + negativeTimeValue); |
| 95 | + |
| 96 | + List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex)); |
| 97 | + assertEquals(singletonList(expected), issues); |
| 98 | + |
| 99 | + final IndexMetaData goodIndex = IndexMetaData.builder(indexName) |
| 100 | + .settings(settings(Version.CURRENT)) |
| 101 | + .numberOfShards(randomIntBetween(1, 100)) |
| 102 | + .numberOfReplicas(randomIntBetween(1, 15)) |
| 103 | + .build(); |
| 104 | + List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex)); |
| 105 | + assertTrue(noIssues.isEmpty()); |
| 106 | + } |
79 | 107 | }
|
0 commit comments