2222import org .elasticsearch .index .engine .frozen .FrozenEngine ;
2323import org .elasticsearch .snapshots .SearchableSnapshotsSettings ;
2424import org .elasticsearch .test .ESTestCase ;
25+ import org .elasticsearch .xpack .core .deprecation .DeprecatedIndexPredicate ;
2526import org .elasticsearch .xpack .core .deprecation .DeprecationIssue ;
2627
2728import java .io .IOException ;
2829import java .util .List ;
2930import java .util .Map ;
3031
3132import static java .util .Collections .singletonList ;
32- import static java .util .Collections .singletonMap ;
33+ import static java .util .Map .entry ;
34+ import static java .util .Map .ofEntries ;
35+ import static org .elasticsearch .cluster .metadata .IndexMetadata .INDEX_IGNORE_DEPRECATION_WARNING_FOR_VERSION_KEY ;
3336import static org .elasticsearch .index .IndexModule .INDEX_STORE_TYPE_SETTING ;
37+ import static org .elasticsearch .xpack .core .deprecation .DeprecatedIndexPredicate .MINIMUM_WRITEABLE_VERSION_AFTER_UPGRADE ;
3438import static org .elasticsearch .xpack .deprecation .DeprecationChecks .INDEX_SETTINGS_CHECKS ;
3539import static org .hamcrest .Matchers .empty ;
3640import static org .hamcrest .Matchers .equalTo ;
@@ -54,7 +58,10 @@ public void testOldIndicesCheck() {
5458 "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-9.0.html" ,
5559 "This index has version: " + createdWith .toReleaseVersion (),
5660 false ,
57- singletonMap ("reindex_required" , true )
61+ ofEntries (
62+ entry ("reindex_required" , true ),
63+ entry ("minimum_writable_version_after_upgrade" , DeprecatedIndexPredicate .MINIMUM_WRITEABLE_VERSION_AFTER_UPGRADE .id ())
64+ )
5865 );
5966 List <DeprecationIssue > issues = DeprecationChecks .filterChecks (INDEX_SETTINGS_CHECKS , c -> c .apply (indexMetadata , clusterState ));
6067 assertEquals (singletonList (expected ), issues );
@@ -116,6 +123,20 @@ public void testOldIndicesCheckSnapshotIgnored() {
116123 assertThat (issues , empty ());
117124 }
118125
126+ public void testIgnoredIndex () {
127+ IndexVersion createdWith = IndexVersion .fromId (7170099 );
128+ Settings .Builder settings = settings (createdWith );
129+ settings .put (INDEX_IGNORE_DEPRECATION_WARNING_FOR_VERSION_KEY , MINIMUM_WRITEABLE_VERSION_AFTER_UPGRADE .id ());
130+ IndexMetadata indexMetadata = IndexMetadata .builder ("test" ).settings (settings ).numberOfShards (1 ).numberOfReplicas (0 ).build ();
131+ ClusterState clusterState = ClusterState .builder (ClusterState .EMPTY_STATE )
132+ .metadata (Metadata .builder ().put (indexMetadata , true ))
133+ .build ();
134+
135+ List <DeprecationIssue > issues = DeprecationChecks .filterChecks (INDEX_SETTINGS_CHECKS , c -> c .apply (indexMetadata , clusterState ));
136+
137+ assertThat (issues , empty ());
138+ }
139+
119140 public void testTranslogRetentionSettings () {
120141 Settings .Builder settings = settings (IndexVersion .current ());
121142 settings .put (IndexSettings .INDEX_TRANSLOG_RETENTION_AGE_SETTING .getKey (), randomPositiveTimeValue ());
0 commit comments