feat(updates): check Gitea automatically and deploy on owner confirmation
Add owner-only update controls, a read-only SSH checker and independent systemd deployment services. Build before maintenance; back up code and database; restore on failed deployment. Preserve runtime configuration and gate business writes during the switch.
This commit is contained in:
1 parent
9b5463ecb3
commit
e2bafd8bff
28 files changed
+1346
-1
No files matched your search
@@ -0,0 +1,27 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
import pytest
|
||||
from starlette.websockets import WebSocketDisconnect
|
||||
|
||||
from app.core import system_maintenance as maintenance
|
||||
|
||||
|
||||
def test_maintenance_gates_business_requests_but_allows_status(tmp_path, monkeypatch):
|
||||
marker = tmp_path / 'maintenance'
|
||||
monkeypatch.setattr(maintenance, 'MAINTENANCE_FILE', marker)
|
||||
app = FastAPI()
|
||||
for path in ['/health', '/api/v1/system-updates', '/api/v1/chats']:
|
||||
app.get(path)(lambda: {'ok': True})
|
||||
client = TestClient(maintenance.SystemMaintenanceMiddleware(app))
|
||||
assert client.get('/api/v1/chats').status_code == 200
|
||||
marker.touch()
|
||||
assert client.get('/health').status_code == 200
|
||||
assert client.get('/api/v1/system-updates').status_code == 200
|
||||
assert client.get('/api/v1/chats').status_code == 503
|
||||
assert client.post('/api/v1/system-updates/check').status_code == 503
|
||||
with pytest.raises(WebSocketDisconnect) as exc:
|
||||
with client.websocket_connect('/socket.io/'):
|
||||
pass
|
||||
assert exc.value.code == 1013
|
||||
Reference in new issue
Block a user