Prod upgrade fixes: profiler compatibility with new FastAPI, pinned dependencies
- profiler: Literal instead of Query(enum=...) (broke on FastAPI 0.162) - pin fastapi/starlette/uvicorn/pydantic for the profiler, upper bounds for APP_CORE - health check: show the service log when an HTTP check fails - update.sh: the "before" version comes from deploy.state - migrate.py: hint about OVPMON_*_DB_PATH when the default database is missing - docs: --source --no-pull mode, dependency pinning, PIP_CONSTRAINT - tests: new test for the section parameter, fixed test_server_process.py Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1bbf9b7cc1
commit
79c950f8f7
14 files changed
+156
-38
No files matched your search
@@ -1,33 +1,27 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
# The DB path must be set before database.py is imported (via main)
|
||||
_tmp = tempfile.TemporaryDirectory()
|
||||
os.environ["OVPMON_PROFILER_DB_PATH"] = os.path.join(_tmp.name, "test.db")
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add project root to sys.path
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
from utils.auth import verify_token
|
||||
|
||||
app.dependency_overrides[verify_token] = lambda: {"sub": "test"}
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_get_stats():
|
||||
response = client.get("/server/process/stats")
|
||||
print(f"Stats response status: {response.status_code}")
|
||||
print(f"Stats response body: {response.json()}")
|
||||
response = client.get("/api/server/process/stats")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "pid" in data
|
||||
assert "cpu_percent" in data
|
||||
assert "memory_mb" in data
|
||||
|
||||
def test_control_invalid():
|
||||
response = client.post("/server/process/invalid_action")
|
||||
print(f"Invalid action response: {response.status_code}")
|
||||
assert response.status_code == 400
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Running API tests...")
|
||||
try:
|
||||
test_get_stats()
|
||||
test_control_invalid()
|
||||
print("Tests passed!")
|
||||
except Exception as e:
|
||||
print(f"Tests failed: {e}")
|
||||
def test_control_invalid():
|
||||
response = client.post("/api/server/process/invalid_action")
|
||||
assert response.status_code == 400
|
||||
Reference in new issue
Block a user