Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retry connection if timed out #4329

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 44 additions & 29 deletions src/test/lib/HandshakeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,42 +284,57 @@ QuicTestConnect(
TEST_QUIC_SUCCEEDED(Client.SetRemoteAddr(RemoteAddr));
}

TEST_QUIC_SUCCEEDED(
Client.Start(
ClientConfiguration,
QuicAddrFamily,
QUIC_LOCALHOST_FOR_AF(QuicAddrFamily),
ServerLocalAddr.GetPort()));
do {
if (Client.GetIsConnected()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support reusing a connection handle.

Client.Shutdown(QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, QUIC_TEST_NO_ERROR);
if (!Client.WaitForShutdownComplete()) {
return;
}
}
if (Server->GetIsConnected()) {
Server->Shutdown(QUIC_CONNECTION_SHUTDOWN_FLAG_NONE, QUIC_TEST_NO_ERROR);
if (!Server->WaitForShutdownComplete()) {
return;
}
}

if (AsyncConfiguration || AsyncTicketValidation) {
if (!CxPlatEventWaitWithTimeout(ServerAcceptCtx.NewConnectionReady, TestWaitTimeout)) {
TEST_FAILURE("Timed out waiting for server accept.");
} else if (Server == nullptr) {
TEST_FAILURE("Failed to accept server connection.");
} else {
if (AsyncConfiguration) {
if (AsyncConfiguration == QUIC_TEST_ASYNC_CONFIG_DELAYED) {
TEST_QUIC_SUCCEEDED(
Client.Start(
ClientConfiguration,
QuicAddrFamily,
QUIC_LOCALHOST_FOR_AF(QuicAddrFamily),
ServerLocalAddr.GetPort()));

if (AsyncConfiguration || AsyncTicketValidation) {
if (!CxPlatEventWaitWithTimeout(ServerAcceptCtx.NewConnectionReady, TestWaitTimeout)) {
TEST_FAILURE("Timed out waiting for server accept.");
} else if (Server == nullptr) {
TEST_FAILURE("Failed to accept server connection.");
} else {
if (AsyncConfiguration) {
if (AsyncConfiguration == QUIC_TEST_ASYNC_CONFIG_DELAYED) {
CxPlatSleep(1000);
}
TEST_QUIC_SUCCEEDED(
Server->SetConfiguration(ServerConfiguration));
}
if (AsyncTicketValidation) {
CxPlatSleep(1000);
TEST_QUIC_SUCCEEDED(Server->SetCustomTicketValidationResult(SessionResumption == QUIC_TEST_RESUMPTION_ENABLED_ASYNC));
}
TEST_QUIC_SUCCEEDED(
Server->SetConfiguration(ServerConfiguration));
}
if (AsyncTicketValidation) {
CxPlatSleep(1000);
TEST_QUIC_SUCCEEDED(Server->SetCustomTicketValidationResult(SessionResumption == QUIC_TEST_RESUMPTION_ENABLED_ASYNC));
}
}
}

if (!Client.WaitForConnectionComplete()) {
return;
}
TEST_TRUE(Client.GetIsConnected());
if (!Client.WaitForConnectionComplete()) {
return;
}

TEST_NOT_EQUAL(nullptr, Server);
if (!Server->WaitForConnectionComplete()) {
return;
}
TEST_NOT_EQUAL(nullptr, Server);
if (!Server->WaitForConnectionComplete()) {
return;
}
} while (Server->GetConnectionTimeout() || Client.GetConnectionTimeout());
TEST_TRUE(Client.GetIsConnected());
TEST_TRUE(Server->GetIsConnected());

TEST_EQUAL(
Expand Down
1 change: 1 addition & 0 deletions src/test/lib/TestConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ TestConnection::HandleConnectionEvent(
QuicTraceLogInfo(
TestIgnoreConnectionTimeout,
"[test] Ignoring timeout unexpected status because of random loss");
ConnectionTimeout = true;
} else {
TEST_FAILURE(
"Unexpected transport Close Error, expected=0x%x, actual=0x%x",
Expand Down
2 changes: 2 additions & 0 deletions src/test/lib/TestConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TestConnection
bool HasRandomLoss : 1;
bool AsyncCustomValidation : 1;
bool CustomValidationResultSet : 1;
bool ConnectionTimeout : 1;

bool ExpectedResumed : 1;
QUIC_STATUS ExpectedCustomTicketValidationResult;
Expand Down Expand Up @@ -193,6 +194,7 @@ class TestConnection
bool GetTransportClosed() const { return TransportClosed; }
bool GetIsShutdown() const { return IsShutdown; }
bool GetShutdownTimedOut() const { return ShutdownTimedOut; }
bool GetConnectionTimeout() const { return ConnectionTimeout; }

bool GetExpectedResumed() const { return ExpectedResumed; };
void SetExpectedResumed(bool Value) { ExpectedResumed = Value; }
Expand Down
Loading