Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(vpn): send ping results over tunnel#18200

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 13 commits intomainfromethan/send-ping-results
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
review
  • Loading branch information
@ethanndickson
ethanndickson committedJun 3, 2025
commit176a375365de2a8b0735fc1bd64648cb26abbf10
35 changes: 35 additions & 0 deletionstailnet/derpmap_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
"tailscale.com/ipn/ipnstate"
"tailscale.com/tailcfg"

"github.com/coder/coder/v2/tailnet"
Expand DownExpand Up@@ -236,3 +237,37 @@ func TestExtractDERPLatency(t *testing.T) {
require.Empty(t, latencyMs)
})
}

func TestExtractPreferredDERPName(t *testing.T) {
t.Parallel()
derpMap := &tailcfg.DERPMap{
Regions: map[int]*tailcfg.DERPRegion{
1: {RegionName: "New York"},
2: {RegionName: "London"},
},
}

t.Run("UsesPingRegion", func(t *testing.T) {
t.Parallel()
pingResult := &ipnstate.PingResult{DERPRegionID: 2}
node := &tailnet.Node{PreferredDERP: 1}
result := tailnet.ExtractPreferredDERPName(pingResult, node, derpMap)
require.Equal(t, "London", result)
})

t.Run("UsesNodePreferred", func(t *testing.T) {
t.Parallel()
pingResult := &ipnstate.PingResult{DERPRegionID: 0}
node := &tailnet.Node{PreferredDERP: 1}
result := tailnet.ExtractPreferredDERPName(pingResult, node, derpMap)
require.Equal(t, "New York", result)
})

t.Run("UnknownRegion", func(t *testing.T) {
t.Parallel()
pingResult := &ipnstate.PingResult{DERPRegionID: 99}
node := &tailnet.Node{PreferredDERP: 1}
result := tailnet.ExtractPreferredDERPName(pingResult, node, derpMap)
require.Equal(t, "Unnamed 99", result)
})
}
8 changes: 4 additions & 4 deletionsvpn/tunnel_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -461,7 +461,7 @@ func TestTunnel_sendAgentUpdate(t *testing.T) {
}

// Latency is gathered in the background, so it'll eventually be sent
require.Eventually(t, func() bool {
testutil.Eventually(ctx,t, func(ctx context.Context) bool {
mClock.AdvanceNext()
req = testutil.TryReceive(ctx, t, mgr.requests)
if len(req.msg.GetPeerUpdate().UpsertedAgents) == 0 {
Expand All@@ -474,7 +474,7 @@ func TestTunnel_sendAgentUpdate(t *testing.T) {
return false
}
return req.msg.GetPeerUpdate().UpsertedAgents[0].LastPing.PreferredDerp == "Coder Region"
}, testutil.WaitShort, testutil.IntervalFast)
}, testutil.IntervalFast)

// Upsert a new agent
err = tun.Update(tailnet.WorkspaceUpdate{
Expand DownExpand Up@@ -538,7 +538,7 @@ func TestTunnel_sendAgentUpdate(t *testing.T) {
require.Equal(t, hsTime, req.msg.GetPeerUpdate().UpsertedAgents[0].LastHandshake.AsTime())

// Eventually the second agent's latency is set
require.Eventually(t, func() bool {
testutil.Eventually(ctx,t, func(ctx context.Context) bool {
mClock.AdvanceNext()
req = testutil.TryReceive(ctx, t, mgr.requests)
if len(req.msg.GetPeerUpdate().UpsertedAgents) == 0 {
Expand All@@ -551,7 +551,7 @@ func TestTunnel_sendAgentUpdate(t *testing.T) {
return false
}
return req.msg.GetPeerUpdate().UpsertedAgents[0].LastPing.PreferredDerp == "Coder Region"
}, testutil.WaitShort, testutil.IntervalFast)
}, testutil.IntervalFast)
}

func TestTunnel_sendAgentUpdateReconnect(t *testing.T) {
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp