Expose supervisor shutdown broadcast for tests
Adds AgentRunSupervisor.ShutdownBroadcast() returning the handler's shutdown channel so the StopAndResume integration test can wait for graceful-shutdown propagation deterministically instead of sleeping for a fixed duration. The method is explicitly documented as test-only and not part of the operational contract. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -273,9 +273,16 @@ func TestAgentRunSupervisor_StopAndResume(t *testing.T) {
|
||||
// agent's stop channel.
|
||||
cancel1()
|
||||
|
||||
// Give the AfterFunc goroutine a moment to close the broadcast and
|
||||
// propagate into the per-run stopCh before the tool unblocks.
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
// Wait for the shutdown broadcast to be observed (the AfterFunc
|
||||
// goroutine closes it) before releasing the tool. This is
|
||||
// deterministic: no wall-clock sleep. The per-run forwarder
|
||||
// goroutine observes the same close synchronously and closes the
|
||||
// agent stop channel.
|
||||
select {
|
||||
case <-supervisor.ShutdownBroadcastForTests():
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("timed out waiting for supervisor shutdown broadcast")
|
||||
}
|
||||
|
||||
// Now release the tool. When the coreLoop resumes control at the
|
||||
// next turn boundary it observes the closed stop channel, saves
|
||||
|
||||
Reference in New Issue
Block a user