@@ -167,6 +167,42 @@ public static function cleanUpCluster(Client $client): void
167
167
self ::ensureNoInitializingShards ($ client );
168
168
self ::wipeCluster ($ client );
169
169
self ::waitForClusterStateUpdatesToFinish ($ client );
170
+ self ::checkForUnexpectedlyRecreatedObjects ($ client );
171
+ }
172
+
173
+ /**
174
+ * This method checks whether ILM policies or templates get recreated after they have been deleted. If so, we are probably deleting
175
+ * them unnecessarily, potentially causing test performance problems. This could happen for example if someone adds a new standard ILM
176
+ * policy but forgets to put it in the exclusion list in this test.
177
+ *
178
+ * @see ESRestTestCase.java:checkForUnexpectedlyRecreatedObjects()
179
+ */
180
+ private static function checkForUnexpectedlyRecreatedObjects (Client $ client ): void
181
+ {
182
+ if (self ::$ hasIlm ) {
183
+ $ policies = self ::getAllUnexpectedIlmPolicies ($ client );
184
+ if (!empty ($ policies )) {
185
+ throw new Exception (sprintf (
186
+ "Expected no ILM policies after deletions, but found %s " ,
187
+ implode (', ' , array_keys ($ policies ))
188
+ ));
189
+ }
190
+ }
191
+ }
192
+
193
+ /**
194
+ * @see ESRestTestCase.java:getAllUnexpectedIlmPolicies()
195
+ */
196
+ private static function getAllUnexpectedIlmPolicies (Client $ client ): array
197
+ {
198
+ try {
199
+ return $ client ->ilm ()->getLifecycle ()->asArray ();
200
+ } catch (ClientResponseException $ e ) {
201
+ if (in_array ($ e ->getCode (), [400 , 405 ])) {
202
+ return [];
203
+ }
204
+ throw $ e ;
205
+ }
170
206
}
171
207
172
208
/**
@@ -621,9 +657,19 @@ private static function preserveILMPolicyIds(): array
621
657
"ilm-history-ilm-policy " ,
622
658
"slm-history-ilm-policy " ,
623
659
"watch-history-ilm-policy " ,
660
+ "watch-history-ilm-policy-16 " ,
624
661
"ml-size-based-ilm-policy " ,
625
662
"logs " ,
626
- "metrics "
663
+ "metrics " ,
664
+ "synthetics " ,
665
+ "7-days-default " ,
666
+ "30-days-default " ,
667
+ "90-days-default " ,
668
+ "180-days-default " ,
669
+ "365-days-default " ,
670
+ ".fleet-actions-results-ilm-policy " ,
671
+ ".deprecation-indexing-ilm-policy " ,
672
+ ".monitoring-8-ilm-policy "
627
673
];
628
674
}
629
675
0 commit comments