feat: 新增工具插件、系统日志、workflow配置及前端优化
1. 新增工具插件(edit_file, python_executor, search_file, shell_executor, write_file) 2. 新增系统事件日志模块和API 3. 新增workflow配置文件和详情API 4. 前端增加SSE、错误边界、设置引导等组件 5. 优化认证加密、速率限制、配置加载等工具模块 6. 删除废弃的cluster和health API 7. 补充单元测试和集成测试 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,3 +44,64 @@ def test_ray_actor_hook_unknown_actor_raises(fake_actors):
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
ray_actor_hook("does_not_exist")
|
||||
|
||||
|
||||
def test_wait_for_actor_returns_immediately_when_ready(fake_actors):
|
||||
"""actor 已就绪时 wait_for_actor 立刻返回,不进入轮询等待。"""
|
||||
handle = MagicMock()
|
||||
fake_actors.register("postgres_database", handle)
|
||||
|
||||
from kilostar.utils.ray_hook import wait_for_actor
|
||||
|
||||
got = wait_for_actor("postgres_database", timeout=5.0)
|
||||
assert got is handle
|
||||
|
||||
|
||||
def test_wait_for_actor_times_out_with_clear_error(fake_actors):
|
||||
"""超时仍未就绪时抛 TimeoutError,并在 message 里带 actor 名。"""
|
||||
from kilostar.utils.ray_hook import wait_for_actor
|
||||
|
||||
with pytest.raises(TimeoutError) as exc_info:
|
||||
wait_for_actor("never_ready", timeout=0.2, interval=0.05)
|
||||
assert "never_ready" in str(exc_info.value)
|
||||
|
||||
|
||||
def test_wait_for_actor_succeeds_after_delayed_registration(fake_actors):
|
||||
"""actor 在第 N 次轮询时才注册,wait_for_actor 应在它就绪后返回。"""
|
||||
from kilostar.utils.ray_hook import wait_for_actor
|
||||
|
||||
handle = MagicMock()
|
||||
calls = {"n": 0}
|
||||
original_get = fake_actors.get
|
||||
|
||||
def delayed_get(name, namespace="kilostar"):
|
||||
calls["n"] += 1
|
||||
if calls["n"] >= 3:
|
||||
return handle
|
||||
raise ValueError("not ready yet")
|
||||
|
||||
fake_actors.get = delayed_get
|
||||
try:
|
||||
got = wait_for_actor("late_actor", timeout=2.0, interval=0.05)
|
||||
assert got is handle
|
||||
assert calls["n"] >= 3
|
||||
finally:
|
||||
fake_actors.get = original_get
|
||||
|
||||
|
||||
def test_ray_actor_hook_with_timeout_waits(fake_actors):
|
||||
"""ray_actor_hook(timeout>0) 会走 wait_for_actor 等待路径。"""
|
||||
from kilostar.utils.ray_hook import ray_actor_hook
|
||||
|
||||
handle = MagicMock()
|
||||
calls = {"n": 0}
|
||||
|
||||
def delayed_get(name, namespace="kilostar"):
|
||||
calls["n"] += 1
|
||||
if calls["n"] >= 2:
|
||||
return handle
|
||||
raise ValueError("not ready yet")
|
||||
|
||||
fake_actors.get = delayed_get
|
||||
actors = ray_actor_hook("slow_actor", timeout=2.0, interval=0.05)
|
||||
assert actors.slow_actor is handle
|
||||
|
||||
Reference in New Issue
Block a user