MCPcopy Create free account
hub / github.com/coder/coder / setupRunnerTest

Function setupRunnerTest

scaletest/reconnectingpty/run_test.go:248–293  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

246}
247
248func setupRunnerTest(t *testing.T) (client *codersdk.Client, agentID uuid.UUID) {
249 t.Helper()
250
251 client, _, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
252 IncludeProvisionerDaemon: true,
253 })
254 user := coderdtest.CreateFirstUser(t, client)
255
256 authToken := uuid.NewString()
257 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
258 Parse: echo.ParseComplete,
259 ProvisionPlan: echo.PlanComplete,
260 ProvisionGraph: []*proto.Response{{
261 Type: &proto.Response_Graph{
262 Graph: &proto.GraphComplete{
263 Resources: []*proto.Resource{{
264 Name: "example",
265 Type: "aws_instance",
266 Agents: []*proto.Agent{{
267 Id: uuid.NewString(),
268 Name: "agent",
269 Auth: &proto.Agent_Token{
270 Token: authToken,
271 },
272 Apps: []*proto.App{},
273 }},
274 }},
275 },
276 },
277 }},
278 })
279
280 template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
281 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
282
283 workspace := coderdtest.CreateWorkspace(t, client, template.ID)
284 coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
285
286 _ = agenttest.New(t, client.URL, authToken)
287 resources := coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
288 require.Eventually(t, func() bool {
289 t.Log("agent id", resources[0].Agents[0].ID)
290 return (*api.TailnetCoordinator.Load()).Node(resources[0].Agents[0].ID) != nil
291 }, testutil.WaitLong, testutil.IntervalMedium, "agent never connected")
292 return client, resources[0].Agents[0].ID
293}

Callers 1

Test_RunnerFunction · 0.70

Calls 13

NewWithAPIFunction · 0.92
CreateFirstUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92
NewFunction · 0.92
AwaitWorkspaceAgentsFunction · 0.92
LogMethod · 0.80
HelperMethod · 0.65
NodeMethod · 0.65

Tested by

no test coverage detected