ML: Fix testMigrateConfigs (#37373)

* ML: :s/execute/get

* Fixing other broken tests

* unmuting test
This commit is contained in:
Benjamin Trent 2019-01-11 13:29:30 -06:00 committed by GitHub
parent de52ba1f78
commit 5101e51891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -8,9 +8,11 @@ package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
@ -455,8 +457,9 @@ public class TransportOpenJobActionTests extends ESTestCase {
metaData = new MetaData.Builder(cs.metaData());
routingTable = new RoutingTable.Builder(cs.routingTable());
String indexToRemove = randomFrom(TransportOpenJobAction.indicesOfInterest(".ml-anomalies-shared"));
IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver();
String indexToRemove = randomFrom(indexNameExpressionResolver.concreteIndexNames(cs, IndicesOptions.lenientExpandOpen(),
TransportOpenJobAction.indicesOfInterest(".ml-anomalies-shared")));
if (randomBoolean()) {
routingTable.remove(indexToRemove);
} else {

View File

@ -51,6 +51,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.persistent.PersistentTasksClusterService.needsReassignment;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasEntry;
public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
@ -399,8 +400,9 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
String detailedMessage = detail.getMessage();
assertTrue(detailedMessage,
detailedMessage.startsWith("Could not open job because no suitable nodes were found, allocation explanation"));
assertTrue(detailedMessage, detailedMessage.endsWith("because not all primary shards are active for the following indices " +
"[.ml-state,.ml-anomalies-shared]]"));
assertThat(detailedMessage, containsString("because not all primary shards are active for the following indices"));
assertThat(detailedMessage, containsString(".ml-state"));
assertThat(detailedMessage, containsString(".ml-anomalies-shared"));
logger.info("Start data node");
String nonMlNode = internalCluster().startNode(Settings.builder()

View File

@ -120,7 +120,6 @@ public class MlConfigMigratorIT extends MlSingleNodeTestCase {
assertNull(alreadyMigratedJob.getCustomSettings());
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37374")
public void testMigrateConfigs() throws InterruptedException, IOException {
// and jobs and datafeeds clusterstate
MlMetadata.Builder mlMetadata = new MlMetadata.Builder();
@ -311,7 +310,7 @@ public class MlConfigMigratorIT extends MlSingleNodeTestCase {
}
public void assertSnapshot(MlMetadata expectedMlMetadata) throws IOException {
client().admin().indices().prepareRefresh(AnomalyDetectorsIndex.jobStateIndexPattern()).execute();
client().admin().indices().prepareRefresh(AnomalyDetectorsIndex.jobStateIndexPattern()).get();
SearchResponse searchResponse = client()
.prepareSearch(AnomalyDetectorsIndex.jobStateIndexPattern())
.setTypes(ElasticsearchMappings.DOC_TYPE)