@@ -175,7 +175,6 @@ public static function cleanUpCluster(Client $client): void
175
175
self ::ensureNoInitializingShards ($ client );
176
176
self ::wipeCluster ($ client );
177
177
self ::waitForClusterStateUpdatesToFinish ($ client );
178
- self ::checkForUnexpectedlyRecreatedObjects ($ client );
179
178
}
180
179
181
180
/**
@@ -830,85 +829,4 @@ private static function waitForClusterStateUpdatesToFinish(Client $client, int $
830
829
$ stillWaiting = ! empty ($ result ['tasks ' ]);
831
830
} while ($ stillWaiting && time () < ($ start + $ timeout ));
832
831
}
833
-
834
- /**
835
- * Returns all the unexpected ilm policies, removing $exclusions from the list
836
- */
837
- private static function getAllUnexpectedIlmPolicies (Client $ client , array $ exclusions ): array
838
- {
839
- try {
840
- $ policies = $ client ->ilm ()->getLifecycle ();
841
- } catch (ElasticsearchException $ e ) {
842
- return [];
843
- }
844
- foreach ($ policies as $ name => $ value ) {
845
- if (in_array ($ name , $ exclusions )) {
846
- unset($ policies [$ name ]);
847
- }
848
- }
849
- return $ policies ;
850
- }
851
-
852
- /**
853
- * Returns all the unexpected templates
854
- */
855
- private static function getAllUnexpectedTemplates (Client $ client ): array
856
- {
857
- if (!self ::$ hasXPack ) {
858
- return [];
859
- }
860
- $ unexpected = [];
861
- // In case of bwc testing, if all nodes are before 7.7.0 then no need
862
- // to attempt to delete component and composable index templates,
863
- // because these were introduced in 7.7.0:
864
- if (version_compare (self ::getVersion ($ client ), '7.6.99 ' ) > 0 ) {
865
- $ result = $ client ->indices ()->getIndexTemplate ();
866
- foreach ($ result ['index_templates ' ] as $ template ) {
867
- if (!self ::isXPackTemplate ($ template ['name ' ])) {
868
- $ unexpected [$ template ['name ' ]] = true ;
869
- }
870
- }
871
- $ result = $ client ->cluster ()->getComponentTemplate ();
872
- foreach ($ result ['component_templates ' ] as $ template ) {
873
- if (!self ::isXPackTemplate ($ template ['name ' ])) {
874
- $ unexpected [$ template ['name ' ]] = true ;
875
- }
876
- }
877
- }
878
- $ result = $ client ->indices ()->getIndexTemplate ();
879
- foreach ($ result ['index_templates ' ] as $ template ) {
880
- if (!self ::isXPackTemplate ($ template ['name ' ])) {
881
- $ unexpected [$ template ['name ' ]] = true ;
882
- }
883
- }
884
- return array_keys ($ unexpected );
885
- }
886
-
887
-
888
- /**
889
- * This method checks whether ILM policies or templates get recreated after
890
- * they have been deleted. If so, we are probably deleting them unnecessarily,
891
- * potentially causing test performance problems. This could happen for example
892
- * if someone adds a new standard ILM policy but forgets to put it in the
893
- * exclusion list in this test.
894
- */
895
- private static function checkForUnexpectedlyRecreatedObjects (Client $ client ): void
896
- {
897
- if (self ::$ hasIlm ) {
898
- $ policies = self ::getAllUnexpectedIlmPolicies ($ client , self ::preserveILMPolicyIds ());
899
- if (count ($ policies ) > 0 ) {
900
- throw new Exception (sprintf (
901
- "Expected no ILM policies after deletions, but found %s " ,
902
- implode (', ' , array_keys ($ policies ))
903
- ));
904
- }
905
- }
906
- $ templates = self ::getAllUnexpectedTemplates ($ client );
907
- if (count ($ templates ) > 0 ) {
908
- throw new Exception (sprintf (
909
- "Expected no templates after deletions, but found %s " ,
910
- implode (', ' , array_keys ($ templates ))
911
- ));
912
- }
913
- }
914
832
}
0 commit comments