Reduce controller polling and bound chat admission waits
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import unittest
|
||||
@@ -42,6 +43,34 @@ def music_item(state="exited"):
|
||||
|
||||
|
||||
class ProfileControllerTests(unittest.TestCase):
|
||||
def test_status_keeps_llm_when_optional_container_is_missing(self):
|
||||
payload = json.dumps([item("medium", "running")]).encode()
|
||||
with patch.object(controller, "MUSIC_WORKER", "missing-music"), \
|
||||
patch.object(controller, "docker_request", return_value=(200, payload)) as request:
|
||||
result = controller.status_snapshot()
|
||||
self.assertEqual(result["active_profile"], "medium")
|
||||
self.assertEqual(result["music_worker"], "missing")
|
||||
self.assertIn("music", result["worker_errors"])
|
||||
request.assert_called_once_with("GET", "/containers/json?all=1")
|
||||
|
||||
def test_empty_snapshot_does_not_repeat_docker_query(self):
|
||||
with patch.object(controller, "docker_request", return_value=(200, b"[]")) as request:
|
||||
result = controller.status_snapshot()
|
||||
self.assertIsNone(result["active_profile"])
|
||||
self.assertEqual(request.call_count, 1)
|
||||
|
||||
def test_video_ui_failure_does_not_hide_llm(self):
|
||||
video = {"Id": "video", "State": "running",
|
||||
"Labels": {controller.VIDEO_LABEL_KEY: "ltx2"}}
|
||||
payload = json.dumps([item("medium", "running"), video]).encode()
|
||||
with patch.object(controller, "VIDEO_WORKER", "ltx2"), \
|
||||
patch.object(controller, "docker_request", return_value=(200, payload)), \
|
||||
patch.object(controller, "cached_video_ui_state", side_effect=RuntimeError("exec failed")):
|
||||
result = controller.status_snapshot()
|
||||
self.assertEqual(result["active_profile"], "medium")
|
||||
self.assertEqual(result["video_worker"], "running")
|
||||
self.assertIn("video_ui", result["worker_errors"])
|
||||
|
||||
def test_music_start_exclusively_stops_gpu_workers(self):
|
||||
profiles = {name: item(name) for name in controller.ALLOWED}
|
||||
profiles["ultra"] = item("ultra", "running")
|
||||
@@ -99,9 +128,11 @@ class ProfileControllerTests(unittest.TestCase):
|
||||
profiles = {name: item(name) for name in controller.ALLOWED[:-1]}
|
||||
with patch.object(controller, "containers", return_value=profiles), \
|
||||
patch.object(controller, "image_containers", return_value=[image_item()]), \
|
||||
patch.object(controller, "tts_container", return_value=tts_item()):
|
||||
patch.object(controller, "tts_container", return_value=tts_item()), \
|
||||
patch.object(controller, "docker_request") as request:
|
||||
with self.assertRaisesRegex(RuntimeError, "missing"):
|
||||
controller.activate("fast")
|
||||
request.assert_not_called()
|
||||
|
||||
def test_image_start_stops_inference_first(self):
|
||||
profiles = {name: item(name) for name in controller.ALLOWED}
|
||||
|
||||
Reference in New Issue
Block a user