feat: release v0.27 unified HTTP limits and safe request shutdown
This commit is contained in:
@@ -54,3 +54,28 @@ func TestRuntimeRetainsMonitorFaultDuringCleanup(t *testing.T) {
|
||||
}()
|
||||
r.OnClose(func() error { return nil })
|
||||
}
|
||||
|
||||
func TestFinishRetainsDependenciesAfterIncompleteHTTPDrain(t *testing.T) {
|
||||
r := NewRuntime(context.Background())
|
||||
var order []string
|
||||
r.OnStop("worker", func(context.Context) error { order = append(order, "stop"); return nil })
|
||||
r.OnDrain("worker", func(context.Context) error { order = append(order, "drain"); return nil })
|
||||
r.OnClose(func() error { t.Error("released dependency while HTTP work remains"); return nil })
|
||||
fault := errors.New("HTTP shutdown timeout")
|
||||
err := r.Finish(errors.Join(fault, ErrResourcesRetained))
|
||||
if !errors.Is(err, fault) || !errors.Is(err, ErrResourcesRetained) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(order, []string{"stop", "drain"}) {
|
||||
t.Fatal(order)
|
||||
}
|
||||
if r.WorkContext().Err() == nil {
|
||||
t.Fatal("background work was not canceled")
|
||||
}
|
||||
if err = r.Close(); !errors.Is(err, ErrResourcesRetained) {
|
||||
t.Fatal("deferred Close bypassed retention", err)
|
||||
}
|
||||
if err = r.Finish(nil); !errors.Is(err, ErrResourcesRetained) {
|
||||
t.Fatal("repeat Finish bypassed retention", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user