mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-29 03:56:43 +08:00
* fix(resource): select free-threaded extension ABI * chore(deps): require moviepilot-rust 0.2.9 * perf: add free-threaded runtime comparison * feat: add free-threaded runtime profile * chore(deps): require moviepilot-rust 0.3.0 * test: isolate system endpoint import graph * fix(docker): preserve runtime profile during recovery * feat(runtime): expose active GIL state * feat(plugin): log GIL fallback attribution * test: refresh runtime observability dependency baseline * fix(plugin): validate the active uv runtime profile * test(runtime): expand free-threaded benchmark evidence * docs(runtime): define v3t governance gates * test(runtime): separate rust benchmark modes * docs: sync free-threaded architecture baseline * perf: add PostgreSQL driver comparison * docs(runtime): record final free-threaded evidence * fix(runtime): converge dual-profile dependency verification * fix(runtime): scope Python 3.14 warning filter * fix(runtime): match actual oss2 syntax warning * docs(runtime): refresh free-threaded benchmark evidence * test(architecture): refresh runtime dependency baseline * ci: skip unused Trivy Java database * build: exclude local verification artifacts * docs(runtime): refresh PostgreSQL driver benchmarks * docs(runtime): record plugin restore acceptance * docs(runtime): record amd64 candidate acceptance * ci: pin beta image publisher action * test(architecture): merge runtime dependency baseline * feat(runtime): expose Python GIL status * docs(runtime): document Python runtime status fields
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
from app.runtime.config import settings
|
|
from app.adapters.system import rust as rust_accel
|
|
|
|
|
|
class _DummyRustExtension:
|
|
"""
|
|
测试用 Rust 扩展替身,用来验证总开关会阻止扩展调用。
|
|
"""
|
|
|
|
@staticmethod
|
|
def is_available() -> bool:
|
|
"""
|
|
模拟 Rust 扩展基础能力可用。
|
|
"""
|
|
return True
|
|
|
|
@staticmethod
|
|
def parse_filter_rule_fast(_expression: str) -> list:
|
|
"""
|
|
如果总开关关闭后仍调用扩展,测试应立即失败。
|
|
"""
|
|
raise AssertionError("Rust extension should not be called")
|
|
|
|
|
|
def test_rust_accel_runtime_switch_disables_fast_paths(monkeypatch):
|
|
"""
|
|
RUST_ACCEL 关闭时,即便扩展可用也应回退到 Python 路径。
|
|
"""
|
|
monkeypatch.setattr(settings, "RUST_ACCEL", False)
|
|
monkeypatch.setattr(rust_accel, "is_required", lambda: False)
|
|
monkeypatch.setattr(rust_accel, "_moviepilot_rust", _DummyRustExtension())
|
|
|
|
assert rust_accel.is_available()
|
|
assert not rust_accel.is_enabled()
|
|
assert rust_accel.parse_filter_rule("HDR") is None
|
|
|
|
|
|
def test_free_threaded_runtime_requires_rust_acceleration(monkeypatch):
|
|
"""free-threaded 运行时不能通过配置关闭 Rust 快路径。"""
|
|
monkeypatch.setattr(settings, "RUST_ACCEL", False)
|
|
monkeypatch.setattr(rust_accel, "is_required", lambda: True)
|
|
monkeypatch.setattr(rust_accel, "_moviepilot_rust", _DummyRustExtension())
|
|
|
|
assert rust_accel.is_config_enabled()
|
|
assert rust_accel.is_enabled()
|
|
assert rust_accel.status()["required"] is True
|
|
|
|
|
|
def test_rust_accel_status_reports_enabled_state(monkeypatch):
|
|
"""
|
|
状态接口应同时体现扩展可用性和配置开关后的实际启用状态。
|
|
"""
|
|
monkeypatch.setattr(settings, "RUST_ACCEL", True)
|
|
monkeypatch.setattr(rust_accel, "is_required", lambda: False)
|
|
monkeypatch.setattr(rust_accel, "_moviepilot_rust", _DummyRustExtension())
|
|
|
|
assert rust_accel.status()["available"] is True
|
|
assert rust_accel.status()["enabled"] is True
|