[ML] Fix intermittent test failure (occasionally deleted an index we don’t care about)
Original commit: elastic/x-pack-elasticsearch@56c7bdb5b9
This commit is contained in:
parent
a09e8a260a
commit
f67d8c3746
|
@ -454,11 +454,15 @@ public class OpenJobAction extends Action<OpenJobAction.Request, PersistentActio
|
||||||
return minLoadedNode;
|
return minLoadedNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String[] indicesOfInterest(Job job) {
|
||||||
|
String jobResultIndex = AnomalyDetectorsIndex.jobResultsIndexName(job.getResultsIndexName());
|
||||||
|
return new String[]{AnomalyDetectorsIndex.jobStateIndexName(), jobResultIndex, JobProvider.ML_META_INDEX};
|
||||||
|
}
|
||||||
|
|
||||||
static boolean verifyIndicesPrimaryShardsAreActive(Logger logger, String jobId, ClusterState clusterState) {
|
static boolean verifyIndicesPrimaryShardsAreActive(Logger logger, String jobId, ClusterState clusterState) {
|
||||||
MlMetadata mlMetadata = clusterState.metaData().custom(MlMetadata.TYPE);
|
MlMetadata mlMetadata = clusterState.metaData().custom(MlMetadata.TYPE);
|
||||||
Job job = mlMetadata.getJobs().get(jobId);
|
Job job = mlMetadata.getJobs().get(jobId);
|
||||||
String jobResultIndex = AnomalyDetectorsIndex.jobResultsIndexName(job.getResultsIndexName());
|
String[] indices = indicesOfInterest(job);
|
||||||
String[] indices = new String[]{AnomalyDetectorsIndex.jobStateIndexName(), jobResultIndex, JobProvider.ML_META_INDEX};
|
|
||||||
for (String index : indices) {
|
for (String index : indices) {
|
||||||
// Indices are created on demand from templates.
|
// Indices are created on demand from templates.
|
||||||
// It is not an error if the index doesn't exist yet
|
// It is not an error if the index doesn't exist yet
|
||||||
|
|
|
@ -276,7 +276,10 @@ public class OpenJobActionTests extends ESTestCase {
|
||||||
|
|
||||||
metaData = new MetaData.Builder(cs.metaData());
|
metaData = new MetaData.Builder(cs.metaData());
|
||||||
routingTable = new RoutingTable.Builder(cs.routingTable());
|
routingTable = new RoutingTable.Builder(cs.routingTable());
|
||||||
String indexToRemove = randomFrom(cs.metaData().getConcreteAllIndices());
|
|
||||||
|
MlMetadata mlMetadata = cs.metaData().custom(MlMetadata.TYPE);
|
||||||
|
Job job = mlMetadata.getJobs().get("job_id");
|
||||||
|
String indexToRemove = randomFrom(OpenJobAction.indicesOfInterest(job));
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
routingTable.remove(indexToRemove);
|
routingTable.remove(indexToRemove);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue