mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: change servertailnet to register the DERP dialer before setting DERP map (#12137)
I noticed a possible race where tailnet.Conn can try to dial the embedded region before we've set our custom dialer that send the DERP in-memory. This closes that race and adds a test case for servertailnet with no STUN and an embedded relay
This commit is contained in:
@ -50,6 +50,24 @@ func TestServerTailnet_AgentConn_OK(t *testing.T) {
|
||||
assert.True(t, conn.AwaitReachable(ctx))
|
||||
}
|
||||
|
||||
func TestServerTailnet_AgentConn_NoSTUN(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
|
||||
defer cancel()
|
||||
|
||||
// Connect through the ServerTailnet
|
||||
agents, serverTailnet := setupServerTailnetAgent(t, 1,
|
||||
tailnettest.DisableSTUN, tailnettest.DERPIsEmbedded)
|
||||
a := agents[0]
|
||||
|
||||
conn, release, err := serverTailnet.AgentConn(ctx, a.id)
|
||||
require.NoError(t, err)
|
||||
defer release()
|
||||
|
||||
assert.True(t, conn.AwaitReachable(ctx))
|
||||
}
|
||||
|
||||
func TestServerTailnet_ReverseProxy(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@ -311,9 +329,9 @@ type agentWithID struct {
|
||||
agent.Agent
|
||||
}
|
||||
|
||||
func setupServerTailnetAgent(t *testing.T, agentNum int) ([]agentWithID, *coderd.ServerTailnet) {
|
||||
func setupServerTailnetAgent(t *testing.T, agentNum int, opts ...tailnettest.DERPAndStunOption) ([]agentWithID, *coderd.ServerTailnet) {
|
||||
logger := slogtest.Make(t, nil).Leveled(slog.LevelDebug)
|
||||
derpMap, derpServer := tailnettest.RunDERPAndSTUN(t)
|
||||
derpMap, derpServer := tailnettest.RunDERPAndSTUN(t, opts...)
|
||||
|
||||
coord := tailnet.NewCoordinator(logger)
|
||||
t.Cleanup(func() {
|
||||
|
Reference in New Issue
Block a user