mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-28 10:58:30 +00:00
[7.x] Wipe data streams in each REST test (#55009)
This commit is contained in:
parent
9ec9866acb
commit
30638a0b41
@ -438,6 +438,15 @@ public abstract class ESRestTestCase extends ESTestCase {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if data streams are preserved upon completion of this test. The default implementation wipes data streams.
|
||||
*
|
||||
* @return whether or not to preserve data streams
|
||||
*/
|
||||
protected boolean preserveDataStreamsUponCompletion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls whether or not to preserve cluster settings upon completion of the test. The default implementation is to remove all cluster
|
||||
* settings.
|
||||
@ -551,6 +560,11 @@ public abstract class ESRestTestCase extends ESTestCase {
|
||||
inProgressSnapshots.set(wipeSnapshots());
|
||||
}
|
||||
|
||||
// wipe data streams before indices so that the backing indices for data streams are handled properly
|
||||
if (preserveDataStreamsUponCompletion() == false) {
|
||||
wipeDataStreams();
|
||||
}
|
||||
|
||||
if (preserveIndicesUponCompletion() == false) {
|
||||
// wipe indices
|
||||
wipeAllIndices();
|
||||
@ -629,6 +643,17 @@ public abstract class ESRestTestCase extends ESTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected static void wipeDataStreams() throws IOException {
|
||||
try {
|
||||
adminClient().performRequest(new Request("DELETE", "_data_stream/*"));
|
||||
} catch (ResponseException e) {
|
||||
// We hit a version of ES that doesn't have data streams enabled so it's safe to ignore
|
||||
if (e.getResponse().getStatusLine().getStatusCode() != 405 && e.getResponse().getStatusLine().getStatusCode() != 500) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wipe fs snapshots we created one by one and all repositories so that the next test can create the repositories fresh and they'll
|
||||
* start empty. There isn't an API to delete all snapshots. There is an API to delete all snapshot repositories but that leaves all of
|
||||
|
Loading…
x
Reference in New Issue
Block a user