assertBusy in XPackRestIT#awaitCallApi (#54264)

Retries in this method were lost in #45794. This commit reinstates them.
This commit is contained in:
David Turner 2020-03-26 16:15:31 +00:00
parent cc981fa377
commit fc92bf4208
1 changed files with 9 additions and 5 deletions

View File

@ -36,6 +36,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import static java.util.Collections.emptyList;
@ -229,11 +230,14 @@ public class XPackRestIT extends ESClientYamlSuiteTestCase {
CheckedFunction<ClientYamlTestResponse, Boolean, IOException> success,
Supplier<String> error) {
try {
final AtomicReference<ClientYamlTestResponse> response = new AtomicReference<>();
assertBusy(() -> {
// The actual method call that sends the API requests returns a Future, but we immediately
// call .get() on it so there's no need for this method to do any other awaiting.
ClientYamlTestResponse response = callApi(apiName, params, bodies, getApiCallHeaders());
assertEquals(response.getStatusCode(), HttpStatus.SC_OK);
success.apply(response);
response.set(callApi(apiName, params, bodies, getApiCallHeaders()));
assertEquals(HttpStatus.SC_OK, response.get().getStatusCode());
});
success.apply(response.get());
} catch (Exception e) {
throw new IllegalStateException(error.get(), e);
}