Skip to content

Commit 9adf2ee

Browse files
committed
reset data in shared clusters
1 parent 52f36f2 commit 9adf2ee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.apache.lucene.tests.util.TimeUnits;
1414
import org.elasticsearch.Version;
1515
import org.elasticsearch.client.Request;
16+
import org.elasticsearch.client.ResponseException;
1617
import org.elasticsearch.client.RestClient;
1718
import org.elasticsearch.common.xcontent.XContentHelper;
1819
import org.elasticsearch.features.NodeFeature;
@@ -35,6 +36,7 @@
3536
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.RequestObjectBuilder;
3637
import org.elasticsearch.xpack.esql.telemetry.TookMetrics;
3738
import org.junit.After;
39+
import org.junit.AfterClass;
3840
import org.junit.Before;
3941
import org.junit.Rule;
4042

@@ -67,6 +69,7 @@
6769
import static org.elasticsearch.xpack.esql.CsvTestUtils.isEnabled;
6870
import static org.elasticsearch.xpack.esql.CsvTestUtils.loadCsvSpecValues;
6971
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.createInferenceEndpoints;
72+
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.deleteInferenceEndpoints;
7073
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;
7174
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
7275
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.COMPLETION;
@@ -137,6 +140,24 @@ public void setup() throws IOException {
137140
}
138141
}
139142

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+
140161
public boolean logResults() {
141162
return false;
142163
}

0 commit comments

Comments
 (0)