e2e-improved
Some checks failed
Deploy on push / deploy (push) Failing after 7s

This commit is contained in:
2025-08-27 18:31:51 +03:00
parent e7cdcbc5dd
commit f3fc6c34ae
10 changed files with 170 additions and 88 deletions

View File

@@ -8,75 +8,47 @@ import requests
import pytest
@pytest.mark.skip_ci
def test_backend_health():
def test_backend_health(backend_server):
"""Проверяем здоровье бэкенда"""
max_retries = 10
for attempt in range(1, max_retries + 1):
try:
response = requests.get("http://localhost:8000/", timeout=10)
if response.status_code == 200:
print(f"✅ Бэкенд готов (попытка {attempt})")
return
except requests.exceptions.RequestException as e:
print(f"⚠️ Попытка {attempt}/{max_retries}: Бэкенд не готов - {e}")
if attempt < max_retries:
time.sleep(3)
else:
pytest.fail(f"Бэкенд не готов после {max_retries} попыток")
assert backend_server, "Бэкенд сервер должен быть запущен"
response = requests.get("http://localhost:8000/", timeout=10)
assert response.status_code == 200, f"Бэкенд вернул статус {response.status_code}"
print("✅ Бэкенд здоров")
@pytest.mark.skip_ci
def test_frontend_health():
def test_frontend_health(frontend_server):
"""Проверяем здоровье фронтенда"""
max_retries = 10
for attempt in range(1, max_retries + 1):
try:
response = requests.get("http://localhost:3000/", timeout=10)
if response.status_code == 200:
print(f"✅ Фронтенд готов (попытка {attempt})")
return
except requests.exceptions.RequestException as e:
print(f"⚠️ Попытка {attempt}/{max_retries}: Фронтенд не готов - {e}")
if attempt < max_retries:
time.sleep(3)
else:
# В CI фронтенд может быть не запущен, поэтому не падаем
pytest.skip("Фронтенд не запущен (ожидаемо в некоторых CI средах)")
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("✅ Фронтенд здоров")
@pytest.mark.skip_ci
def test_graphql_endpoint():
def test_graphql_endpoint(backend_server):
"""Проверяем доступность GraphQL endpoint"""
try:
response = requests.post(
"http://localhost:8000/graphql",
headers={"Content-Type": "application/json"},
json={"query": "{ __schema { types { name } } }"},
timeout=15
)
if response.status_code == 200:
print("GraphQL endpoint доступен")
return
else:
pytest.fail(f"GraphQL endpoint вернул статус {response.status_code}")
except requests.exceptions.RequestException as e:
pytest.fail(f"GraphQL endpoint недоступен: {e}")
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 доступен")
@pytest.mark.skip_ci
def test_admin_panel_access():
def test_admin_panel_access(frontend_server):
"""Проверяем доступность админ-панели"""
try:
response = requests.get("http://localhost:3000/admin", timeout=15)
if response.status_code == 200:
print("✅ Админ-панель доступна")
return
else:
pytest.fail(f"Админ-панель вернула статус {response.status_code}")
except requests.exceptions.RequestException as e:
# В CI фронтенд может быть не запущен, поэтому не падаем
pytest.skip("Админ-панель недоступна (фронтенд не запущен)")
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__":