TestHeartbeats_Cleanup tests the cleanup loop
(t *testing.T)
| 37 | |
| 38 | // TestHeartbeats_Cleanup tests the cleanup loop |
| 39 | func TestHeartbeats_Cleanup(t *testing.T) { |
| 40 | t.Parallel() |
| 41 | |
| 42 | ctrl := gomock.NewController(t) |
| 43 | mStore := dbmock.NewMockStore(ctrl) |
| 44 | |
| 45 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) |
| 46 | defer cancel() |
| 47 | logger := testutil.Logger(t) |
| 48 | |
| 49 | mStore.EXPECT().CleanTailnetCoordinators(gomock.Any()).Times(2).Return(nil) |
| 50 | mStore.EXPECT().CleanTailnetLostPeers(gomock.Any()).Times(2).Return(nil) |
| 51 | mStore.EXPECT().CleanTailnetTunnels(gomock.Any()).Times(2).Return(nil) |
| 52 | |
| 53 | mClock := quartz.NewMock(t) |
| 54 | trap := mClock.Trap().TickerFunc("heartbeats", "cleanupLoop") |
| 55 | defer trap.Close() |
| 56 | |
| 57 | uut := &heartbeats{ |
| 58 | ctx: ctx, |
| 59 | logger: logger, |
| 60 | store: mStore, |
| 61 | clock: mClock, |
| 62 | } |
| 63 | uut.wg.Add(1) |
| 64 | go uut.cleanupLoop() |
| 65 | |
| 66 | call := trap.MustWait(ctx) |
| 67 | call.MustRelease(ctx) |
| 68 | require.Equal(t, cleanupPeriod, call.Duration) |
| 69 | mClock.Advance(cleanupPeriod).MustWait(ctx) |
| 70 | } |
| 71 | |
| 72 | // TestHeartbeats_recvBeat_resetSkew is a regression test for a bug where heartbeats from two |
| 73 | // coordinators slightly skewed from one another could result in one coordinator failing to get |
nothing calls this directly
no test coverage detected