Files
ewoooc/tests/test_cd_health_check.py
OoO 3193f1979d
Some checks failed
CD Pipeline / deploy (push) Failing after 1m6s
縮短 CD rebuild 切換停機窗口
2026-04-30 09:25:49 +08:00

40 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
CD_WORKFLOW = ROOT / ".gitea/workflows/cd.yaml"
def test_cd_health_check_allows_slow_rebuild_warmup():
workflow = CD_WORKFLOW.read_text(encoding="utf-8")
assert "等待服務啟動30s" in workflow
assert "seq 1 12" in workflow
assert "等待 15s" in workflow
def test_cd_health_check_validates_internal_and_external_health():
workflow = CD_WORKFLOW.read_text(encoding="utf-8")
assert "docker exec momo-pro-system curl" in workflow
assert "http://127.0.0.1:80/health" in workflow
assert "https://mo.wooo.work/health" in workflow
assert 'internal=$INTERNAL_CODE, external=$EXTERNAL_CODE' in workflow
def test_cd_sync_mode_restarts_after_rsync_to_reload_python_processes():
workflow = CD_WORKFLOW.read_text(encoding="utf-8")
assert "docker compose up -d --no-deps momo-app scheduler telegram-bot" in workflow
assert "docker compose restart momo-app scheduler telegram-bot" in workflow
def test_cd_rebuild_builds_image_before_stopping_running_containers():
workflow = CD_WORKFLOW.read_text(encoding="utf-8")
build_index = workflow.index("docker compose build --no-cache momo-app")
stop_index = workflow.index("docker stop momo-pro-system")
up_index = workflow.index("docker compose up -d --no-deps --force-recreate momo-app scheduler telegram-bot")
assert build_index < stop_index < up_index