Skip to content

Commit 8f9f0cd

Browse files
authored
chore: avoid DNS lookups for DERP in tests (#19385)
Closes coder/internal#886
1 parent 93279df commit 8f9f0cd

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
471471

472472
serverURL, err := url.Parse(srv.URL)
473473
require.NoError(t, err)
474-
serverURL.Host = fmt.Sprintf("localhost:%d", tcpAddr.Port)
474+
serverURL.Host = fmt.Sprintf("127.0.0.1:%d", tcpAddr.Port)
475475

476476
derpPort, err := strconv.Atoi(serverURL.Port())
477477
require.NoError(t, err)

enterprise/coderd/coderdenttest/coderdenttest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func NewWithAPI(t *testing.T, options *Options) (
105105
AuditLogging: options.AuditLogging,
106106
BrowserOnly: options.BrowserOnly,
107107
SCIMAPIKey: options.SCIMAPIKey,
108-
DERPServerRelayAddress: oop.AccessURL.String(),
108+
DERPServerRelayAddress: serverURL.String(),
109109
DERPServerRegionID: oop.BaseDERPMap.RegionIDs()[0],
110110
ReplicaSyncUpdateInterval: options.ReplicaSyncUpdateInterval,
111111
ReplicaErrorGracePeriod: options.ReplicaErrorGracePeriod,

enterprise/coderd/coderdenttest/proxytest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func NewWorkspaceProxyReplica(t *testing.T, coderdAPI *coderd.API, owner *coders
109109
serverURL, err := url.Parse(srv.URL)
110110
require.NoError(t, err)
111111

112-
serverURL.Host = fmt.Sprintf("localhost:%d", tcpAddr.Port)
112+
serverURL.Host = fmt.Sprintf("127.0.0.1:%d", tcpAddr.Port)
113113

114114
accessURL := options.ProxyURL
115115
if accessURL == nil {

enterprise/wsproxy/wsproxy_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,8 @@ func TestDERPOnly(t *testing.T) {
9494
func TestDERP(t *testing.T) {
9595
t.Parallel()
9696

97-
deploymentValues := coderdtest.DeploymentValues(t)
98-
deploymentValues.Experiments = []string{
99-
"*",
100-
}
101-
10297
client, closer, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
10398
Options: &coderdtest.Options{
104-
DeploymentValues: deploymentValues,
10599
AppHostname: "*.primary.test.coder.com",
106100
IncludeProvisionerDaemon: true,
107101
RealIPConfig: &httpmw.RealIPConfig{
@@ -146,7 +140,7 @@ func TestDERP(t *testing.T) {
146140
})
147141
require.NoError(t, err)
148142

149-
// Wait for both running proxies to become healthy.
143+
// Wait for all three running proxies to become healthy.
150144
require.Eventually(t, func() bool {
151145
err := api.ProxyHealth.ForceUpdate(ctx)
152146
if !assert.NoError(t, err) {
@@ -207,7 +201,7 @@ resourceLoop:
207201
require.NoError(t, err)
208202

209203
// There should be three DERP regions in the map: the primary, and each
210-
// of the two running proxies. Also the STUN-only regions.
204+
// of the two DERP-enabled running proxies. Also the STUN-only regions.
211205
require.NotNil(t, connInfo.DERPMap)
212206
require.Len(t, connInfo.DERPMap.Regions, 3+len(api.DeploymentValues.DERP.Server.STUNAddresses.Value()))
213207

@@ -290,7 +284,7 @@ resourceLoop:
290284

291285
t.Run(r.RegionName, func(t *testing.T) {
292286
t.Parallel()
293-
ctx := testutil.Context(t, testutil.WaitShort)
287+
ctx := testutil.Context(t, testutil.WaitLong)
294288

295289
derpMap := &tailcfg.DERPMap{
296290
Regions: map[int]*tailcfg.DERPRegion{

0 commit comments

Comments
 (0)