[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;
|
||||
}
|
||||
|
||||
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) {
|
||||
MlMetadata mlMetadata = clusterState.metaData().custom(MlMetadata.TYPE);
|
||||
Job job = mlMetadata.getJobs().get(jobId);
|
||||
String jobResultIndex = AnomalyDetectorsIndex.jobResultsIndexName(job.getResultsIndexName());
|
||||
String[] indices = new String[]{AnomalyDetectorsIndex.jobStateIndexName(), jobResultIndex, JobProvider.ML_META_INDEX};
|
||||
String[] indices = indicesOfInterest(job);
|
||||
for (String index : indices) {
|
||||
// Indices are created on demand from templates.
|
||||
// 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());
|
||||
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()) {
|
||||
routingTable.remove(indexToRemove);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue