diff --git a/cmd/mesh-controller/composed_served_integration_test.go b/cmd/mesh-controller/composed_served_integration_test.go index 41819d3d..01c1b2b9 100644 --- a/cmd/mesh-controller/composed_served_integration_test.go +++ b/cmd/mesh-controller/composed_served_integration_test.go @@ -28,6 +28,7 @@ import ( "github.com/novox/mesh-controller/internal/chain" "github.com/novox/mesh-controller/internal/identity" "github.com/novox/mesh-controller/internal/inventory" + "github.com/novox/mesh-controller/internal/link" ) // The compositions through the controller whole (novox/hq ADR 0539; the review's G1): the real store, the controller's @@ -220,6 +221,7 @@ func aServedMesh(t *testing.T) *servedMesh { } } + keepWhatServeSets(t) serving, stop := context.WithCancel(context.Background()) done := make(chan error, 1) go func() { done <- serve(serving) }() @@ -587,3 +589,18 @@ func capturedOutput(act func() error) (string, error) { w.Close() return <-done, actErr } + +// keepWhatServeSets gives back, once the served controller stopped, what serve sets for the rest of its process, which +// a controller's process exits after and the test process does not (issue 1945): the served mark in the environment, the +// hand-act log's connection, the keeper, the status and the event publishers. Registered before the controller starts, so +// it runs after the cleanup that stops it. +func keepWhatServeSets(t *testing.T) { + t.Helper() + t.Setenv(servedVar, "") + unheld, status, given, check, follow, keeper, hand := logUnheldChanges, statusFrom, givenEvents, checkEvents, + link.Calls.Follow, conditionsFrom, handActConn + t.Cleanup(func() { + logUnheldChanges, statusFrom, givenEvents, checkEvents, link.Calls.Follow, conditionsFrom, handActConn = + unheld, status, given, check, follow, keeper, hand + }) +}