[TEST] ensure "index1" is yellow before searching in MigrateToolIT
If the search runs before the primary shards are initialized for the "index1" index, the search may fail for unrelated reasons. Resolves elastic/elasticsearch#2818 Original commit: elastic/x-pack-elasticsearch@654ba9e142
This commit is contained in:
parent
1fe0f5c7ac
commit
7e4b200f43
|
@ -118,6 +118,13 @@ public class MigrateToolIT extends MigrateToolTestCase {
|
|||
String token = basicAuthHeaderValue("bob", new SecuredString("changeme".toCharArray()));
|
||||
// Create "index1" index and try to search from it as "bob"
|
||||
client.filterWithHeader(Collections.singletonMap("Authorization", token)).admin().indices().prepareCreate("index1").get();
|
||||
// Wait for the index to be ready so it doesn't fail if no shards are initialized
|
||||
client.admin().cluster().health(Requests.clusterHealthRequest("index1")
|
||||
.timeout(TimeValue.timeValueSeconds(30))
|
||||
.waitForYellowStatus()
|
||||
.waitForEvents(Priority.LANGUID)
|
||||
.waitForRelocatingShards(0))
|
||||
.actionGet();
|
||||
SearchResponse searchResp = client.filterWithHeader(Collections.singletonMap("Authorization", token)).prepareSearch("index1").get();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue