package plugin import ( "sync/atomic" "testing" ) // TestRetiredInstanceExitDoesNotReleaseHeldInput checks that a zero-downtime // reload does not make the embedder lift input the replacement process just // pressed: only the exit of the live instance, or a stopped supervisor, reports // that the plugin can no longer release what it holds. func TestRetiredInstanceExitDoesNotReleaseHeldInput(t *testing.T) { var exits atomic.Int32 sup := NewSidecarSupervisor(SidecarOptions{ PluginID: "acme.tool", OnExit: func() { exits.Add(1) }, }) live := &sidecarInstance{} sup.cur = live sup.onInstanceExit(live, nil) if got := exits.Load(); got != 1 { t.Fatalf("the live instance exiting reported %d times, want 1", got) } replacement := &sidecarInstance{} sup.cur = replacement sup.onInstanceExit(live, nil) if got := exits.Load(); got != 1 { t.Fatalf("a retired instance reported %d times, want the count to stay at 1", got) } }