mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
feat: improve logging for speedtest connections
part of #7963 improve connection logging for speedtest connections
This commit is contained in:
+10
-1
@@ -895,6 +895,10 @@ func (a *agent) createTailnet(ctx context.Context, agentID uuid.UUID, derpMap *t
|
||||
}
|
||||
break
|
||||
}
|
||||
clog := a.logger.Named("speedtest").With(
|
||||
slog.F("remote", conn.RemoteAddr().String()),
|
||||
slog.F("local", conn.LocalAddr().String()))
|
||||
clog.Info(ctx, "accepted conn")
|
||||
wg.Add(1)
|
||||
closed := make(chan struct{})
|
||||
go func() {
|
||||
@@ -907,7 +911,12 @@ func (a *agent) createTailnet(ctx context.Context, agentID uuid.UUID, derpMap *t
|
||||
}()
|
||||
go func() {
|
||||
defer close(closed)
|
||||
_ = speedtest.ServeConn(conn)
|
||||
sErr := speedtest.ServeConn(conn)
|
||||
if sErr != nil {
|
||||
clog.Error(ctx, "test ended with error", slog.Error(sErr))
|
||||
return
|
||||
}
|
||||
clog.Info(ctx, "test ended")
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
+4
-1
@@ -1850,13 +1850,16 @@ func TestAgent_UpdatedDERP(t *testing.T) {
|
||||
func TestAgent_Speedtest(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Skip("This test is relatively flakey because of Tailscale's speedtest code...")
|
||||
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancel()
|
||||
derpMap, _ := tailnettest.RunDERPAndSTUN(t)
|
||||
//nolint:dogsled
|
||||
conn, _, _, _, _ := setupAgent(t, agentsdk.Manifest{
|
||||
DERPMap: derpMap,
|
||||
}, 0)
|
||||
}, 0, func(client *agenttest.Client, options *agent.Options) {
|
||||
options.Logger = logger.Named("agent")
|
||||
})
|
||||
defer conn.Close()
|
||||
res, err := conn.Speedtest(ctx, speedtest.Upload, 250*time.Millisecond)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user