mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
- 新增 safe_create_task 统一替代裸 asyncio.create_task,通过全局集合持有 task 引用 - 默认 worker 数量从 4 降为 1,HTTP 连接池总预算从 800 降为 200 - 为 health_cache 和 affinity_manager 内存缓存增加上限淘汰机制 - MemoryCachePlugin 支持延迟启动清理任务 - gunicorn when_ready 增加 gc.collect() 并记录 post_worker_init RSS
35 lines
996 B
Python
35 lines
996 B
Python
import pytest
|
|
|
|
from src.config.settings import Config
|
|
|
|
|
|
def test_config_defaults_to_single_worker_and_capped_http_pool(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
for key in (
|
|
"WEB_CONCURRENCY",
|
|
"GUNICORN_WORKERS",
|
|
"HTTP_MAX_CONNECTIONS",
|
|
"HTTP_KEEPALIVE_CONNECTIONS",
|
|
):
|
|
monkeypatch.delenv(key, raising=False)
|
|
|
|
cfg = Config()
|
|
|
|
assert cfg.worker_processes == 1
|
|
assert cfg.http_max_connections == 200
|
|
assert cfg.http_keepalive_connections == 60
|
|
|
|
|
|
def test_config_scales_http_pool_down_for_multi_worker(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("GUNICORN_WORKERS", "2")
|
|
monkeypatch.delenv("WEB_CONCURRENCY", raising=False)
|
|
monkeypatch.delenv("HTTP_MAX_CONNECTIONS", raising=False)
|
|
monkeypatch.delenv("HTTP_KEEPALIVE_CONNECTIONS", raising=False)
|
|
|
|
cfg = Config()
|
|
|
|
assert cfg.worker_processes == 2
|
|
assert cfg.http_max_connections == 100
|
|
assert cfg.http_keepalive_connections == 30
|