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,9 @@ 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 ()))
5864 );
5965 List <DeprecationIssue > issues = DeprecationChecks .filterChecks (INDEX_SETTINGS_CHECKS , c -> c .apply (indexMetadata , clusterState ));
6066 assertEquals (singletonList (expected ), issues );
@@ -116,6 +122,20 @@ public void testOldIndicesCheckSnapshotIgnored() {
116122 assertThat (issues , empty ());
117123 }
118124
125+ public void testIgnoredIndex () {
126+ IndexVersion createdWith = IndexVersion .fromId (7170099 );
127+ Settings .Builder settings = settings (createdWith );
128+ settings .put (INDEX_IGNORE_DEPRECATION_WARNING_FOR_VERSION_KEY , MINIMUM_WRITEABLE_VERSION_AFTER_UPGRADE .id ());
129+ IndexMetadata indexMetadata = IndexMetadata .builder ("test" ).settings (settings ).numberOfShards (1 ).numberOfReplicas (0 ).build ();
130+ ClusterState clusterState = ClusterState .builder (ClusterState .EMPTY_STATE )
131+ .metadata (Metadata .builder ().put (indexMetadata , true ))
132+ .build ();
133+
134+ List <DeprecationIssue > issues = DeprecationChecks .filterChecks (INDEX_SETTINGS_CHECKS , c -> c .apply (indexMetadata , clusterState ));
135+
136+ assertThat (issues , empty ());
137+ }
138+
119139 public void testTranslogRetentionSettings () {
120140 Settings .Builder settings = settings (IndexVersion .current ());
121141 settings .put (IndexSettings .INDEX_TRANSLOG_RETENTION_AGE_SETTING .getKey (), randomPositiveTimeValue ());
0 commit comments