1717import org .elasticsearch .index .Index ;
1818import org .elasticsearch .index .IndexMode ;
1919import org .elasticsearch .index .IndexVersion ;
20+ import org .elasticsearch .snapshots .SearchableSnapshotsSettings ;
2021import org .elasticsearch .test .ESTestCase ;
2122import org .elasticsearch .xpack .core .deprecation .DeprecationIssue ;
2223
2324import java .util .ArrayList ;
2425import java .util .HashMap ;
26+ import java .util .HashSet ;
2527import java .util .List ;
2628import java .util .Map ;
27- import java .util .stream . Collectors ;
29+ import java .util .Set ;
2830
2931import static java .util .Collections .singletonList ;
3032import static java .util .Map .entry ;
3133import static java .util .Map .ofEntries ;
34+ import static org .elasticsearch .index .IndexModule .INDEX_STORE_TYPE_SETTING ;
3235import static org .elasticsearch .xpack .deprecation .DeprecationChecks .DATA_STREAM_CHECKS ;
3336import static org .hamcrest .Matchers .equalTo ;
3437
@@ -40,10 +43,20 @@ public void testOldIndicesCheck() {
4043
4144 List <Index > allIndices = new ArrayList <>();
4245 Map <String , IndexMetadata > nameToIndexMetadata = new HashMap <>();
46+ Set <String > expectedIndices = new HashSet <>();
4347
4448 for (int i = 0 ; i < oldIndexCount ; i ++) {
45- Settings .Builder settingsBuilder = settings (IndexVersion .fromId (7170099 ));
46- IndexMetadata oldIndexMetadata = IndexMetadata .builder ("old-data-stream-index-" + i )
49+ Settings .Builder settings = settings (IndexVersion .fromId (7170099 ));
50+
51+ String indexName = "old-data-stream-index-" + i ;
52+ if (expectedIndices .isEmpty () == false && randomIntBetween (0 , 2 ) == 0 ) {
53+ settings .put (INDEX_STORE_TYPE_SETTING .getKey (), SearchableSnapshotsSettings .SEARCHABLE_SNAPSHOT_STORE_TYPE );
54+ } else {
55+ expectedIndices .add (indexName );
56+ }
57+
58+ Settings .Builder settingsBuilder = settings ;
59+ IndexMetadata oldIndexMetadata = IndexMetadata .builder (indexName )
4760 .settings (settingsBuilder )
4861 .numberOfShards (1 )
4962 .numberOfReplicas (0 )
@@ -92,14 +105,8 @@ public void testOldIndicesCheck() {
92105 ofEntries (
93106 entry ("reindex_required" , true ),
94107 entry ("total_backing_indices" , oldIndexCount + newIndexCount ),
95- entry ("indices_requiring_upgrade_count" , oldIndexCount ),
96- entry (
97- "indices_requiring_upgrade" ,
98- nameToIndexMetadata .keySet ()
99- .stream ()
100- .filter (name -> name .startsWith ("old-data-stream-index-" ))
101- .collect (Collectors .toUnmodifiableSet ())
102- )
108+ entry ("indices_requiring_upgrade_count" , expectedIndices .size ()),
109+ entry ("indices_requiring_upgrade" , expectedIndices )
103110 )
104111 );
105112
0 commit comments