Add ensureGreen method for use with adminClient (#113425)

Current ensureGreen test helper method uses client() directly.
Sometimes is useful to call ensureGreen with adminClient() or
another rest client. This PR allows passing a RestClient into
ensureGreen.
This commit is contained in:
Parker Timmins 2024-09-24 08:39:58 -05:00 committed by GitHub
parent d07d167430
commit c17cf18d5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 9 deletions

View file

@ -0,0 +1,5 @@
pr: 113425
summary: Add `ensureGreen` test method for use with `adminClient`
area: Infra/Metrics
type: enhancement
issues: []

View file

@ -1721,7 +1721,11 @@ public abstract class ESRestTestCase extends ESTestCase {
* @param index index to test for
**/
public final void ensureGreen(String index) throws IOException {
ensureHealth(index, (request) -> {
ensureGreen(client(), index);
}
public final void ensureGreen(RestClient client, String index) throws IOException {
ensureHealth(client, index, (request) -> {
request.addParameter("wait_for_status", "green");
request.addParameter("wait_for_no_relocating_shards", "true");
final String ensureGreenTimeout = getEnsureGreenTimeout();

View file

@ -405,13 +405,8 @@ public class CcrRollingUpgradeIT extends AbstractMultiClusterUpgradeTestCase {
assertOK(client.performRequest(new Request("POST", "/" + followerIndex + "/_ccr/resume_follow")));
}
private static void ensureGreen(RestClient client, String index) throws IOException {
Request request = new Request("GET", "/_cluster/health/" + index);
request.addParameter("wait_for_status", "green");
request.addParameter("wait_for_no_relocating_shards", "true");
request.addParameter("timeout", "70s");
request.addParameter("level", "shards");
client.performRequest(request);
@Override
protected final String getEnsureGreenTimeout() {
return "70s";
}
}