|
7 | 7 | package org.elasticsearch.xpack.ml; |
8 | 8 |
|
9 | 9 | import org.elasticsearch.action.ActionListener; |
| 10 | +import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateAction; |
| 11 | +import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateRequest; |
10 | 12 | import org.elasticsearch.cluster.ClusterState; |
11 | 13 | import org.elasticsearch.common.settings.Settings; |
12 | 14 | import org.elasticsearch.common.unit.ByteSizeValue; |
|
32 | 34 | import org.elasticsearch.xpack.datastreams.DataStreamsPlugin; |
33 | 35 | import org.elasticsearch.xpack.ilm.IndexLifecycle; |
34 | 36 |
|
35 | | -import java.util.Arrays; |
36 | 37 | import java.util.Collection; |
37 | 38 | import java.util.Collections; |
38 | 39 | import java.util.Map; |
|
42 | 43 | import java.util.function.Consumer; |
43 | 44 | import java.util.function.Function; |
44 | 45 |
|
45 | | -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
46 | 46 | import static org.mockito.Matchers.any; |
47 | 47 | import static org.mockito.Mockito.doAnswer; |
48 | 48 | import static org.mockito.Mockito.mock; |
@@ -88,28 +88,11 @@ protected Collection<Class<? extends Plugin>> getPlugins() { |
88 | 88 | IndexLifecycle.class); |
89 | 89 | } |
90 | 90 |
|
91 | | - /** |
92 | | - * This cleanup is to fix the problem described in |
93 | | - * https://github.com/elastic/elasticsearch/issues/38952 |
94 | | - */ |
95 | 91 | @Override |
96 | 92 | public void tearDown() throws Exception { |
97 | 93 | try { |
98 | 94 | logger.trace("[{}#{}]: ML-specific after test cleanup", getTestClass().getSimpleName(), getTestName()); |
99 | | - String[] nonAnnotationMlIndices; |
100 | | - boolean mlAnnotationsIndexExists; |
101 | | - do { |
102 | | - String[] mlIndices = client().admin().indices().prepareGetIndex().addIndices(".ml-*").get().indices(); |
103 | | - nonAnnotationMlIndices = Arrays.stream(mlIndices).filter(name -> name.startsWith(".ml-annotations") == false) |
104 | | - .toArray(String[]::new); |
105 | | - mlAnnotationsIndexExists = mlIndices.length > nonAnnotationMlIndices.length; |
106 | | - } while (nonAnnotationMlIndices.length > 0 && mlAnnotationsIndexExists == false); |
107 | | - if (nonAnnotationMlIndices.length > 0) { |
108 | | - // Delete the ML indices apart from the annotations index. The annotations index will be deleted by the |
109 | | - // base class cleanup. We want to delete all the others first so that the annotations index doesn't get |
110 | | - // automatically recreated. |
111 | | - assertAcked(client().admin().indices().prepareDelete(nonAnnotationMlIndices).get()); |
112 | | - } |
| 95 | + client().execute(ResetFeatureStateAction.INSTANCE, new ResetFeatureStateRequest()).actionGet(); |
113 | 96 | } finally { |
114 | 97 | super.tearDown(); |
115 | 98 | } |
|
0 commit comments