mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: resolve flake test on manager (#17702)
Fixes coder/internal#544 --------- Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
This commit is contained in:
co-authored by
Mathias Fredriksson
parent
857587b35d
commit
1bb96b8528
@@ -182,6 +182,28 @@ func TestStopBeforeRun(t *testing.T) {
|
||||
}, testutil.WaitShort, testutil.IntervalFast)
|
||||
}
|
||||
|
||||
func TestRunStopRace(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// SETUP
|
||||
|
||||
// nolint:gocritic // Unit test.
|
||||
ctx := dbauthz.AsSystemRestricted(testutil.Context(t, testutil.WaitMedium))
|
||||
store, ps := dbtestutil.NewDB(t)
|
||||
logger := testutil.Logger(t)
|
||||
|
||||
// GIVEN: a standard manager
|
||||
mgr, err := notifications.NewManager(defaultNotificationsConfig(database.NotificationMethodSmtp), store, ps, defaultHelpers(), createMetrics(), logger.Named("notifications-manager"))
|
||||
require.NoError(t, err)
|
||||
|
||||
// Start Run and Stop after each other (run does "go loop()").
|
||||
// This is to catch a (now fixed) race condition where the manager
|
||||
// would be accessed/stopped while it was being created/starting up.
|
||||
mgr.Run(ctx)
|
||||
err = mgr.Stop(ctx)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
type syncInterceptor struct {
|
||||
notifications.Store
|
||||
|
||||
|
||||
Reference in New Issue
Block a user