Files
core/tests/test_server_health.py
Untone f3fc6c34ae
Some checks failed
Deploy on push / deploy (push) Failing after 7s
e2e-improved
2025-08-27 18:31:51 +03:00

66 lines
2.5 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.
#!/usr/bin/env python3
"""
Тест здоровья серверов для CI
"""
import time
import requests
import pytest
def test_backend_health(backend_server):
"""Проверяем здоровье бэкенда"""
assert backend_server, "Бэкенд сервер должен быть запущен"
response = requests.get("http://localhost:8000/", timeout=10)
assert response.status_code == 200, f"Бэкенд вернул статус {response.status_code}"
print("✅ Бэкенд здоров")
def test_frontend_health(frontend_server):
"""Проверяем здоровье фронтенда"""
if not frontend_server:
pytest.skip("Фронтенд сервер не удалось запустить (возможно отсутствует npm или зависимости)")
response = requests.get("http://localhost:3000/", timeout=10)
assert response.status_code == 200, f"Фронтенд вернул статус {response.status_code}"
print("✅ Фронтенд здоров")
def test_graphql_endpoint(backend_server):
"""Проверяем доступность GraphQL endpoint"""
assert backend_server, "Бэкенд сервер должен быть запущен"
response = requests.post(
"http://localhost:8000/graphql",
headers={"Content-Type": "application/json"},
json={"query": "{ __schema { types { name } } }"},
timeout=15
)
assert response.status_code == 200, f"GraphQL endpoint вернул статус {response.status_code}"
print("✅ GraphQL endpoint доступен")
def test_admin_panel_access(frontend_server):
"""Проверяем доступность админ-панели"""
if not frontend_server:
pytest.skip("Фронтенд сервер не запущен - админ-панель недоступна")
response = requests.get("http://localhost:3000/admin", timeout=15)
assert response.status_code == 200, f"Админ-панель вернула статус {response.status_code}"
print("✅ Админ-панель доступна")
if __name__ == "__main__":
print("🧪 Проверяем здоровье серверов...")
try:
test_backend_health()
test_frontend_health()
test_graphql_endpoint()
test_admin_panel_access()
print("Все серверы здоровы!")
except Exception as e:
print(f"❌ Ошибка проверки здоровья: {e}")
exit(1)