(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func 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 | } |
nothing calls this directly
no test coverage detected