sync @ b825d2b

This commit is contained in:
2026-10-12 22:03:31 +07:00
parent 50a9b415c3
commit 82c6514b25
2 changed files with 44 additions and 16 deletions
+41 -13
View File
@@ -139,32 +139,60 @@ echo ""
# C. Catalog — contoh schema (namespace) & refs
# ─────────────────────────────────────────────────────────────────────────────
echo -e "${BOLD}C. Catalog — contoh schema (≤5) & refs${NC}"
ns_json="$(curl -sf --max-time 10 "${BASE}${PFX}/v1/namespaces" 2>/dev/null || echo "")"
if [[ -z "${ns_json}" ]]; then
code="$(http_code "${BASE}${PFX}/v1/namespaces")"
if [[ -z "${ic_cfg}" ]]; then
warn "Tak bisa membaca namespace karena Iceberg REST tak tersedia [HTTP ${code}]"
else
fail "Iceberg REST aktif tetapi namespace tak terbaca [HTTP ${code} — $(code_hint "${code}")]"
fi
else
ns_out="$(printf '%s' "${ns_json}" | python3 -c '
# Endpoint 'namespaces' Iceberg REST memakai PREFIX (warehouse/branch) yang bergantung
# pada server — `/v1/namespaces` (tanpa prefix) bisa 404 walau REST aktif. Coba beberapa
# kandidat; kandidat pertama yang mengembalikan JSON namespace dipakai.
ns_parse() {
printf '%s' "$1" | python3 -c '
import sys, json
try:
d = json.load(sys.stdin)
except Exception:
print("0|"); sys.exit()
ns = d.get("namespaces") or []
sys.exit(1)
ns = d.get("namespaces")
if ns is None:
sys.exit(1)
def flat(n): return ".".join(n) if isinstance(n, list) else str(n)
print(f"{len(ns)}|" + ", ".join(flat(n) for n in ns[:5]))
' 2>/dev/null
}
ic_prefix="$(printf '%s' "${ic_cfg}" | python3 -c '
import sys, json
try:
d = json.load(sys.stdin)
except Exception:
sys.exit()
ov = d.get("overrides") or {}; df = d.get("defaults") or {}
print(ov.get("prefix") or df.get("prefix") or "")
' 2>/dev/null)"
ns_cands=()
[[ -n "${ic_prefix}" ]] && ns_cands+=("${BASE}${PFX}/v1/${ic_prefix}/namespaces")
ns_cands+=("${BASE}${PFX}/v1/namespaces")
[[ -n "${WAREHOUSE}" ]] && ns_cands+=("${BASE}${PFX}/v1/${WAREHOUSE}/namespaces")
ns_cands+=("${BASE}${PFX}/v1/main/namespaces")
[[ -n "${WAREHOUSE}" ]] && ns_cands+=("${BASE}${PFX}/v1/main%7C${WAREHOUSE}/namespaces")
[[ -n "${WAREHOUSE}" ]] && ns_cands+=("${BASE}${PFX}/v1/%7C${WAREHOUSE}/namespaces")
ns_out=""; ns_used=""
for _u in "${ns_cands[@]}"; do
_j="$(curl -sf --max-time 10 "${_u}" 2>/dev/null || echo "")"
if [[ -n "${_j}" ]] && ns_out="$(ns_parse "${_j}")" && [[ -n "${ns_out}" ]]; then ns_used="${_u}"; break; fi
ns_out=""
done
if [[ -n "${ns_out}" ]]; then
ns_count="${ns_out%%|*}"; ns_list="${ns_out#*|}"
if [[ "${ns_count:-0}" -gt 0 ]]; then
pass "Catalog berisi ${ns_count} namespace — contoh (≤5): ${ns_list}"
else
warn "Iceberg REST aktif tetapi catalog MASIH KOSONG (0 namespace) — normal sebelum ingest"
info "Konteks konfigurasi: bucket='${BUCKET}' warehouse='${WAREHOUSE}' prefix='${PFX}'"
fi
info "namespace via ${ns_used#${BASE}} (bucket='${BUCKET}' warehouse='${WAREHOUSE}' prefix='${PFX}')"
elif [[ -z "${ic_cfg}" ]]; then
warn "Tak bisa membaca namespace karena Iceberg REST tak tersedia [HTTP $(http_code "${BASE}${PFX}/v1/namespaces")]"
else
codes=""
for _u in "${ns_cands[@]}"; do codes+="${_u#${BASE}}→$(http_code "${_u}") "; done
fail "Iceberg REST aktif tetapi namespace TIDAK terbaca — kandidat path: ${codes% }"
info "Nessie umumnya menaruh namespace di path ber-PREFIX (warehouse/branch), mis. ${PFX}/v1/${WAREHOUSE}/namespaces"
fi
main_code="$(http_code "${BASE}/api/v2/trees/main")"
[[ "${main_code}" == "200" ]] && pass "Branch 'main' tersedia" \