2929import java .util .Map ;
3030
3131import static java .util .Collections .singletonList ;
32- import static java .util .Collections .singletonMap ;
32+ import static java .util .Map .entry ;
33+ import static java .util .Map .ofEntries ;
3334import static org .elasticsearch .xpack .deprecation .DeprecationChecks .INDEX_SETTINGS_CHECKS ;
35+ import static org .elasticsearch .xpack .deprecation .IndexDeprecationChecks .MINIMUM_VERSION ;
3436import static org .hamcrest .Matchers .empty ;
3537import static org .hamcrest .Matchers .equalTo ;
3638import static org .hamcrest .Matchers .hasItem ;
@@ -53,7 +55,7 @@ public void testOldIndicesCheck() {
5355 "https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-9.0.html" ,
5456 "This index has version: " + createdWith .toReleaseVersion (),
5557 false ,
56- singletonMap ( "reindex_required" , true )
58+ ofEntries ( entry ( "reindex_required" , true ), entry ( "minimum_version_id_required" , MINIMUM_VERSION . id ()) )
5759 );
5860 List <DeprecationIssue > issues = DeprecationChecks .filterChecks (INDEX_SETTINGS_CHECKS , c -> c .apply (indexMetadata , clusterState ));
5961 assertEquals (singletonList (expected ), issues );
@@ -101,6 +103,21 @@ public void testOldIndicesCheckDataStreamIndex() {
101103 assertThat (issues .size (), equalTo (0 ));
102104 }
103105
106+ public void testOldIndicesIgnoredCheck () {
107+ IndexVersion createdWith = IndexVersion .fromId (7170099 );
108+
109+ Settings .Builder settings = settings (createdWith );
110+ settings .put (IndexMetadata .INDEX_IGNORE_DEPRECATION_WARNING_FOR_VERSION_KEY , MINIMUM_VERSION .id ());
111+
112+ IndexMetadata indexMetadata = IndexMetadata .builder ("test" ).settings (settings ).numberOfShards (1 ).numberOfReplicas (0 ).build ();
113+ ClusterState clusterState = ClusterState .builder (ClusterState .EMPTY_STATE )
114+ .metadata (Metadata .builder ().put (indexMetadata , true ))
115+ .build ();
116+
117+ List <DeprecationIssue > issues = DeprecationChecks .filterChecks (INDEX_SETTINGS_CHECKS , c -> c .apply (indexMetadata , clusterState ));
118+ assertThat (issues , empty ());
119+ }
120+
104121 public void testTranslogRetentionSettings () {
105122 Settings .Builder settings = settings (IndexVersion .current ());
106123 settings .put (IndexSettings .INDEX_TRANSLOG_RETENTION_AGE_SETTING .getKey (), randomPositiveTimeValue ());
0 commit comments