| 284 | } |
| 285 | |
| 286 | func TestHeartbeat(t *testing.T) { |
| 287 | t.Parallel() |
| 288 | |
| 289 | numBeats := 3 |
| 290 | ctx := testutil.Context(t, testutil.WaitShort) |
| 291 | heartbeatChan := make(chan struct{}) |
| 292 | heartbeatFn := func(hbCtx context.Context) error { |
| 293 | t.Log("heartbeat") |
| 294 | select { |
| 295 | case <-hbCtx.Done(): |
| 296 | return hbCtx.Err() |
| 297 | case heartbeatChan <- struct{}{}: |
| 298 | return nil |
| 299 | } |
| 300 | } |
| 301 | //nolint:dogsled |
| 302 | _, _, _, _ = setup(t, false, &overrides{ |
| 303 | ctx: ctx, |
| 304 | heartbeatFn: heartbeatFn, |
| 305 | heartbeatInterval: testutil.IntervalFast, |
| 306 | }) |
| 307 | |
| 308 | for i := 0; i < numBeats; i++ { |
| 309 | testutil.TryReceive(ctx, t, heartbeatChan) |
| 310 | } |
| 311 | // goleak.VerifyTestMain ensures that the heartbeat goroutine does not leak |
| 312 | } |
| 313 | |
| 314 | func TestAcquireJob(t *testing.T) { |
| 315 | t.Parallel() |