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

Function TestRunner_RunMissedUpdate

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

Source from the content-addressed store, hash-verified

283}
284
285func TestRunner_RunMissedUpdate(t *testing.T) {
286 t.Parallel()
287
288 testCtx := testutil.Context(t, testutil.WaitShort)
289 runCtx, cancel := context.WithCancel(testCtx)
290 defer cancel()
291
292 mClock := quartz.NewMock(t)
293 fClient := newFakeClient(t)
294 fUpdater := newFakeAppStatusUpdater(t)
295 templateID := uuid.UUID{5, 6, 7, 8}
296 workspaceName := "test-workspace"
297 appSlug := "test-app"
298
299 reg := prometheus.NewRegistry()
300 metrics := NewMetrics(reg, "test")
301
302 connectedWaitGroup := &sync.WaitGroup{}
303 connectedWaitGroup.Add(1)
304 startReporting := make(chan struct{})
305
306 cfg := Config{
307 TemplateID: templateID,
308 WorkspaceName: workspaceName,
309 AppSlug: appSlug,
310 ConnectedWaitGroup: connectedWaitGroup,
311 StartReporting: startReporting,
312 ReportStatusPeriod: 10 * time.Second,
313 ReportStatusDuration: 35 * time.Second,
314 Metrics: metrics,
315 MetricLabelValues: []string{"test"},
316 }
317 runner := &Runner{
318 client: fClient,
319 updater: fUpdater,
320 cfg: cfg,
321 clock: mClock,
322 randFloat64: func() float64 { return 0.5 }, // not random in tests
323 reportTimes: make(map[int]time.Time),
324 }
325
326 tickerTrap := mClock.Trap().NewTimer("reportTaskStatus")
327 defer tickerTrap.Close()
328 sinceTrap := mClock.Trap().Since("watchWorkspaceUpdates")
329 defer sinceTrap.Close()
330 buildTickerTrap := mClock.Trap().TickerFunc("createExternalWorkspace")
331 defer buildTickerTrap.Close()
332
333 // Run the runner in a goroutine
334 runErr := make(chan error, 1)
335 go func() {
336 runErr <- runner.Run(runCtx, "test-runner", testutil.NewTestLogWriter(t))
337 }()
338
339 // complete the build
340 buildTickerTrap.MustWait(testCtx).MustRelease(testCtx)
341 w := mClock.Advance(30 * time.Second)
342 testutil.RequireSend(testCtx, t, fClient.workspaceByOwnerAndNameStatus, codersdk.ProvisionerJobSucceeded)

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
DurationMethod · 0.80
newFakeClientFunction · 0.70
NewMetricsFunction · 0.70
AddMethod · 0.65
CloseMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected