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

Function TestRun

scaletest/workspaceupdates/run_test.go:24–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestRun(t *testing.T) {
25 t.Parallel()
26
27 ctx := testutil.Context(t, testutil.WaitSuperLong)
28
29 client := coderdtest.New(t, &coderdtest.Options{
30 IncludeProvisionerDaemon: true,
31 })
32 user := coderdtest.CreateFirstUser(t, client)
33
34 numUsers := 2
35 userWorkspaces := 2
36 numWorkspaces := numUsers * userWorkspaces
37
38 authToken := uuid.NewString()
39 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
40 Parse: echo.ParseComplete,
41 ProvisionPlan: echo.PlanComplete,
42 ProvisionGraph: []*proto.Response{
43 {
44 Type: &proto.Response_Graph{
45 Graph: &proto.GraphComplete{
46 Resources: []*proto.Resource{
47 {
48 Name: "example",
49 Type: "aws_instance",
50 Agents: []*proto.Agent{
51 {
52 Id: uuid.NewString(),
53 Name: "agent",
54 Auth: &proto.Agent_Token{
55 Token: authToken,
56 },
57 Apps: []*proto.App{},
58 },
59 },
60 },
61 },
62 },
63 },
64 },
65 },
66 })
67
68 template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
69 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
70
71 barrier := new(sync.WaitGroup)
72 barrier.Add(numUsers)
73 metrics := workspaceupdates.NewMetrics(prometheus.NewRegistry())
74
75 eg, runCtx := errgroup.WithContext(ctx)
76
77 runners := make([]*workspaceupdates.Runner, 0, numUsers)
78 for i := range numUsers {
79 cfg := workspaceupdates.Config{
80 User: createusers.Config{
81 OrganizationID: user.OrganizationID,

Callers

nothing calls this directly

Calls 15

ValidateMethod · 0.95
RunMethod · 0.95
CleanupMethod · 0.95
GetMetricsMethod · 0.95
ContextFunction · 0.92
NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
NewMetricsFunction · 0.92
NewRunnerFunction · 0.92

Tested by

no test coverage detected