Root background loops at context.Background() (closes #97) (#100)
All checks were successful
check / check (push) Successful in 5s
All checks were successful
check / check (push) Successful in 5s
The delivery engine worker pool and the retention reaper both rooted their goroutines in the fx OnStart hook context, which fx cancels 15s into startup. Both now use context.WithCancel(context.Background()), bounded by OnStop.
This commit was merged in pull request #100.
This commit is contained in:
@@ -476,7 +476,7 @@ func TestWorkerLifecycle_StartStop(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
s := newISetup(t)
|
||||
s.Engine.ExportStart(context.Background())
|
||||
s.Engine.ExportStart()
|
||||
|
||||
event := iSeedEvent(
|
||||
t, s.WebhookDB, s.WebhookID,
|
||||
@@ -499,21 +499,17 @@ func TestWorkerLifecycle_StartStop(t *testing.T) {
|
||||
|
||||
s.Engine.Notify([]delivery.Task{task})
|
||||
|
||||
iWaitForStatus(
|
||||
t, s.WebhookDB, d.ID,
|
||||
database.DeliveryStatusDelivered,
|
||||
)
|
||||
iWaitForDelivered(t, s.WebhookDB, d.ID)
|
||||
|
||||
s.Engine.ExportStop()
|
||||
}
|
||||
|
||||
// iWaitForStatus polls until the delivery reaches the
|
||||
// expected status.
|
||||
func iWaitForStatus(
|
||||
// iWaitForDelivered polls until the delivery reaches the
|
||||
// delivered status.
|
||||
func iWaitForDelivered(
|
||||
t *testing.T,
|
||||
db *gorm.DB,
|
||||
deliveryID string,
|
||||
expected database.DeliveryStatus,
|
||||
) {
|
||||
t.Helper()
|
||||
|
||||
@@ -527,7 +523,7 @@ func iWaitForStatus(
|
||||
return false
|
||||
}
|
||||
|
||||
return d.Status == expected
|
||||
return d.Status == database.DeliveryStatusDelivered
|
||||
}, 5*time.Second, 50*time.Millisecond)
|
||||
}
|
||||
|
||||
@@ -558,7 +554,7 @@ func TestWorkerLifecycle_ProcessesRetryChannel(
|
||||
database.DeliveryStatusRetrying,
|
||||
)
|
||||
|
||||
s.Engine.ExportStart(context.Background())
|
||||
s.Engine.ExportStart()
|
||||
|
||||
bodyStr := event.Body
|
||||
cfg := iHTTPConfig(ts.URL)
|
||||
@@ -569,10 +565,7 @@ func TestWorkerLifecycle_ProcessesRetryChannel(
|
||||
|
||||
s.Engine.ExportRetryCh() <- task
|
||||
|
||||
iWaitForStatus(
|
||||
t, s.WebhookDB, d.ID,
|
||||
database.DeliveryStatusDelivered,
|
||||
)
|
||||
iWaitForDelivered(t, s.WebhookDB, d.ID)
|
||||
|
||||
s.Engine.ExportStop()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user