end-to-end controller tests.

This commit is contained in:
Dmitry Sergeev
2026-09-02 00:06:02 +03:00
parent a0e46a7bb5
commit f3f53fc7ad
3 changed files with 215 additions and 0 deletions
@@ -344,6 +344,38 @@ func TestSessionControllerCancellationStopsAndJoinsRuntime(t *testing.T) {
}
}
func TestSessionControllerStopAllWhileSessionIsActive(t *testing.T) {
events := make(chan controllerEvent, 32)
controller := newRecordingController(t, events)
initial := validCommandSession()
initial.SyncRequested = false
commands := make(chan SessionCommand)
done := make(chan error, 1)
go func() { done <- controller.Run(context.Background(), initial, commands) }()
receiveIndependentStarts(t, events)
commands <- SessionCommand{Kind: CommandStopAll}
stopped := map[Unit]bool{}
for len(stopped) < 2 {
event := receiveControllerEvent(t, events)
if event.action != "stop" || (event.unit != UnitVideo && event.unit != UnitAudio) {
t.Fatalf("unexpected stop event: %+v", event)
}
stopped[event.unit] = true
}
snapshot := waitControllerSnapshot(t, controller, func(snapshot SessionSnapshot) bool {
return snapshot.Plan.Topology == TopologyIdle
})
if snapshot.Desired.Video.Active || snapshot.Desired.Audio.Active {
t.Fatalf("stopped desired session = %#v", snapshot.Desired)
}
close(commands)
if err := <-done; err != nil {
t.Fatalf("Run() error = %v", err)
}
}
func TestSessionControllerSnapshotTracksDesiredPlanAndGeneration(t *testing.T) {
events := make(chan controllerEvent, 64)
controller := newRecordingController(t, events)