chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
dhv2_base_url="${DHV2_BASE_URL:-https://dhv2.korexlabs.com}"
|
||||
dhv2_base_url="${dhv2_base_url%/}"
|
||||
|
||||
fail() {
|
||||
echo "ERROR: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "========== B2 · MIGRACIONES =========="
|
||||
dhv2_migration_status="$(docker compose --profile tools run --rm migrate npm run migration:show 2>&1)"
|
||||
grep -q 'Pending migrations: no' <<<"$dhv2_migration_status" \
|
||||
|| fail "Quedaron migraciones pendientes"
|
||||
echo "Migraciones pendientes: no"
|
||||
|
||||
echo
|
||||
echo "========== B2 · HEALTH =========="
|
||||
dhv2_internal="$(curl -fsS --connect-timeout 10 --max-time 30 http://127.0.0.1:3101/api/v3/health)"
|
||||
dhv2_external="$(curl -fsS --connect-timeout 10 --max-time 30 "$dhv2_base_url/api/v3/health")"
|
||||
grep -q '"version":"0.9.0"' <<<"$dhv2_internal" || fail "Health interno no informa v0.9.0"
|
||||
grep -q '"phase":"B2"' <<<"$dhv2_internal" || fail "Health interno no informa B2"
|
||||
grep -q '"version":"0.9.0"' <<<"$dhv2_external" || fail "Health externo no informa v0.9.0"
|
||||
grep -q '"database":"ok"' <<<"$dhv2_external" || fail "La base no está saludable"
|
||||
echo "$dhv2_external"
|
||||
|
||||
echo
|
||||
echo "========== B2 · RUTAS PROTEGIDAS =========="
|
||||
for dhv2_path in map/assets assets; do
|
||||
dhv2_code="$(curl -sS --connect-timeout 10 --max-time 30 \
|
||||
-o /tmp/dhv2-b2-response.json -w '%{http_code}' \
|
||||
"$dhv2_base_url/api/v3/$dhv2_path")"
|
||||
test "$dhv2_code" = "401" || fail "/api/v3/$dhv2_path devolvió HTTP $dhv2_code; se esperaba 401"
|
||||
echo "/api/v3/$dhv2_path sin sesión: 401 OK"
|
||||
done
|
||||
rm -f /tmp/dhv2-b2-response.json
|
||||
|
||||
echo
|
||||
echo "========== B2 · POSTGIS Y PERMISOS =========="
|
||||
dhv2_db_check="$(docker compose exec -T db sh -lc \
|
||||
'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -v ON_ERROR_STOP=1 -At' <<'SQL'
|
||||
SELECT 'postgis', COUNT(*)
|
||||
FROM pg_extension
|
||||
WHERE extname = 'postgis';
|
||||
|
||||
SELECT 'geometry_table', COUNT(*)
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'asset_geometries';
|
||||
|
||||
SELECT 'geometry_column', COUNT(*)
|
||||
FROM geometry_columns
|
||||
WHERE f_table_schema = 'public'
|
||||
AND f_table_name = 'asset_geometries'
|
||||
AND f_geometry_column = 'geometry'
|
||||
AND srid = 4326;
|
||||
|
||||
SELECT 'gist_index', COUNT(*)
|
||||
FROM pg_indexes
|
||||
WHERE schemaname = 'public'
|
||||
AND tablename = 'asset_geometries'
|
||||
AND indexname = 'idx_asset_geometries_geometry';
|
||||
|
||||
SELECT 'permission', COUNT(*)
|
||||
FROM permissions
|
||||
WHERE code = 'assets.update_geometry';
|
||||
|
||||
SELECT 'admin_permission', COUNT(*)
|
||||
FROM role_permissions role_permission
|
||||
INNER JOIN roles role ON role.id = role_permission.role_id
|
||||
INNER JOIN permissions permission ON permission.id = role_permission.permission_id
|
||||
WHERE role.code = 'admin'
|
||||
AND permission.code = 'assets.update_geometry';
|
||||
SQL
|
||||
)"
|
||||
grep -q 'postgis|1' <<<"$dhv2_db_check" || fail "PostGIS no está disponible"
|
||||
grep -q 'geometry_table|1' <<<"$dhv2_db_check" || fail "No se creó asset_geometries"
|
||||
grep -q 'geometry_column|1' <<<"$dhv2_db_check" || fail "La geometría EPSG:4326 no fue registrada"
|
||||
grep -q 'gist_index|1' <<<"$dhv2_db_check" || fail "No se encontró el índice espacial GIST"
|
||||
grep -q 'permission|1' <<<"$dhv2_db_check" || fail "No se creó assets.update_geometry"
|
||||
grep -q 'admin_permission|1' <<<"$dhv2_db_check" || fail "Admin no recibió assets.update_geometry"
|
||||
echo "$dhv2_db_check"
|
||||
|
||||
echo
|
||||
echo "========== B2 · FRONTEND =========="
|
||||
docker compose exec -T web sh -lc \
|
||||
'grep -R "0.9.0" /usr/share/nginx/html/assets >/dev/null && grep -R "Geometrías PostGIS y mapa operativo" /usr/share/nginx/html/assets >/dev/null && grep -R "Mapa de activos" /usr/share/nginx/html/assets >/dev/null'
|
||||
echo "Mapa y footer v0.9.0: OK"
|
||||
|
||||
echo
|
||||
echo "ACEPTACIÓN DE FASE B2: OK"
|
||||
Reference in New Issue
Block a user