feat: Add comprehensive testing plan for IPSExtractor, including unit, integration, E2E, stress, and resilience tests. Introduce LaTeX documentation structure with sections for architecture, test strategy, and execution guidelines. Enhance README with setup instructions and k6 stress testing scripts.

This commit is contained in:
erik
2026-07-13 17:45:39 -05:00
parent 103bcea15b
commit 6bf413c4ce
25 changed files with 1662 additions and 0 deletions
@@ -0,0 +1,56 @@
\chapter{Arquitectura bajo prueba}
\label{ch:arquitectura}
\section{Vista de componentes}
El host solo expone el Gateway en el puerto \textbf{8189}. El resto de APIs viven en la red Docker. El agent del bot corre en PCs externas y se comunica por HTTP + PutObject a MinIO.
\input{diagrams/arquitectura}
\section{Inventario de componentes}
\begin{table}[ht]
\centering
\begin{tabular}{@{}llp{5.8cm}@{}}
\toprule
\textbf{Componente} & \textbf{Puerto} & \textbf{Responsabilidad} \\
\midrule
\texttt{api\_gateway} & Host 8189 & Proxy HTTP, health agregado, CORS \\
\texttt{extraction} & 8001 & Jobs/tasks, LLM, ingest PDFs \\
\texttt{worker} (ARQ) & --- & Procesamiento async v\'ia Redis \\
\texttt{cleaning} & 8002 & Limpieza CSV / reglas \\
\texttt{count-api} & 8080 & OCR + ONNX, stateless \\
\texttt{bot-descarga} & 8200 & Control remoto de bots \\
PostgreSQL 16 & 5432 & Persistencia compartida \\
Redis 7 & 6379 & Cola ARQ + rate limiter \\
Desktop & local & Cliente Electron/React \\
Agent bot & local PC & Selenium + MinIO upload \\
MinIO/S3 & externo & Excel y PDFs del bot \\
\bottomrule
\end{tabular}
\caption{Componentes del sistema bajo prueba.}
\end{table}
\section{Flujo cr\'itico: bot de descarga}
\input{diagrams/flujo_bot}
Secuencia resumida:
\begin{enumerate}
\item Agent: \texttt{register} + loop \texttt{heartbeat} / \texttt{claim\_pending} ($\sim$8\,s).
\item Desktop: \texttt{POST /bot-descarga/jobs} (Excel, \texttt{worker\_id}, \texttt{job\_id}).
\item API: valida job padre y worker online; sube Excel a MinIO; estado \texttt{pending}.
\item Agent: claim $\rightarrow$ \texttt{RUNNING}; descarga Excel; Selenium/Imaging; PutObject PDFs.
\item Eventos \texttt{POST /events}; cierre \texttt{PATCH /jobs/\{id\}} (\texttt{completed}/\texttt{failed}).
\end{enumerate}
Layout MinIO:
\begin{lstlisting}[language={},caption={Prefijos MinIO del bot}]
uploads/{download_job_id}/input.xlsx
downloads/{download_job_id}/{nit}/{radicado}.pdf
downloads/{download_job_id}/_manifest.json
\end{lstlisting}
\section{Otros flujos de negocio}
\begin{description}
\item[Conteo] Desktop $\rightarrow$ \texttt{POST /count/v1/count} $\rightarrow$ \texttt{POST /count-jobs} $\rightarrow$ validaci\'on humana.
\item[Extracci\'on] \texttt{from-count} o ingest de PDFs $\rightarrow$ workers ARQ $\rightarrow$ filas en BD.
\item[Limpieza] Job cleaning desde \texttt{extraction\_batch\_id} o CSV upload.
\end{description}