104 lines
3.9 KiB
Markdown
104 lines
3.9 KiB
Markdown
# 🧪 Panduan Validasi & Pengujian: MERICA Pipeline Bundles
|
|
|
|
> **Repositori**: `merica-pipelines.git`
|
|
> **Status**: **Production Ready (4 Canonical Pipelines & 8 dbt Models)**
|
|
> **Integrasi**: Apache Airflow 3 Native `GitDagBundle` (Interval: 30s)
|
|
> **Standar Kepatuhan**: **Production Asset Standards**
|
|
|
|
---
|
|
|
|
## 📌 1. Gambaran Umum Pengujian Asset Pipeline
|
|
|
|
Repositori ini menyimpan logika analitik data lakehouse yang dipantau secara langsung oleh Airflow 3 DAG Processor. Sebelum aset pipeline di-merge atau di-push ke branch produksi (`development` / `main`), seluruh aset wajib melewati validasi:
|
|
|
|
1. **Validasi Sintaksis YAML**: Menjamin tidak ada kesalahan indentasi atau parsing pada file konfigurasi pipeline.
|
|
2. **Validasi Kontrak Aturan Great Expectations**: Memastikan deklarasi `rules:` dan `queries:` valid dan memiliki parameter wajib.
|
|
3. **Validasi Sintaksis Model dbt SQL**: Memastikan model transformasi Silver dan Gold memiliki struktur query yang kompatibel.
|
|
4. **Audit Integritas Aset Produksi**: Memastikan hanya konfigurasi kanonikal terverifikasi yang tersimpan di `configs/` atau `metadata/`.
|
|
|
|
---
|
|
|
|
## ⚡ 2. Perintah Validasi Lokal
|
|
|
|
Jalankan perintah berikut di root repositori `merica-pipeline-bundles/`:
|
|
|
|
### A. Validasi Seluruh Konfigurasi YAML
|
|
```bash
|
|
python3 -c "
|
|
import glob, yaml, sys
|
|
files = sorted(glob.glob('configs/*.yaml'))
|
|
print(f'Memvalidasi {len(files)} berkas konfigurasi...')
|
|
for f in files:
|
|
try:
|
|
data = yaml.safe_load(open(f))
|
|
pid = data.get('pipeline_id', 'UNKNOWN')
|
|
print(f' ✓ {f} -> Pipeline ID: {pid} (VALID)')
|
|
except Exception as e:
|
|
print(f' ✗ ERROR pada {f}: {e}', file=sys.stderr)
|
|
sys.exit(1)
|
|
print('Seluruh konfigurasi YAML valid 100%!')
|
|
"
|
|
```
|
|
|
|
### B. Validasi Keberadaan 4 Pipeline Produksi Kanonikal
|
|
```bash
|
|
python3 -c "
|
|
import glob, yaml, sys
|
|
expected = {
|
|
'example_permits_medallion_dbt_postgres',
|
|
'ingestion_db_environmental_permits_cdc',
|
|
'ingestion_gws_waste_reports',
|
|
'ingestion_api_spku_air_quality'
|
|
}
|
|
actual = {yaml.safe_load(open(f)).get('pipeline_id') for f in glob.glob('configs/*.yaml')}
|
|
diff = actual - expected
|
|
if diff:
|
|
print(f'PERINGATAN: Ditemukan pipeline non-standar: {diff}', file=sys.stderr)
|
|
sys.exit(1)
|
|
missing = expected - actual
|
|
if missing:
|
|
print(f'PERINGATAN: Pipeline kanonikal hilang: {missing}', file=sys.stderr)
|
|
sys.exit(1)
|
|
print(f'Audit Integritas Aset Sukses: Tepat 4 pipeline kanonikal terdaftar ({len(actual)}/4).')
|
|
"
|
|
```
|
|
|
|
### C. Validasi Model dbt SQL
|
|
```bash
|
|
# Periksa keberadaan 4 model Silver dan 4 model Gold
|
|
ls -la dbt/models/silver/*.sql
|
|
ls -la dbt/models/gold/*.sql
|
|
```
|
|
|
|
---
|
|
|
|
## 🛡️ 3. Kebijakan Integritas Pipeline Produksi
|
|
|
|
Repositori produksi ini diaudit ketat terhadap aturan standarisasi aset:
|
|
* Dilarang menempatkan file konfigurasi dengan penamaan ad-hoc atau sementara.
|
|
* Seluruh pipeline harus memiliki identitas semantik yang mencerminkan fungsi bisnis:
|
|
* `example_permits_medallion_dbt_postgres.yaml`
|
|
* `ingestion_db_environmental_permits_cdc.yaml`
|
|
* `ingestion_gws_waste_reports.yaml`
|
|
* `ingestion_api_spku_air_quality.yaml`
|
|
|
|
---
|
|
|
|
## 🔄 4. Verifikasi End-to-End dengan Airflow 3 `GitDagBundle`
|
|
|
|
Saat perubahan di-push ke remote Git:
|
|
1. Airflow 3 DAG Processor akan menarik pembaruan dalam interval maksimal 30 detik.
|
|
2. Buka dashboard Airflow di `http://<airflow-host>:8088`.
|
|
3. Pastikan DAG baru muncul di daftar DAGs dengan bundle tag `dlh-pipeline-bundle`.
|
|
4. Periksa log DAG Processor untuk memastikan tidak ada pesan *Import Error*:
|
|
```bash
|
|
docker compose logs --tail=50 airflow-dag-processor | grep -i "error"
|
|
```
|
|
|
|
---
|
|
|
|
## 📚 5. Referensi Terkait
|
|
|
|
* 🧪 [Dokumen 41: Panduan & Laporan Pengujian Riil E2E](file:///mnt/c/project/bpkp/dlh/tech/docs/41_panduan_dan_laporan_pengujian_riil_e2e_merica_beta_dan_pipeline_bundles.md)
|
|
* 📋 [RELEASE_NOTES.md](file:///mnt/c/project/bpkp/dlh/tech/merica-pipeline-bundles/RELEASE_NOTES.md)
|