Fix timeouts and rebinding check in quic_client_interop_test
gfe-relnote: n/a (test-only tool change)
PiperOrigin-RevId: 293349649
Change-Id: Ie06ac6f2190da8aeff0796a6bec6efd4a13d056d
diff --git a/quic/tools/quic_client.cc b/quic/tools/quic_client.cc
index 50ba040..a9a9320 100644
--- a/quic/tools/quic_client.cc
+++ b/quic/tools/quic_client.cc
@@ -84,6 +84,23 @@
std::move(proof_verifier),
std::move(session_cache)) {}
+QuicClient::QuicClient(QuicSocketAddress server_address,
+ const QuicServerId& server_id,
+ const ParsedQuicVersionVector& supported_versions,
+ const QuicConfig& config,
+ QuicEpollServer* epoll_server,
+ std::unique_ptr<ProofVerifier> proof_verifier,
+ std::unique_ptr<SessionCache> session_cache)
+ : QuicClient(
+ server_address,
+ server_id,
+ supported_versions,
+ config,
+ epoll_server,
+ QuicWrapUnique(new QuicClientEpollNetworkHelper(epoll_server, this)),
+ std::move(proof_verifier),
+ std::move(session_cache)) {}
+
QuicClient::QuicClient(
QuicSocketAddress server_address,
const QuicServerId& server_id,
diff --git a/quic/tools/quic_client.h b/quic/tools/quic_client.h
index 10c61f3..7ce795d 100644
--- a/quic/tools/quic_client.h
+++ b/quic/tools/quic_client.h
@@ -49,6 +49,13 @@
QuicEpollServer* epoll_server,
std::unique_ptr<ProofVerifier> proof_verifier,
std::unique_ptr<SessionCache> session_cache);
+ QuicClient(QuicSocketAddress server_address,
+ const QuicServerId& server_id,
+ const ParsedQuicVersionVector& supported_versions,
+ const QuicConfig& config,
+ QuicEpollServer* epoll_server,
+ std::unique_ptr<ProofVerifier> proof_verifier,
+ std::unique_ptr<SessionCache> session_cache);
// This will take ownership of a passed in network primitive.
QuicClient(QuicSocketAddress server_address,
const QuicServerId& server_id,
diff --git a/quic/tools/quic_client_interop_test_bin.cc b/quic/tools/quic_client_interop_test_bin.cc
index 03d32a5..0ea2c7c 100644
--- a/quic/tools/quic_client_interop_test_bin.cc
+++ b/quic/tools/quic_client_interop_test_bin.cc
@@ -163,9 +163,12 @@
auto session_cache = std::make_unique<test::SimpleSessionCache>();
QuicEpollServer epoll_server;
QuicEpollClock epoll_clock(&epoll_server);
+ QuicConfig config;
+ QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(20);
+ config.SetIdleNetworkTimeout(timeout, timeout);
auto client = std::make_unique<QuicClient>(
- addr, server_id, versions, &epoll_server, std::move(proof_verifier),
- std::move(session_cache));
+ addr, server_id, versions, config, &epoll_server,
+ std::move(proof_verifier), std::move(session_cache));
client->set_connection_debug_visitor(this);
if (!client->Initialize()) {
QUIC_LOG(ERROR) << "Failed to initialize client";
@@ -202,18 +205,7 @@
header_block[":authority"] = authority;
header_block[":path"] = "/";
client->set_store_response(true);
- client->SendRequest(header_block, "", /*fin=*/true);
-
- const QuicTime request_start_time = epoll_clock.Now();
- static const auto request_timeout = QuicTime::Delta::FromSeconds(20);
- bool request_timed_out = false;
- while (client->WaitForEvents()) {
- if (epoll_clock.Now() - request_start_time >= request_timeout) {
- QUIC_LOG(ERROR) << "Timed out waiting for HTTP response";
- request_timed_out = true;
- break;
- }
- }
+ client->SendRequestAndWaitForResponse(header_block, "", /*fin=*/true);
client_stats = connection->GetStats();
QuicSentPacketManager* sent_packet_manager =
@@ -226,7 +218,7 @@
InsertFeature(Feature::kStreamData);
}
- if (request_timed_out || !client->connected()) {
+ if (!client->connected()) {
return;
}
@@ -240,17 +232,12 @@
if (attempt_rebind) {
// Now make a second request after switching to a different client port.
if (client->ChangeEphemeralPort()) {
- client->SendRequest(header_block, "", /*fin=*/true);
-
- const QuicTime second_request_start_time = epoll_clock.Now();
- while (client->WaitForEvents()) {
- if (epoll_clock.Now() - second_request_start_time >=
- request_timeout) {
- // Rebinding does not work, retry without attempting it.
- AttemptRequest(addr, authority, server_id, test_version_negotiation,
- /*attempt_rebind=*/false);
- return;
- }
+ client->SendRequestAndWaitForResponse(header_block, "", /*fin=*/true);
+ if (!client->connected()) {
+ // Rebinding does not work, retry without attempting it.
+ AttemptRequest(addr, authority, server_id, test_version_negotiation,
+ /*attempt_rebind=*/false);
+ return;
}
InsertFeature(Feature::kRebinding);