MCPcopy Index your code
hub / github.com/coder/coder / TestSpeedtestJson

Function TestSpeedtestJson

cli/speedtest_test.go:61–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestSpeedtestJson(t *testing.T) {
62 t.Parallel()
63 t.Skip("Potentially flaky test - see https://github.com/coder/coder/issues/6321")
64 if testing.Short() {
65 t.Skip("This test takes a minimum of 5ms per a hardcoded value in Tailscale!")
66 }
67 client, workspace, agentToken := setupWorkspaceForAgent(t)
68 _ = agenttest.New(t, client.URL, agentToken)
69 coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
70
71 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
72 defer cancel()
73
74 require.Eventually(t, func() bool {
75 ws, err := client.Workspace(ctx, workspace.ID)
76 if !assert.NoError(t, err) {
77 return false
78 }
79 a := ws.LatestBuild.Resources[0].Agents[0]
80 return a.Status == codersdk.WorkspaceAgentConnected &&
81 a.LifecycleState == codersdk.WorkspaceAgentLifecycleReady
82 }, testutil.WaitLong, testutil.IntervalFast, "agent is not ready")
83
84 inv, root := clitest.New(t, "speedtest", "--output=json", workspace.Name)
85 clitest.SetupConfig(t, client, root)
86 out := bytes.NewBuffer(nil)
87 inv.Stdout = out
88 ctx, cancel = context.WithTimeout(context.Background(), testutil.WaitLong)
89 defer cancel()
90
91 inv.Logger = testutil.Logger(t).Named("speedtest")
92 cmdDone := tGo(t, func() {
93 err := inv.WithContext(ctx).Run()
94 assert.NoError(t, err)
95 })
96 <-cmdDone
97
98 var result cli.SpeedtestResult
99 require.NoError(t, json.Unmarshal(out.Bytes(), &result))
100 require.Len(t, result.Intervals, 5)
101}

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
AwaitWorkspaceAgentsFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
LoggerFunction · 0.92
tGoFunction · 0.85
SkipMethod · 0.80
WorkspaceMethod · 0.80
NamedMethod · 0.80
WithContextMethod · 0.80
setupWorkspaceForAgentFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected