| 
13 | 13 | import org.apache.lucene.tests.util.TimeUnits;  | 
14 | 14 | import org.elasticsearch.Version;  | 
15 | 15 | import org.elasticsearch.client.Request;  | 
 | 16 | +import org.elasticsearch.client.ResponseException;  | 
16 | 17 | import org.elasticsearch.client.RestClient;  | 
17 | 18 | import org.elasticsearch.common.xcontent.XContentHelper;  | 
18 | 19 | import org.elasticsearch.features.NodeFeature;  | 
 | 
35 | 36 | import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.RequestObjectBuilder;  | 
36 | 37 | import org.elasticsearch.xpack.esql.telemetry.TookMetrics;  | 
37 | 38 | import org.junit.After;  | 
 | 39 | +import org.junit.AfterClass;  | 
38 | 40 | import org.junit.Before;  | 
39 | 41 | import org.junit.Rule;  | 
40 | 42 | 
 
  | 
 | 
67 | 69 | import static org.elasticsearch.xpack.esql.CsvTestUtils.isEnabled;  | 
68 | 70 | import static org.elasticsearch.xpack.esql.CsvTestUtils.loadCsvSpecValues;  | 
69 | 71 | import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.createInferenceEndpoints;  | 
 | 72 | +import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.deleteInferenceEndpoints;  | 
70 | 73 | import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;  | 
71 | 74 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;  | 
72 | 75 | import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.COMPLETION;  | 
@@ -137,6 +140,24 @@ public void setup() throws IOException {  | 
137 | 140 |         }  | 
138 | 141 |     }  | 
139 | 142 | 
 
  | 
 | 143 | +    @AfterClass  | 
 | 144 | +    public static void wipeTestData() throws IOException {  | 
 | 145 | +        if (testClustersOk == false) {  | 
 | 146 | +            return;  | 
 | 147 | +        }  | 
 | 148 | +        try {  | 
 | 149 | +            dataLoaded = false;  | 
 | 150 | +            adminClient().performRequest(new Request("DELETE", "/*"));  | 
 | 151 | +        } catch (ResponseException e) {  | 
 | 152 | +            // 404 here just means we had no indexes  | 
 | 153 | +            if (e.getResponse().getStatusLine().getStatusCode() != 404) {  | 
 | 154 | +                throw e;  | 
 | 155 | +            }  | 
 | 156 | +        }  | 
 | 157 | + | 
 | 158 | +        deleteInferenceEndpoints(adminClient());  | 
 | 159 | +    }  | 
 | 160 | + | 
140 | 161 |     public boolean logResults() {  | 
141 | 162 |         return false;  | 
142 | 163 |     }  | 
 | 
0 commit comments