(t *testing.T)
| 354 | } |
| 355 | |
| 356 | func TestBasicLifecycler_HeartbeatWhileRunning(t *testing.T) { |
| 357 | ctx := context.Background() |
| 358 | cfg := prepareBasicLifecyclerConfig() |
| 359 | cfg.HeartbeatPeriod = 10 * time.Millisecond |
| 360 | |
| 361 | lifecycler, _, store, err := prepareBasicLifecycler(t, cfg) |
| 362 | require.NoError(t, err) |
| 363 | defer services.StopAndAwaitTerminated(ctx, lifecycler) //nolint:errcheck |
| 364 | require.NoError(t, services.StartAndAwaitRunning(ctx, lifecycler)) |
| 365 | |
| 366 | // Get the initial timestamp so that we can then assert on the timestamp updated. |
| 367 | desc, _ := getInstanceFromStore(t, store, testInstanceID) |
| 368 | initialTimestamp := desc.GetTimestamp() |
| 369 | |
| 370 | assert.Eventually(t, func() bool { |
| 371 | desc, _ := getInstanceFromStore(t, store, testInstanceID) |
| 372 | return desc.GetTimestamp() > initialTimestamp |
| 373 | }, 2*time.Second, 10*time.Millisecond, "expected timestamp to be updated") |
| 374 | |
| 375 | assert.Greater(t, testutil.ToFloat64(lifecycler.metrics.heartbeats), float64(0)) |
| 376 | } |
| 377 | |
| 378 | func TestBasicLifecycler_HeartbeatWhileStopping(t *testing.T) { |
| 379 | ctx := context.Background() |
nothing calls this directly
no test coverage detected