test: добавить полное покрытие Molecule + HTML report генератор
Molecule тесты для всех аддонов и кластерный topology тест: Аддоны (Helm lint + template + assertions): - addons/technitium-dns/role/molecule/ — Primary/Secondary DNS, CronJob, kube-vip - addons/authelia/role/molecule/ — OIDC clients, access_control, manifests - addons/ingress-proxypass/role/molecule/ — proxies, Service/Endpoints/Ingress - addons/ingress-add-domains/role/molecule/ — entries, Ingress per namespace - addons/yandex-dns-controller/role/molecule/ — CronJob, ConfigMap, RBAC Кластер: - molecule/cluster/ — 3 master (embedded etcd HA) + 2 worker topology тест Инфраструктура: - scripts/molecule-report.py — генератор HTML отчётов из JUnit XML (читает /tmp/molecule-junit/*.xml → /tmp/molecule-report.html) - requirements-python.txt — комментарий к отчётному блоку - docker/entrypoint.sh — добавлены команды molecule-addon, molecule-cluster, molecule-report с автоматическим включением junit callback - Makefile — targets: molecule-cluster, molecule-addon-*, molecule-addon-all, molecule-report; molecule-all генерирует HTML отчёт - docs/molecule-testing.md — полная документация всех сценариев - docs/addons.md — добавлены technitium-dns и authelia в таблицу аддонов
This commit is contained in:
@@ -392,10 +392,48 @@ case "${COMMAND}" in
|
||||
exit 1
|
||||
fi
|
||||
log "Тестирую роль: ${ROLE}"
|
||||
export JUNIT_OUTPUT_DIR="${JUNIT_OUTPUT_DIR:-/tmp/molecule-junit}"
|
||||
export ANSIBLE_CALLBACKS_ENABLED="${ANSIBLE_CALLBACKS_ENABLED:-junit}"
|
||||
mkdir -p "${JUNIT_OUTPUT_DIR}"
|
||||
cd "/ansible/roles/${ROLE}"
|
||||
exec molecule "${@:-test}"
|
||||
;;
|
||||
|
||||
# ── Molecule тестирование аддонов ─────────────────────────────────────────
|
||||
molecule-addon)
|
||||
ADDON="${2:-}"
|
||||
shift 2 || true
|
||||
if [[ -z "${ADDON}" ]]; then
|
||||
err "Укажи аддон: molecule-addon technitium-dns | molecule-addon authelia"
|
||||
echo ""
|
||||
echo "Доступные аддоны с molecule тестами:"
|
||||
find /ansible/addons -name "molecule.yml" 2>/dev/null \
|
||||
| sed 's|/ansible/addons/||; s|/role/molecule.*||' | sort | sed 's/^/ /'
|
||||
exit 1
|
||||
fi
|
||||
ADDON_MOLECULE_DIR="/ansible/addons/${ADDON}/role"
|
||||
if [[ ! -d "${ADDON_MOLECULE_DIR}/molecule" ]]; then
|
||||
err "Molecule тесты не найдены: ${ADDON_MOLECULE_DIR}/molecule/"
|
||||
exit 1
|
||||
fi
|
||||
log "Тестирую аддон: ${ADDON}"
|
||||
export JUNIT_OUTPUT_DIR="${JUNIT_OUTPUT_DIR:-/tmp/molecule-junit}"
|
||||
export ANSIBLE_CALLBACKS_ENABLED="${ANSIBLE_CALLBACKS_ENABLED:-junit}"
|
||||
mkdir -p "${JUNIT_OUTPUT_DIR}"
|
||||
cd "${ADDON_MOLECULE_DIR}"
|
||||
exec molecule "${@:-test}"
|
||||
;;
|
||||
|
||||
# ── Molecule кластерный тест (3 master + 2 worker) ────────────────────────
|
||||
molecule-cluster)
|
||||
log "Тестирую topology кластера (3 master + 2 worker)..."
|
||||
export JUNIT_OUTPUT_DIR="${JUNIT_OUTPUT_DIR:-/tmp/molecule-junit}"
|
||||
export ANSIBLE_CALLBACKS_ENABLED="${ANSIBLE_CALLBACKS_ENABLED:-junit}"
|
||||
mkdir -p "${JUNIT_OUTPUT_DIR}"
|
||||
cd /ansible
|
||||
exec molecule test -s cluster "${@}"
|
||||
;;
|
||||
|
||||
molecule-lint)
|
||||
log "Запуск линтинга (yamllint + ansible-lint)..."
|
||||
cd /ansible
|
||||
@@ -404,6 +442,17 @@ case "${COMMAND}" in
|
||||
ok "Линтинг прошёл"
|
||||
;;
|
||||
|
||||
# ── Molecule HTML отчёт ───────────────────────────────────────────────────
|
||||
molecule-report)
|
||||
XML_DIR="${2:-/tmp/molecule-junit}"
|
||||
OUTPUT="${3:-/tmp/molecule-report.html}"
|
||||
log "Генерирую HTML отчёт из ${XML_DIR}..."
|
||||
python3 /ansible/scripts/molecule-report.py \
|
||||
--xml-dir "${XML_DIR}" \
|
||||
--output "${OUTPUT}"
|
||||
ok "Отчёт: ${OUTPUT}"
|
||||
;;
|
||||
|
||||
# ── Прямые вызовы ─────────────────────────────────────────────────────────
|
||||
ansible-playbook)
|
||||
exec ansible-playbook "$@"
|
||||
|
||||
Reference in New Issue
Block a user