@@ -122,6 +122,11 @@ private static function wipeCluster(Client $client): void
122
122
self ::deleteAllSLMPolicies ($ client );
123
123
}
124
124
125
+ // Clean up searchable snapshots indices before deleting snapshots and repositories
126
+ if (getenv ('TEST_SUITE ' ) === 'platinum ' && version_compare (self ::getVersion ($ client ), '7.7.99 ' ) > 0 ) {
127
+ self ::wipeSearchableSnapshotsIndices ($ client );
128
+ }
129
+
125
130
self ::wipeSnapshots ($ client );
126
131
self ::wipeDataStreams ($ client );
127
132
self ::wipeAllIndices ($ client );
@@ -154,6 +159,8 @@ private static function wipeCluster(Client $client): void
154
159
self ::deleteAllAutoFollowPatterns ($ client );
155
160
self ::deleteAllTasks ($ client );
156
161
}
162
+
163
+ self ::deleteAllNodeShutdownMetadata ($ client );
157
164
}
158
165
159
166
/**
@@ -491,6 +498,7 @@ private static function isXPackTemplate(string $name): bool
491
498
case ".deprecation-indexing-template " :
492
499
case "logstash-index-template " :
493
500
case "security-index-template " :
501
+ case "data-streams-mappings " :
494
502
return true ;
495
503
}
496
504
return false ;
@@ -562,6 +570,49 @@ private static function deleteAllTasks(Client $client): void
562
570
}
563
571
}
564
572
573
+ /**
574
+ * If any nodes are registered for shutdown, removes their metadata
575
+ *
576
+ * @see https://github.com/elastic/elasticsearch/commit/cea054f7dae215475ea0499bc7060ca7ec05382f
577
+ */
578
+ private static function deleteAllNodeShutdownMetadata (Client $ client )
579
+ {
580
+ $ nodes = $ client ->shutdown ()->getNode ();
581
+ if (isset ($ nodes ['_nodes ' ]) && isset ($ nodes ['cluster_name ' ])) {
582
+ // If the response contains these two keys, the feature flag isn't enabled on this cluster, so skip out now.
583
+ // We can't check the system property directly because it only gets set for the cluster under test's JVM, not for the test
584
+ // runner's JVM.
585
+ return ;
586
+ }
587
+ foreach ($ nodes ['nodes ' ] as $ node ) {
588
+ $ client ->shutdown ()->deleteNode ($ node ['node_id ' ]);
589
+ }
590
+ }
591
+
592
+ /**
593
+ * Delete searchable snapshots index
594
+ *
595
+ * @see https://github.com/elastic/elasticsearch/commit/4927b6917deca6793776cf0c839eadf5ea512b4a
596
+ */
597
+ private static function wipeSearchableSnapshotsIndices (Client $ client )
598
+ {
599
+ $ indices = $ client ->cluster ()->state ([
600
+ 'metric ' => 'metadata ' ,
601
+ 'filter_path ' => 'metadata.indices.*.settings.index.store.snapshot '
602
+ ]);
603
+ if (!isset ($ indices ['metadata ' ]['indices ' ])) {
604
+ return ;
605
+ }
606
+ foreach ($ indices ['metadata ' ]['indices ' ] as $ index => $ value ) {
607
+ $ client ->indices ()->delete ([
608
+ 'index ' => $ index ,
609
+ 'client ' => [
610
+ 'ignore ' => 404
611
+ ]
612
+ ]);
613
+ }
614
+ }
615
+
565
616
/**
566
617
* Wait for Cluster state updates to finish
567
618
*
0 commit comments