Skip to content

Commit

Permalink
server: increase test http client timeouts under race
Browse files Browse the repository at this point in the history
Previously, we'd use a 10s timeout on HTTP clients for all test runs.
This change modifies this to be `30s` under race.

Resolves cockroachdb#124395
Resolves cockroachdb#122892

Release note: None
  • Loading branch information
dhartunian committed May 23, 2024
1 parent 677a373 commit 8c99abc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/server/testserver_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"net/http/cookiejar"
"net/url"
"sync"
"time"

"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/security/username"
Expand All @@ -26,6 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
)

Expand Down Expand Up @@ -88,6 +90,9 @@ func (ts *httpTestServer) GetUnauthenticatedHTTPClient() (http.Client, error) {
RoundTripper: client.Transport,
tenantName: ts.t.tenantName,
}
if util.RaceEnabled {
client.Timeout = 30 * time.Second
}
return client, nil
}

Expand All @@ -96,6 +101,9 @@ func (ts *httpTestServer) GetAdminHTTPClient() (http.Client, error) {
httpClient, _, err := ts.GetAuthenticatedHTTPClientAndCookie(
apiconstants.TestingUserName(), true, serverutils.SingleTenantSession,
)
if util.RaceEnabled {
httpClient.Timeout = 30 * time.Second
}
return httpClient, err
}

Expand All @@ -108,6 +116,9 @@ func (ts *httpTestServer) GetAuthenticatedHTTPClient(
authUser = apiconstants.TestingUserNameNoAdmin()
}
httpClient, _, err := ts.GetAuthenticatedHTTPClientAndCookie(authUser, isAdmin, session)
if util.RaceEnabled {
httpClient.Timeout = 30 * time.Second
}
return httpClient, err
}

Expand Down

0 comments on commit 8c99abc

Please sign in to comment.