Skip to content

Commit e13f34b

Browse files
committed
assertBusy in XPackRestIT#awaitCallApi (#54264)
Retries in this method were lost in #45794. This commit reinstates them.
1 parent ad2cc48 commit e13f34b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.HashMap;
4040
import java.util.List;
4141
import java.util.Map;
42+
import java.util.concurrent.atomic.AtomicReference;
4243
import java.util.function.Supplier;
4344

4445
import static java.util.Collections.emptyList;
@@ -284,11 +285,14 @@ private void awaitCallApi(String apiName,
284285
CheckedFunction<ClientYamlTestResponse, Boolean, IOException> success,
285286
Supplier<String> error) {
286287
try {
287-
// The actual method call that sends the API requests returns a Future, but we immediately
288-
// call .get() on it so there's no need for this method to do any other awaiting.
289-
ClientYamlTestResponse response = callApi(apiName, params, bodies, getApiCallHeaders());
290-
assertEquals(response.getStatusCode(), HttpStatus.SC_OK);
291-
success.apply(response);
288+
final AtomicReference<ClientYamlTestResponse> response = new AtomicReference<>();
289+
assertBusy(() -> {
290+
// The actual method call that sends the API requests returns a Future, but we immediately
291+
// call .get() on it so there's no need for this method to do any other awaiting.
292+
response.set(callApi(apiName, params, bodies, getApiCallHeaders()));
293+
assertEquals(HttpStatus.SC_OK, response.get().getStatusCode());
294+
});
295+
success.apply(response.get());
292296
} catch (Exception e) {
293297
throw new IllegalStateException(error.get(), e);
294298
}

0 commit comments

Comments
 (0)