In internal test clusters tests we check that wiping all indices was acknowledged but in REST tests we didn't. This aligns the behavior in both kinds of tests. Relates #45605 which might be caused by unacked deletes that were just slow.
This commit is contained in:
parent
a1b88ca009
commit
bfddaaa2ae
|
@ -513,14 +513,7 @@ public abstract class ESRestTestCase extends ESTestCase {
|
||||||
|
|
||||||
if (preserveIndicesUponCompletion() == false) {
|
if (preserveIndicesUponCompletion() == false) {
|
||||||
// wipe indices
|
// wipe indices
|
||||||
try {
|
wipeAllIndices();
|
||||||
adminClient().performRequest(new Request("DELETE", "*"));
|
|
||||||
} catch (ResponseException e) {
|
|
||||||
// 404 here just means we had no indexes
|
|
||||||
if (e.getResponse().getStatusLine().getStatusCode() != 404) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wipe index templates
|
// wipe index templates
|
||||||
|
@ -563,6 +556,20 @@ public abstract class ESRestTestCase extends ESTestCase {
|
||||||
assertThat("Found in progress snapshots [" + inProgressSnapshots.get() + "].", inProgressSnapshots.get(), anEmptyMap());
|
assertThat("Found in progress snapshots [" + inProgressSnapshots.get() + "].", inProgressSnapshots.get(), anEmptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static void wipeAllIndices() throws IOException {
|
||||||
|
try {
|
||||||
|
final Response response = adminClient().performRequest(new Request("DELETE", "*"));
|
||||||
|
try (InputStream is = response.getEntity().getContent()) {
|
||||||
|
assertTrue((boolean) XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true).get("acknowledged"));
|
||||||
|
}
|
||||||
|
} catch (ResponseException e) {
|
||||||
|
// 404 here just means we had no indexes
|
||||||
|
if (e.getResponse().getStatusLine().getStatusCode() != 404) {
|
||||||
|
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
|
* 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
|
* 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
|
||||||
|
|
|
@ -355,7 +355,7 @@ public abstract class DataFrameRestTestCase extends ESRestTestCase {
|
||||||
public static void removeIndices() throws Exception {
|
public static void removeIndices() throws Exception {
|
||||||
// we might have disabled wiping indices, but now its time to get rid of them
|
// we might have disabled wiping indices, but now its time to get rid of them
|
||||||
// note: can not use super.cleanUpCluster() as this method must be static
|
// note: can not use super.cleanUpCluster() as this method must be static
|
||||||
wipeIndices();
|
wipeAllIndices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void wipeDataFrameTransforms() throws IOException {
|
public void wipeDataFrameTransforms() throws IOException {
|
||||||
|
@ -403,17 +403,6 @@ public abstract class DataFrameRestTestCase extends ESRestTestCase {
|
||||||
waitForPendingTasks(adminClient(), taskName -> taskName.startsWith(DataFrameField.TASK_NAME) == false);
|
waitForPendingTasks(adminClient(), taskName -> taskName.startsWith(DataFrameField.TASK_NAME) == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void wipeIndices() throws IOException {
|
|
||||||
try {
|
|
||||||
adminClient().performRequest(new Request("DELETE", "*"));
|
|
||||||
} catch (ResponseException e) {
|
|
||||||
// 404 here just means we had no indexes
|
|
||||||
if (e.getResponse().getStatusLine().getStatusCode() != 404) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getDataFrameCheckpoint(String transformId) throws IOException {
|
static int getDataFrameCheckpoint(String transformId) throws IOException {
|
||||||
Response statsResponse = client().performRequest(new Request("GET", DATAFRAME_ENDPOINT + transformId + "/_stats"));
|
Response statsResponse = client().performRequest(new Request("GET", DATAFRAME_ENDPOINT + transformId + "/_stats"));
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
|
||||||
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction;
|
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesAction;
|
||||||
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
|
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
|
||||||
import org.elasticsearch.client.Request;
|
import org.elasticsearch.client.Request;
|
||||||
import org.elasticsearch.client.ResponseException;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -205,12 +204,7 @@ public abstract class SqlSecurityTestCase extends ESRestTestCase {
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void wipeIndicesAfterTests() throws IOException {
|
public static void wipeIndicesAfterTests() throws IOException {
|
||||||
try {
|
try {
|
||||||
adminClient().performRequest(new Request("DELETE", "*"));
|
wipeAllIndices();
|
||||||
} catch (ResponseException e) {
|
|
||||||
// 404 here just means we had no indexes
|
|
||||||
if (e.getResponse().getStatusLine().getStatusCode() != 404) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
// Clear the static state so other subclasses can reuse it later
|
// Clear the static state so other subclasses can reuse it later
|
||||||
oneTimeSetup = false;
|
oneTimeSetup = false;
|
||||||
|
|
Loading…
Reference in New Issue