Skip to content

Commit d703e2d

Browse files
committed
Fix replica key for tests
1 parent ae956fb commit d703e2d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

coderd/coderdtest/coderdtest.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ import (
3737
"golang.org/x/xerrors"
3838
"google.golang.org/api/idtoken"
3939
"google.golang.org/api/option"
40+
"tailscale.com/derp"
4041
"tailscale.com/net/stun/stuntest"
4142
"tailscale.com/tailcfg"
43+
"tailscale.com/types/key"
4244
"tailscale.com/types/nettype"
4345

4446
"cdr.dev/slog"
@@ -59,6 +61,7 @@ import (
5961
"github.com/coder/coder/provisionerd"
6062
"github.com/coder/coder/provisionersdk"
6163
"github.com/coder/coder/provisionersdk/proto"
64+
"github.com/coder/coder/tailnet"
6265
"github.com/coder/coder/testutil"
6366
)
6467

@@ -184,6 +187,9 @@ func NewOptions(t *testing.T, options *Options) (*httptest.Server, context.Cance
184187
stunAddr, stunCleanup := stuntest.ServeWithPacketListener(t, nettype.Std{})
185188
t.Cleanup(stunCleanup)
186189

190+
derpServer := derp.NewServer(key.NewNode(), tailnet.Logger(slogtest.Make(t, nil).Named("derp")))
191+
derpServer.SetMeshKey("test-key")
192+
187193
// match default with cli default
188194
if options.SSHKeygenAlgorithm == "" {
189195
options.SSHKeygenAlgorithm = gitsshkey.AlgorithmEd25519
@@ -208,6 +214,7 @@ func NewOptions(t *testing.T, options *Options) (*httptest.Server, context.Cance
208214
OIDCConfig: options.OIDCConfig,
209215
GoogleTokenValidator: options.GoogleTokenValidator,
210216
SSHKeygenAlgorithm: options.SSHKeygenAlgorithm,
217+
DERPServer: derpServer,
211218
APIRateLimit: options.APIRateLimit,
212219
Authorizer: options.Authorizer,
213220
Telemetry: telemetry.NewNoop(),

enterprise/coderd/replicas_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestReplicas(t *testing.T) {
7979
})
8080
require.NoError(t, err)
8181
require.Eventually(t, func() bool {
82-
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.IntervalSlow)
82+
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitShort)
8383
defer cancelFunc()
8484
_, err = conn.Ping(ctx)
8585
return err == nil
@@ -122,7 +122,7 @@ func TestReplicas(t *testing.T) {
122122
})
123123
require.NoError(t, err)
124124
require.Eventually(t, func() bool {
125-
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.IntervalMedium)
125+
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.IntervalSlow)
126126
defer cancelFunc()
127127
_, err = conn.Ping(ctx)
128128
return err == nil

0 commit comments

Comments
 (0)