Skip to content

Commit d14dca9

Browse files
authored
assertBusy in XPackRestIT#awaitCallApi (#54264)
Retries in this method were lost in #45794. This commit reinstates them.
1 parent 912864f commit d14dca9

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
@@ -36,6 +36,7 @@
3636
import java.util.HashMap;
3737
import java.util.List;
3838
import java.util.Map;
39+
import java.util.concurrent.atomic.AtomicReference;
3940
import java.util.function.Supplier;
4041

4142
import static java.util.Collections.emptyList;
@@ -229,11 +230,14 @@ private void awaitCallApi(String apiName,
229230
CheckedFunction<ClientYamlTestResponse, Boolean, IOException> success,
230231
Supplier<String> error) {
231232
try {
232-
// The actual method call that sends the API requests returns a Future, but we immediately
233-
// call .get() on it so there's no need for this method to do any other awaiting.
234-
ClientYamlTestResponse response = callApi(apiName, params, bodies, getApiCallHeaders());
235-
assertEquals(response.getStatusCode(), HttpStatus.SC_OK);
236-
success.apply(response);
233+
final AtomicReference<ClientYamlTestResponse> response = new AtomicReference<>();
234+
assertBusy(() -> {
235+
// The actual method call that sends the API requests returns a Future, but we immediately
236+
// call .get() on it so there's no need for this method to do any other awaiting.
237+
response.set(callApi(apiName, params, bodies, getApiCallHeaders()));
238+
assertEquals(HttpStatus.SC_OK, response.get().getStatusCode());
239+
});
240+
success.apply(response.get());
237241
} catch (Exception e) {
238242
throw new IllegalStateException(error.get(), e);
239243
}

0 commit comments

Comments
 (0)