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

Function TestRunner_Run_BuildFailed

scaletest/taskstatus/run_internal_test.go:513–597  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

511}
512
513func TestRunner_Run_BuildFailed(t *testing.T) {
514 t.Parallel()
515
516 testCtx := testutil.Context(t, testutil.WaitShort)
517 runCtx, cancel := context.WithCancel(testCtx)
518 defer cancel()
519
520 mClock := quartz.NewMock(t)
521 fClient := newFakeClient(t)
522 fUpdater := newFakeAppStatusUpdater(t)
523 templateID := uuid.UUID{5, 6, 7, 8}
524 workspaceName := "test-workspace"
525 appSlug := "test-app"
526
527 reg := prometheus.NewRegistry()
528 metrics := NewMetrics(reg, "test")
529
530 connectedWaitGroup := &sync.WaitGroup{}
531 connectedWaitGroup.Add(1)
532 startReporting := make(chan struct{})
533
534 cfg := Config{
535 TemplateID: templateID,
536 WorkspaceName: workspaceName,
537 AppSlug: appSlug,
538 ConnectedWaitGroup: connectedWaitGroup,
539 StartReporting: startReporting,
540 ReportStatusPeriod: 10 * time.Second,
541 ReportStatusDuration: 35 * time.Second,
542 Metrics: metrics,
543 MetricLabelValues: []string{"test"},
544 }
545 runner := &Runner{
546 client: fClient,
547 updater: fUpdater,
548 cfg: cfg,
549 clock: mClock,
550 randFloat64: func() float64 { return 0.5 }, // not random in tests
551 reportTimes: make(map[int]time.Time),
552 }
553
554 buildTickerTrap := mClock.Trap().TickerFunc("createExternalWorkspace")
555 defer buildTickerTrap.Close()
556 // Run the runner in a goroutine
557 runErr := make(chan error, 1)
558 go func() {
559 runErr <- runner.Run(runCtx, "test-runner", testutil.NewTestLogWriter(t))
560 }()
561
562 // complete the build
563 buildTickerTrap.MustWait(testCtx).MustRelease(testCtx)
564 w := mClock.Advance(30 * time.Second)
565 testutil.RequireSend(testCtx, t, fClient.workspaceByOwnerAndNameStatus, codersdk.ProvisionerJobFailed)
566 w.MustWait(testCtx)
567
568 connectedWaitGroup.Wait()
569
570 // Wait for the runner to complete

Callers

nothing calls this directly

Calls 15

RunMethod · 0.95
ContextFunction · 0.92
NewTestLogWriterFunction · 0.92
RequireSendFunction · 0.92
RequireReceiveFunction · 0.92
newFakeAppStatusUpdaterFunction · 0.85
newFakeClientFunction · 0.70
NewMetricsFunction · 0.70
AddMethod · 0.65
CloseMethod · 0.65
WaitMethod · 0.65
GetNameMethod · 0.45

Tested by

no test coverage detected