[TEST] making failing restrictions tighter.
Original commit: elastic/x-pack-elasticsearch@b22352a5ba
This commit is contained in:
parent
06277c3677
commit
67e4544267
|
@ -61,8 +61,8 @@ public class DatafeedJobsIT extends SecurityIntegTestCase {
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void cleanupWorkaround() throws Exception {
|
public void cleanupWorkaround() throws Exception {
|
||||||
deleteAllDatafeeds(client());
|
deleteAllDatafeeds(logger, client());
|
||||||
deleteAllJobs(client());
|
deleteAllJobs(logger, client());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensureClusterStateConsistency() throws IOException {
|
public void ensureClusterStateConsistency() throws IOException {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.ml.support;
|
package org.elasticsearch.xpack.ml.support;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||||
import org.elasticsearch.action.bulk.BulkResponse;
|
import org.elasticsearch.action.bulk.BulkResponse;
|
||||||
|
@ -18,7 +17,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.indices.recovery.RecoveryState;
|
import org.elasticsearch.indices.recovery.RecoveryState;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
||||||
import org.elasticsearch.xpack.XPackPlugin;
|
import org.elasticsearch.xpack.XPackPlugin;
|
||||||
|
@ -186,8 +184,8 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase {
|
||||||
@After
|
@After
|
||||||
public void cleanupWorkaround() throws Exception {
|
public void cleanupWorkaround() throws Exception {
|
||||||
logger.info("[{}#{}]: Cleaning up datafeeds and jobs after test", getTestClass().getSimpleName(), getTestName());
|
logger.info("[{}#{}]: Cleaning up datafeeds and jobs after test", getTestClass().getSimpleName(), getTestName());
|
||||||
deleteAllDatafeeds(client());
|
deleteAllDatafeeds(logger, client());
|
||||||
deleteAllJobs(client());
|
deleteAllJobs(logger, client());
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries()
|
RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries()
|
||||||
.setActiveOnly(true)
|
.setActiveOnly(true)
|
||||||
|
@ -244,7 +242,7 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAllDatafeeds(Client client) throws Exception {
|
public static void deleteAllDatafeeds(Logger logger, Client client) throws Exception {
|
||||||
MetaData metaData = client.admin().cluster().prepareState().get().getState().getMetaData();
|
MetaData metaData = client.admin().cluster().prepareState().get().getState().getMetaData();
|
||||||
MlMetadata mlMetadata = metaData.custom(MlMetadata.TYPE);
|
MlMetadata mlMetadata = metaData.custom(MlMetadata.TYPE);
|
||||||
for (DatafeedConfig datafeed : mlMetadata.getDatafeeds().values()) {
|
for (DatafeedConfig datafeed : mlMetadata.getDatafeeds().values()) {
|
||||||
|
@ -254,8 +252,9 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase {
|
||||||
client.execute(StopDatafeedAction.INSTANCE, new StopDatafeedAction.Request(datafeedId)).get();
|
client.execute(StopDatafeedAction.INSTANCE, new StopDatafeedAction.Request(datafeedId)).get();
|
||||||
assertTrue(stopResponse.isStopped());
|
assertTrue(stopResponse.isStopped());
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
// CONFLICT is ok, as it means the datafeed has already stopped, which isn't an issue at all.
|
if (e.getMessage().contains("datafeed already stopped, expected datafeed state [started], but got [stopped]")) {
|
||||||
if (RestStatus.CONFLICT != ExceptionsHelper.status(e.getCause())) {
|
logger.debug("failed to stop datafeed [" + datafeedId + "]", e);
|
||||||
|
} else {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +273,7 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteAllJobs(Client client) throws Exception {
|
public static void deleteAllJobs(Logger logger, Client client) throws Exception {
|
||||||
MetaData metaData = client.admin().cluster().prepareState().get().getState().getMetaData();
|
MetaData metaData = client.admin().cluster().prepareState().get().getState().getMetaData();
|
||||||
MlMetadata mlMetadata = metaData.custom(MlMetadata.TYPE);
|
MlMetadata mlMetadata = metaData.custom(MlMetadata.TYPE);
|
||||||
for (Map.Entry<String, Job> entry : mlMetadata.getJobs().entrySet()) {
|
for (Map.Entry<String, Job> entry : mlMetadata.getJobs().entrySet()) {
|
||||||
|
@ -286,8 +285,10 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase {
|
||||||
client.execute(CloseJobAction.INSTANCE, closeRequest).get();
|
client.execute(CloseJobAction.INSTANCE, closeRequest).get();
|
||||||
assertTrue(response.isClosed());
|
assertTrue(response.isClosed());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// CONFLICT is ok, as it means the job has been closed already, which isn't an issue at all.
|
if (e.getMessage().contains("expected job state [opened], but got [closed]")
|
||||||
if (RestStatus.CONFLICT != ExceptionsHelper.status(e.getCause())) {
|
|| e.getMessage().contains("expected job state [opened], but got [closing]")) {
|
||||||
|
logger.debug("job [" + jobId + "] has already been closed", e);
|
||||||
|
} else {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue