Files
autotest/DOCS/ARCHITECTURE-FULL.md

96 lines
4.5 KiB
Markdown
Raw Permalink 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.
# Архитектура Autotest — полный обзор
v1.1.44, 2026-07-30
## Назначение
Платформа для тестирования Nubes Cloud API — ручное и автоматизированное создание/изменение/удаление инстансов любых сервисов (PostgreSQL, Redis, S3, Kafka, ~35 сервисов).
## Развёртывание
- **Платформа:** Nubes pythonk8s (managed Flask + gunicorn)
- **URL:** `https://atest.pythonk8s.dev.nubes.ru/`
- **БД:** PostgreSQL 17 (Zalando Operator), autotest
- **Репозиторий:** `/home/naeel/nubes/autotest/app-autotest`
- **Родительский репо:** `/home/naeel/nubes/autotest`
## Ключевые файлы
### Бэкенд (Flask)
| Файл | Назначение |
|------|-----------|
| `site/app.py` | Точка входа, регистрация blueprint'ов, VERSION |
| `site/routes/api_test.py` | Основной: POST /api/test, GET /api/params, поллинг, _finish_op |
| `site/routes/main.py` | GET /, /api/operations/{svc_id} |
| `site/routes/api.py` | LEGACY эндпоинты (будет удалён) |
| `site/api/http_client.py` | HTTP-клиент Nubes API (GET/POST/raw_delete) |
| `site/api/auth.py` | Токены, get_client, get_stand |
| `site/operations/get_params.py` | get_params_with_current_values, _normalize_value_list, state.out |
| `site/operations/get_instances.py` | GET /instances с пагинацией |
| `site/operations/get_services.py` | GET /services, /services/{id} |
| `site/operations/service_list.py` | Загрузка services_{stand}.txt |
| `site/operations/tracker.py` | fcntl.flock файловый трекер инстансов |
| `site/db/pool.py` | psycopg2 ThreadedConnectionPool (lazy-init) |
| `site/db/init_db.py` | CREATE TABLE runs + миграции |
| `site/db/save_run.py` | INSERT в runs (16 колонок) |
| `site/runner.py` | LEGACY runner (будет удалён) |
| `site/config.yaml` | LEGACY конфиг (будет удалён) |
### Фронтенд (vanilla JS)
| Файл | Назначение |
|------|-----------|
| `site/templates/index.html` | Jinja2 шаблон, CSS, window.APP |
| `site/static/app.js` | Весь фронтенд (460 строк) |
| `site/static/style.css` | Доп. стили |
### Конфиги
| Файл | Назначение |
|------|-----------|
| `site/config/services_test.txt` | Список сервисов TEST (комментировать # для исключения) |
| `site/config/services_dev.txt` | Список сервисов DEV |
| `requirements.txt` | Python-зависимости |
## CREATE flow (9 шагов Nubes API)
1. POST /instances
2. POST /instanceOperations {operation:"create"}
3. GET /instanceOperations/{opUid}?fields=cfsParams
4. resolveRefSvcParamValues
5. POST /instanceOperationCfsParams (пользовательские)
6. POST /instanceOperationCfsParams (required+default)
7. GET /validate-cfs
8. POST /run
9. Поллинг dtFinish
## Фронтенд — глобальное состояние
```
svcInstances — кеш инстансов
selectedInst — UID выбранного
selectedOp — {opId, opName, svcId}
pollTimer — setInterval поллинга
currentSvcId — ID сервиса
currentSvcName — имя сервиса
currentSvcShort— краткое имя (redis, postgres)
busy — блокировка параллельных операций
```
## План развития (MVP сценариев)
Файлы: `/home/naeel/nubes/autotest/TASKS/3007.md` (требования), `/home/naeel/nubes/autotest/DOCS/sol-answers.md` (решения)
1. Багфиксы аудита
2. Удалить legacy (api.py, runner.py, config.yaml)
3. Сервисные токены для сценариев
4. YAML-сценарии + валидатор
5. scenario_runs таблица + runner
6. UI: сворачиваемая секция «Сценарии»
## Документация
- `/home/naeel/nubes/autotest/DOCS/terraform-operations-full-logic.md` — эталонный Nubes API flow
- `/home/naeel/nubes/autotest/DOCS/sol-answers.md` — ответы на 14 вопросов по архитектуре
- `/home/naeel/nubes/autotest/DOCS/questions-to-sol.md` — 14 вопросов к Sol
- `/home/naeel/nubes/autotest/app-autotest/DOCS/sonnet-final-audit.md` — финальный аудит Соннета
- `/home/naeel/nubes/autotest/HISTORY/2026-07-29-session.md` — хронология правок