end-to-end controller tests.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user