Optimize terminal startup and deployment smoke checks

This commit is contained in:
2569718930@qq.com
2026-05-31 01:56:08 +08:00
parent bf0fbe1b1d
commit ca72072da0
21 changed files with 393 additions and 41 deletions
+2 -1
View File
@@ -74,7 +74,8 @@ def test_deploy_script_retries_startup_smoke_checks():
assert "smoke_check()" in script
assert 'smoke_check "healthz" "https://api.polyweather.top/healthz" 15 3 5' in script
assert 'smoke_check "local cities" "http://127.0.0.1:8000/api/cities" 10 6 3' in script
assert 'warm_public_route "local cities recent stats" "http://127.0.0.1:8000/api/cities?refresh_deb_recent=1"' in script
assert 'smoke_check "local cities" "http://127.0.0.1:8000/api/cities" 10 6 3' not in script
assert 'smoke_check "frontend cities" "https://polyweather.top/api/cities" 20 5 5' in script
assert 'smoke_check "frontend" "https://www.polyweather.top/" 15 3 5' in script
+25
View File
@@ -11,6 +11,7 @@ import web.routes as routes
import web.services.ops_api as ops_api
import web.scan_terminal_cache as scan_terminal_cache
import web.scan_terminal_service as scan_terminal_service
import web.services.city_api as city_api
import web.services.city_runtime as city_runtime
from web.scan_terminal_cache import scan_terminal_cache_key
from src.database.runtime_state import TruthRecordRepository
@@ -132,6 +133,30 @@ def test_cities_endpoint_includes_new_wunderground_cities():
}.issubset(names)
def test_cities_endpoint_does_not_block_on_recent_deb_index(monkeypatch):
monkeypatch.setattr(city_api, "_RECENT_DEB_CACHE", None, raising=False)
monkeypatch.setattr(city_api, "_RECENT_DEB_CACHE_TS", 0.0, raising=False)
monkeypatch.setattr(city_api, "_RECENT_DEB_REFRESHING", False, raising=False)
monkeypatch.setattr(city_api, "_get_recent_deb_cache", lambda: None, raising=False)
monkeypatch.setattr(city_api, "_start_recent_deb_refresh", lambda: None, raising=False)
def fail_recent_index():
raise AssertionError("recent DEB stats must not run in the default city-list request")
monkeypatch.setattr(
city_api.legacy_routes,
"_build_recent_deb_performance_index",
fail_recent_index,
)
response = client.get("/api/cities")
assert response.status_code == 200
denver = next(item for item in response.json()["cities"] if item["name"] == "denver")
assert denver["deb_recent_tier"] == "other"
assert denver["deb_recent_sample_count"] == 0
def test_payment_runtime_endpoint_returns_shape():
response = client.get('/api/payments/runtime')
assert response.status_code == 200