[EventEngine] Fix HttpCli test to deail with EventEngine async execution (#35776)

One test (`CallerPollentsAreNotReferencedAfterCallbackIsRan`) was not waiting for a callback to be run before finishing when the EventEngine client is in use. With the iomgr implementation, `exec_ctx.Flush();` previously guaranteed that the callback would be executed before the test ended, but the EventEngine runs it in a separate thread, with the EventEngine shim providing its own isolated ExecCtx. This fix simply waits for the callback to be run before exiting, in the same way many other tests in this file wait on iomgr-based callback execution.

Closes #35776

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35776 from drfloob:httpcli-test-async 3c920da741
PiperOrigin-RevId: 603175531
pull/35793/head
AJ Heller 1 year ago committed by Copybara-Service
parent 6e9dad7deb
commit 2288b63601
  1. 12
      test/core/http/httpcli_test.cc

@ -475,11 +475,19 @@ TEST_F(HttpRequestTest, CallerPollentsAreNotReferencedAfterCallbackIsRan) {
http_request->Start();
exec_ctx.Flush();
http_request.reset(); // cancel the request
// With iomgr polling:
// Since the request was cancelled, the on_done callback should be flushed
// out on the ExecCtx flush below. When the on_done callback is ran, it will
// eagerly destroy 'request_state.pollset_set_to_destroy_eagerly'. Thus, we
// can't poll on that pollset here.
// eagerly destroy 'request_state.pollset_set_to_destroy_eagerly'. PollUntil's
// predicate should return true immediately.
//
// With EventEngine polling:
// Since the callback will be run asynchronously in another thread, with an
// independent ExecCtx, PollUntil is used here to ensure this test does not
// finish before the callback is run.
exec_ctx.Flush();
PollUntil([&request_state]() { return request_state.done; },
AbslDeadlineSeconds(60));
}
void CancelRequest(grpc_core::HttpRequest* req) {

Loading…
Cancel
Save