@@ -149,6 +149,9 @@ def wipe_cluster(client):
149149 wipe_tasks (client )
150150 wipe_node_shutdown_metadata (client )
151151 wait_for_pending_datafeeds_and_jobs (client )
152+ wipe_calendars (client )
153+ wipe_filters (client )
154+ wipe_transforms (client )
152155
153156 wait_for_cluster_state_updates_to_finish (client )
154157 if close_after_wipe :
@@ -334,7 +337,7 @@ def wait_for_pending_tasks(client, filter, timeout=30):
334337 break
335338
336339
337- def wait_for_pending_datafeeds_and_jobs (client , timeout = 30 ):
340+ def wait_for_pending_datafeeds_and_jobs (client : Elasticsearch , timeout = 30 ):
338341 end_time = time .time () + timeout
339342 while time .time () < end_time :
340343 resp = client .ml .get_datafeeds (datafeed_id = "*" , allow_no_match = True )
@@ -345,6 +348,7 @@ def wait_for_pending_datafeeds_and_jobs(client, timeout=30):
345348 datafeed_id = datafeed ["datafeed_id" ]
346349 )
347350
351+ end_time = time .time () + timeout
348352 while time .time () < end_time :
349353 resp = client .ml .get_jobs (job_id = "*" , allow_no_match = True )
350354 if resp ["count" ] == 0 :
@@ -353,6 +357,56 @@ def wait_for_pending_datafeeds_and_jobs(client, timeout=30):
353357 client .options (ignore_status = 404 ).ml .close_job (job_id = job ["job_id" ])
354358 client .options (ignore_status = 404 ).ml .delete_job (job_id = job ["job_id" ])
355359
360+ end_time = time .time () + timeout
361+ while time .time () < end_time :
362+ resp = client .ml .get_data_frame_analytics (id = "*" )
363+ if resp ["count" ] == 0 :
364+ break
365+ for job in resp ["data_frame_analytics" ]:
366+ client .options (ignore_status = 404 ).ml .stop_data_frame_analytics (id = job ["id" ])
367+ client .options (ignore_status = 404 ).ml .delete_data_frame_analytics (
368+ id = job ["id" ]
369+ )
370+
371+
372+ def wipe_filters (client : Elasticsearch , timeout = 30 ):
373+ end_time = time .time () + timeout
374+ while time .time () < end_time :
375+ resp = client .ml .get_filters (filter_id = "*" )
376+ if resp ["count" ] == 0 :
377+ break
378+ for filter in resp ["filters" ]:
379+ client .options (ignore_status = 404 ).ml .delete_filter (
380+ filter_id = filter ["filter_id" ]
381+ )
382+
383+
384+ def wipe_calendars (client : Elasticsearch , timeout = 30 ):
385+ end_time = time .time () + timeout
386+ while time .time () < end_time :
387+ resp = client .ml .get_calendars (calendar_id = "*" )
388+ if resp ["count" ] == 0 :
389+ break
390+ for calendar in resp ["calendars" ]:
391+ client .options (ignore_status = 404 ).ml .delete_calendar (
392+ calendar_id = calendar ["calendar_id" ]
393+ )
394+
395+
396+ def wipe_transforms (client : Elasticsearch , timeout = 30 ):
397+ end_time = time .time () + timeout
398+ while time .time () < end_time :
399+ resp = client .transform .get_transform (transform_id = "*" )
400+ if resp ["count" ] == 0 :
401+ break
402+ for trasnform in resp ["transforms" ]:
403+ client .options (ignore_status = 404 ).transform .stop_transform (
404+ transform_id = trasnform ["id" ]
405+ )
406+ client .options (ignore_status = 404 ).transform .delete_transform (
407+ transform_id = trasnform ["id" ]
408+ )
409+
356410
357411def wait_for_cluster_state_updates_to_finish (client , timeout = 30 ):
358412 end_time = time .time () + timeout
0 commit comments