1247 lines
48 KiB
HTML
1247 lines
48 KiB
HTML
|
|
<!DOCTYPE HTML>
|
||
|
|
<html lang="en" class="ayu sidebar-visible" dir="ltr">
|
||
|
|
<head>
|
||
|
|
<!-- Book generated using mdBook -->
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<title>Test Environment Usage - Provisioning Platform Documentation</title>
|
||
|
|
|
||
|
|
|
||
|
|
<!-- Custom HTML head -->
|
||
|
|
|
||
|
|
<meta name="description" content="Complete documentation for the Provisioning Platform - Infrastructure automation with Nushell, KCL, and Rust">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
|
|
<meta name="theme-color" content="#ffffff">
|
||
|
|
|
||
|
|
<link rel="icon" href="../favicon.svg">
|
||
|
|
<link rel="shortcut icon" href="../favicon.png">
|
||
|
|
<link rel="stylesheet" href="../css/variables.css">
|
||
|
|
<link rel="stylesheet" href="../css/general.css">
|
||
|
|
<link rel="stylesheet" href="../css/chrome.css">
|
||
|
|
<link rel="stylesheet" href="../css/print.css" media="print">
|
||
|
|
|
||
|
|
<!-- Fonts -->
|
||
|
|
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
|
||
|
|
<link rel="stylesheet" href="../fonts/fonts.css">
|
||
|
|
|
||
|
|
<!-- Highlight.js Stylesheets -->
|
||
|
|
<link rel="stylesheet" id="highlight-css" href="../highlight.css">
|
||
|
|
<link rel="stylesheet" id="tomorrow-night-css" href="../tomorrow-night.css">
|
||
|
|
<link rel="stylesheet" id="ayu-highlight-css" href="../ayu-highlight.css">
|
||
|
|
|
||
|
|
<!-- Custom theme stylesheets -->
|
||
|
|
|
||
|
|
|
||
|
|
<!-- Provide site root and default themes to javascript -->
|
||
|
|
<script>
|
||
|
|
const path_to_root = "../";
|
||
|
|
const default_light_theme = "ayu";
|
||
|
|
const default_dark_theme = "navy";
|
||
|
|
</script>
|
||
|
|
<!-- Start loading toc.js asap -->
|
||
|
|
<script src="../toc.js"></script>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div id="mdbook-help-container">
|
||
|
|
<div id="mdbook-help-popup">
|
||
|
|
<h2 class="mdbook-help-title">Keyboard shortcuts</h2>
|
||
|
|
<div>
|
||
|
|
<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>
|
||
|
|
<p>Press <kbd>S</kbd> or <kbd>/</kbd> to search in the book</p>
|
||
|
|
<p>Press <kbd>?</kbd> to show this help</p>
|
||
|
|
<p>Press <kbd>Esc</kbd> to hide this help</p>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div id="body-container">
|
||
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
||
|
|
<script>
|
||
|
|
try {
|
||
|
|
let theme = localStorage.getItem('mdbook-theme');
|
||
|
|
let sidebar = localStorage.getItem('mdbook-sidebar');
|
||
|
|
|
||
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
||
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
||
|
|
}
|
||
|
|
|
||
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
||
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
||
|
|
}
|
||
|
|
} catch (e) { }
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
||
|
|
<script>
|
||
|
|
const default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? default_dark_theme : default_light_theme;
|
||
|
|
let theme;
|
||
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
||
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
||
|
|
const html = document.documentElement;
|
||
|
|
html.classList.remove('ayu')
|
||
|
|
html.classList.add(theme);
|
||
|
|
html.classList.add("js");
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
||
|
|
|
||
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
||
|
|
<script>
|
||
|
|
let sidebar = null;
|
||
|
|
const sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
||
|
|
if (document.body.clientWidth >= 1080) {
|
||
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
||
|
|
sidebar = sidebar || 'visible';
|
||
|
|
} else {
|
||
|
|
sidebar = 'hidden';
|
||
|
|
}
|
||
|
|
sidebar_toggle.checked = sidebar === 'visible';
|
||
|
|
html.classList.remove('sidebar-visible');
|
||
|
|
html.classList.add("sidebar-" + sidebar);
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
||
|
|
<!-- populated by js -->
|
||
|
|
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
||
|
|
<noscript>
|
||
|
|
<iframe class="sidebar-iframe-outer" src="../toc.html"></iframe>
|
||
|
|
</noscript>
|
||
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
||
|
|
<div class="sidebar-resize-indicator"></div>
|
||
|
|
</div>
|
||
|
|
</nav>
|
||
|
|
|
||
|
|
<div id="page-wrapper" class="page-wrapper">
|
||
|
|
|
||
|
|
<div class="page">
|
||
|
|
<div id="menu-bar-hover-placeholder"></div>
|
||
|
|
<div id="menu-bar" class="menu-bar sticky">
|
||
|
|
<div class="left-buttons">
|
||
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
||
|
|
<i class="fa fa-bars"></i>
|
||
|
|
</label>
|
||
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
||
|
|
<i class="fa fa-paint-brush"></i>
|
||
|
|
</button>
|
||
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="default_theme">Auto</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
||
|
|
</ul>
|
||
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search (`/`)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="/ s" aria-controls="searchbar">
|
||
|
|
<i class="fa fa-search"></i>
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<h1 class="menu-title">Provisioning Platform Documentation</h1>
|
||
|
|
|
||
|
|
<div class="right-buttons">
|
||
|
|
<a href="../print.html" title="Print this book" aria-label="Print this book">
|
||
|
|
<i id="print-button" class="fa fa-print"></i>
|
||
|
|
</a>
|
||
|
|
<a href="https://github.com/provisioning/provisioning-platform" title="Git repository" aria-label="Git repository">
|
||
|
|
<i id="git-repository-button" class="fa fa-github"></i>
|
||
|
|
</a>
|
||
|
|
<a href="https://github.com/provisioning/provisioning-platform/edit/main/provisioning/docs/src/user/test-environment-usage.md" title="Suggest an edit" aria-label="Suggest an edit">
|
||
|
|
<i id="git-edit-button" class="fa fa-edit"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="search-wrapper" class="hidden">
|
||
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
||
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
||
|
|
</form>
|
||
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
||
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
||
|
|
<ul id="searchresults">
|
||
|
|
</ul>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
||
|
|
<script>
|
||
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
||
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
||
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
||
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<div id="content" class="content">
|
||
|
|
<main>
|
||
|
|
<h1 id="test-environment-service---guía-completa-de-uso"><a class="header" href="#test-environment-service---guía-completa-de-uso">Test Environment Service - Guía Completa de Uso</a></h1>
|
||
|
|
<p><strong>Versión</strong>: 1.0.0
|
||
|
|
<strong>Fecha</strong>: 2025-10-06
|
||
|
|
<strong>Estado</strong>: Producción</p>
|
||
|
|
<hr />
|
||
|
|
<h2 id="Índice"><a class="header" href="#Índice">Índice</a></h2>
|
||
|
|
<ol>
|
||
|
|
<li><a href="#introducci%C3%B3n">Introducción</a></li>
|
||
|
|
<li><a href="#requerimientos">Requerimientos</a></li>
|
||
|
|
<li><a href="#configuraci%C3%B3n-inicial">Configuración Inicial</a></li>
|
||
|
|
<li><a href="#gu%C3%ADa-de-uso-r%C3%A1pido">Guía de Uso Rápido</a></li>
|
||
|
|
<li><a href="#tipos-de-entornos">Tipos de Entornos</a></li>
|
||
|
|
<li><a href="#comandos-detallados">Comandos Detallados</a></li>
|
||
|
|
<li><a href="#topolog%C3%ADas-y-templates">Topologías y Templates</a></li>
|
||
|
|
<li><a href="#casos-de-uso-pr%C3%A1cticos">Casos de Uso Prácticos</a></li>
|
||
|
|
<li><a href="#integraci%C3%B3n-cicd">Integración CI/CD</a></li>
|
||
|
|
<li><a href="#troubleshooting">Troubleshooting</a></li>
|
||
|
|
</ol>
|
||
|
|
<hr />
|
||
|
|
<h2 id="introducción"><a class="header" href="#introducción">Introducción</a></h2>
|
||
|
|
<p>El <strong>Test Environment Service</strong> es un sistema de testing containerizado integrado en el orquestador que permite probar:</p>
|
||
|
|
<ul>
|
||
|
|
<li>✅ <strong>Taskservs individuales</strong> - Test aislado de un servicio</li>
|
||
|
|
<li>✅ <strong>Servidores completos</strong> - Simulación de servidor con múltiples taskservs</li>
|
||
|
|
<li>✅ <strong>Clusters multi-nodo</strong> - Topologías distribuidas (Kubernetes, etcd, etc.)</li>
|
||
|
|
</ul>
|
||
|
|
<h3 id="por-qué-usar-test-environments"><a class="header" href="#por-qué-usar-test-environments">¿Por qué usar Test Environments?</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li><strong>Sin gestión manual de Docker</strong> - Todo automatizado</li>
|
||
|
|
<li><strong>Entornos aislados</strong> - Redes dedicadas, sin interferencias</li>
|
||
|
|
<li><strong>Realista</strong> - Simula configuraciones de producción</li>
|
||
|
|
<li><strong>Rápido</strong> - Un comando para crear, probar y limpiar</li>
|
||
|
|
<li><strong>CI/CD Ready</strong> - Fácil integración en pipelines</li>
|
||
|
|
</ul>
|
||
|
|
<hr />
|
||
|
|
<h2 id="requerimientos"><a class="header" href="#requerimientos">Requerimientos</a></h2>
|
||
|
|
<h3 id="obligatorios"><a class="header" href="#obligatorios">Obligatorios</a></h3>
|
||
|
|
<h4 id="1-docker"><a class="header" href="#1-docker">1. Docker</a></h4>
|
||
|
|
<p><strong>Versión mínima</strong>: Docker 20.10+</p>
|
||
|
|
<pre><code class="language-bash"># Verificar instalación
|
||
|
|
docker --version
|
||
|
|
|
||
|
|
# Verificar que funciona
|
||
|
|
docker ps
|
||
|
|
|
||
|
|
# Verificar recursos disponibles
|
||
|
|
docker info | grep -E "CPUs|Total Memory"
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Instalación según OS:</strong></p>
|
||
|
|
<p><strong>macOS:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Opción 1: Docker Desktop
|
||
|
|
brew install --cask docker
|
||
|
|
|
||
|
|
# Opción 2: OrbStack (más ligero)
|
||
|
|
brew install orbstack
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Linux (Ubuntu/Debian):</strong></p>
|
||
|
|
<pre><code class="language-bash"># Instalar Docker
|
||
|
|
curl -fsSL https://get.docker.com -o get-docker.sh
|
||
|
|
sudo sh get-docker.sh
|
||
|
|
|
||
|
|
# Añadir usuario al grupo docker
|
||
|
|
sudo usermod -aG docker $USER
|
||
|
|
newgrp docker
|
||
|
|
|
||
|
|
# Verificar
|
||
|
|
docker ps
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Linux (Fedora):</strong></p>
|
||
|
|
<pre><code class="language-bash">sudo dnf install docker
|
||
|
|
sudo systemctl enable --now docker
|
||
|
|
sudo usermod -aG docker $USER
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="2-orchestrator"><a class="header" href="#2-orchestrator">2. Orchestrator</a></h4>
|
||
|
|
<p><strong>Puerto por defecto</strong>: 8080</p>
|
||
|
|
<pre><code class="language-bash"># Verificar que el orquestador está corriendo
|
||
|
|
curl http://localhost:9090/health
|
||
|
|
|
||
|
|
# Si no está corriendo, iniciarlo
|
||
|
|
cd provisioning/platform/orchestrator
|
||
|
|
./scripts/start-orchestrator.nu --background
|
||
|
|
|
||
|
|
# Verificar logs
|
||
|
|
tail -f ./data/orchestrator.log
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="3-nushell"><a class="header" href="#3-nushell">3. Nushell</a></h4>
|
||
|
|
<p><strong>Versión mínima</strong>: 0.107.1+</p>
|
||
|
|
<pre><code class="language-bash"># Verificar versión
|
||
|
|
nu --version
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="recursos-recomendados"><a class="header" href="#recursos-recomendados">Recursos Recomendados</a></h3>
|
||
|
|
<div class="table-wrapper"><table><thead><tr><th>Tipo de Test</th><th>CPU</th><th>Memoria</th><th>Disk</th></tr></thead><tbody>
|
||
|
|
<tr><td>Single taskserv</td><td>2 cores</td><td>4 GB</td><td>10 GB</td></tr>
|
||
|
|
<tr><td>Server simulation</td><td>4 cores</td><td>8 GB</td><td>20 GB</td></tr>
|
||
|
|
<tr><td>Cluster 3-nodos</td><td>8 cores</td><td>16 GB</td><td>40 GB</td></tr>
|
||
|
|
</tbody></table>
|
||
|
|
</div>
|
||
|
|
<p><strong>Verificar recursos disponibles:</strong></p>
|
||
|
|
<pre><code class="language-bash"># En el sistema
|
||
|
|
docker info | grep -E "CPUs|Total Memory"
|
||
|
|
|
||
|
|
# Recursos usados actualmente
|
||
|
|
docker stats --no-stream
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="opcional-pero-recomendado"><a class="header" href="#opcional-pero-recomendado">Opcional pero Recomendado</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li><strong>jq</strong> - Para procesar JSON: <code>brew install jq</code> / <code>apt install jq</code></li>
|
||
|
|
<li><strong>glow</strong> - Para visualizar docs: <code>brew install glow</code></li>
|
||
|
|
<li><strong>k9s</strong> - Para gestionar K8s tests: <code>brew install k9s</code></li>
|
||
|
|
</ul>
|
||
|
|
<hr />
|
||
|
|
<h2 id="configuración-inicial"><a class="header" href="#configuración-inicial">Configuración Inicial</a></h2>
|
||
|
|
<h3 id="1-iniciar-el-orquestador"><a class="header" href="#1-iniciar-el-orquestador">1. Iniciar el Orquestador</a></h3>
|
||
|
|
<pre><code class="language-bash"># Navegar al directorio del orquestador
|
||
|
|
cd provisioning/platform/orchestrator
|
||
|
|
|
||
|
|
# Opción 1: Iniciar en background (recomendado)
|
||
|
|
./scripts/start-orchestrator.nu --background
|
||
|
|
|
||
|
|
# Opción 2: Iniciar en foreground (para debug)
|
||
|
|
cargo run --release
|
||
|
|
|
||
|
|
# Verificar que está corriendo
|
||
|
|
curl http://localhost:9090/health
|
||
|
|
# Respuesta esperada: {"success":true,"data":"Orchestrator is healthy"}
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="2-verificar-docker"><a class="header" href="#2-verificar-docker">2. Verificar Docker</a></h3>
|
||
|
|
<pre><code class="language-bash"># Test básico de Docker
|
||
|
|
docker run --rm hello-world
|
||
|
|
|
||
|
|
# Verificar que hay imágenes base (se descargan automáticamente)
|
||
|
|
docker images | grep ubuntu
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="3-configurar-variables-de-entorno-opcional"><a class="header" href="#3-configurar-variables-de-entorno-opcional">3. Configurar Variables de Entorno (opcional)</a></h3>
|
||
|
|
<pre><code class="language-bash"># Añadir a tu ~/.bashrc o ~/.zshrc
|
||
|
|
export PROVISIONING_ORCHESTRATOR="http://localhost:9090"
|
||
|
|
export PROVISIONING_PATH="/ruta/a/provisioning"
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="4-verificar-instalación"><a class="header" href="#4-verificar-instalación">4. Verificar Instalación</a></h3>
|
||
|
|
<pre><code class="language-bash"># Test completo del sistema
|
||
|
|
provisioning test quick redis
|
||
|
|
|
||
|
|
# Debe mostrar:
|
||
|
|
# 🧪 Quick test for redis
|
||
|
|
# ✅ Environment ready, running tests...
|
||
|
|
# ✅ Quick test completed
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="guía-de-uso-rápido"><a class="header" href="#guía-de-uso-rápido">Guía de Uso Rápido</a></h2>
|
||
|
|
<h3 id="test-rápido-recomendado-para-empezar"><a class="header" href="#test-rápido-recomendado-para-empezar">Test Rápido (Recomendado para empezar)</a></h3>
|
||
|
|
<pre><code class="language-bash"># Un solo comando: crea, prueba, limpia
|
||
|
|
provisioning test quick <taskserv>
|
||
|
|
|
||
|
|
# Ejemplos
|
||
|
|
provisioning test quick kubernetes
|
||
|
|
provisioning test quick postgres
|
||
|
|
provisioning test quick redis
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="flujo-completo-paso-a-paso"><a class="header" href="#flujo-completo-paso-a-paso">Flujo Completo Paso a Paso</a></h3>
|
||
|
|
<pre><code class="language-bash"># 1. Crear entorno
|
||
|
|
provisioning test env single kubernetes --auto-start
|
||
|
|
|
||
|
|
# Retorna: environment_id = "abc-123-def-456"
|
||
|
|
|
||
|
|
# 2. Listar entornos
|
||
|
|
provisioning test env list
|
||
|
|
|
||
|
|
# 3. Ver status
|
||
|
|
provisioning test env status abc-123-def-456
|
||
|
|
|
||
|
|
# 4. Ver logs
|
||
|
|
provisioning test env logs abc-123-def-456
|
||
|
|
|
||
|
|
# 5. Limpiar
|
||
|
|
provisioning test env cleanup abc-123-def-456
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="con-auto-cleanup"><a class="header" href="#con-auto-cleanup">Con Auto-Cleanup</a></h3>
|
||
|
|
<pre><code class="language-bash"># Se limpia automáticamente al terminar
|
||
|
|
provisioning test env single redis \
|
||
|
|
--auto-start \
|
||
|
|
--auto-cleanup
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="tipos-de-entornos"><a class="header" href="#tipos-de-entornos">Tipos de Entornos</a></h2>
|
||
|
|
<h3 id="1-single-taskserv"><a class="header" href="#1-single-taskserv">1. Single Taskserv</a></h3>
|
||
|
|
<p>Test de un solo taskserv en container aislado.</p>
|
||
|
|
<p><strong>Cuándo usar:</strong></p>
|
||
|
|
<ul>
|
||
|
|
<li>Desarrollo de nuevo taskserv</li>
|
||
|
|
<li>Validación de configuración</li>
|
||
|
|
<li>Debug de problemas específicos</li>
|
||
|
|
</ul>
|
||
|
|
<p><strong>Comando:</strong></p>
|
||
|
|
<pre><code class="language-bash">provisioning test env single <taskserv> [opciones]
|
||
|
|
|
||
|
|
# Opciones
|
||
|
|
--cpu <millicores> # Default: 1000 (1 core)
|
||
|
|
--memory <MB> # Default: 2048 (2GB)
|
||
|
|
--base-image <imagen> # Default: ubuntu:22.04
|
||
|
|
--infra <nombre> # Contexto de infraestructura
|
||
|
|
--auto-start # Ejecutar tests automáticamente
|
||
|
|
--auto-cleanup # Limpiar al terminar
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Ejemplos:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Test básico
|
||
|
|
provisioning test env single kubernetes
|
||
|
|
|
||
|
|
# Con más recursos
|
||
|
|
provisioning test env single postgres --cpu 4000 --memory 8192
|
||
|
|
|
||
|
|
# Test completo automatizado
|
||
|
|
provisioning test env single redis --auto-start --auto-cleanup
|
||
|
|
|
||
|
|
# Con contexto de infra
|
||
|
|
provisioning test env single cilium --infra prod-cluster
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="2-server-simulation"><a class="header" href="#2-server-simulation">2. Server Simulation</a></h3>
|
||
|
|
<p>Simula servidor completo con múltiples taskservs.</p>
|
||
|
|
<p><strong>Cuándo usar:</strong></p>
|
||
|
|
<ul>
|
||
|
|
<li>Test de integración entre taskservs</li>
|
||
|
|
<li>Validar dependencias</li>
|
||
|
|
<li>Simular servidor de producción</li>
|
||
|
|
</ul>
|
||
|
|
<p><strong>Comando:</strong></p>
|
||
|
|
<pre><code class="language-bash">provisioning test env server <nombre> <taskservs> [opciones]
|
||
|
|
|
||
|
|
# taskservs: lista entre corchetes [ts1 ts2 ts3]
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Ejemplos:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Server con stack de aplicación
|
||
|
|
provisioning test env server app-01 [containerd kubernetes cilium]
|
||
|
|
|
||
|
|
# Server de base de datos
|
||
|
|
provisioning test env server db-01 [postgres redis]
|
||
|
|
|
||
|
|
# Con auto-resolución de dependencias
|
||
|
|
provisioning test env server web-01 [kubernetes] --auto-start
|
||
|
|
# Automáticamente incluye: containerd, etcd (dependencias de k8s)
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="3-cluster-topology"><a class="header" href="#3-cluster-topology">3. Cluster Topology</a></h3>
|
||
|
|
<p>Cluster multi-nodo con topología definida.</p>
|
||
|
|
<p><strong>Cuándo usar:</strong></p>
|
||
|
|
<ul>
|
||
|
|
<li>Test de clusters distribuidos</li>
|
||
|
|
<li>Validar HA (High Availability)</li>
|
||
|
|
<li>Test de failover</li>
|
||
|
|
<li>Simular producción real</li>
|
||
|
|
</ul>
|
||
|
|
<p><strong>Comando:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Desde template predefinido
|
||
|
|
provisioning test topology load <template> | test env cluster <tipo> [opciones]
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Ejemplos:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Cluster Kubernetes 3 nodos (1 CP + 2 workers)
|
||
|
|
provisioning test topology load kubernetes_3node | \
|
||
|
|
test env cluster kubernetes --auto-start
|
||
|
|
|
||
|
|
# Cluster etcd 3 miembros
|
||
|
|
provisioning test topology load etcd_cluster | \
|
||
|
|
test env cluster etcd
|
||
|
|
|
||
|
|
# Cluster K8s single-node
|
||
|
|
provisioning test topology load kubernetes_single | \
|
||
|
|
test env cluster kubernetes
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="comandos-detallados"><a class="header" href="#comandos-detallados">Comandos Detallados</a></h2>
|
||
|
|
<h3 id="gestión-de-entornos"><a class="header" href="#gestión-de-entornos">Gestión de Entornos</a></h3>
|
||
|
|
<h4 id="test-env-create"><a class="header" href="#test-env-create"><code>test env create</code></a></h4>
|
||
|
|
<p>Crear entorno desde configuración custom.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test env create <config> [opciones]
|
||
|
|
|
||
|
|
# Opciones
|
||
|
|
--infra <nombre> # Infraestructura context
|
||
|
|
--auto-start # Iniciar tests automáticamente
|
||
|
|
--auto-cleanup # Limpiar al finalizar
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="test-env-list"><a class="header" href="#test-env-list"><code>test env list</code></a></h4>
|
||
|
|
<p>Listar todos los entornos activos.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test env list
|
||
|
|
|
||
|
|
# Salida ejemplo:
|
||
|
|
# id env_type status containers
|
||
|
|
# abc-123 single_taskserv ready 1
|
||
|
|
# def-456 cluster_topology running 3
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="test-env-get"><a class="header" href="#test-env-get"><code>test env get</code></a></h4>
|
||
|
|
<p>Obtener detalles completos de un entorno.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test env get <env-id>
|
||
|
|
|
||
|
|
# Retorna JSON con:
|
||
|
|
# - Configuración completa
|
||
|
|
# - Estados de containers
|
||
|
|
# - IPs asignadas
|
||
|
|
# - Resultados de tests
|
||
|
|
# - Logs
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="test-env-status"><a class="header" href="#test-env-status"><code>test env status</code></a></h4>
|
||
|
|
<p>Ver status resumido de un entorno.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test env status <env-id>
|
||
|
|
|
||
|
|
# Muestra:
|
||
|
|
# - ID y tipo
|
||
|
|
# - Status actual
|
||
|
|
# - Containers y sus IPs
|
||
|
|
# - Resultados de tests
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="test-env-run"><a class="header" href="#test-env-run"><code>test env run</code></a></h4>
|
||
|
|
<p>Ejecutar tests en un entorno.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test env run <env-id> [opciones]
|
||
|
|
|
||
|
|
# Opciones
|
||
|
|
--tests [test1 test2] # Tests específicos (default: todos)
|
||
|
|
--timeout <segundos> # Timeout para tests
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Ejemplo:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Ejecutar todos los tests
|
||
|
|
provisioning test env run abc-123
|
||
|
|
|
||
|
|
# Tests específicos
|
||
|
|
provisioning test env run abc-123 --tests [connectivity health]
|
||
|
|
|
||
|
|
# Con timeout
|
||
|
|
provisioning test env run abc-123 --timeout 300
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="test-env-logs"><a class="header" href="#test-env-logs"><code>test env logs</code></a></h4>
|
||
|
|
<p>Ver logs del entorno.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test env logs <env-id>
|
||
|
|
|
||
|
|
# Muestra:
|
||
|
|
# - Logs de creación
|
||
|
|
# - Logs de containers
|
||
|
|
# - Logs de tests
|
||
|
|
# - Errores si los hay
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="test-env-cleanup"><a class="header" href="#test-env-cleanup"><code>test env cleanup</code></a></h4>
|
||
|
|
<p>Limpiar y destruir entorno.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test env cleanup <env-id>
|
||
|
|
|
||
|
|
# Elimina:
|
||
|
|
# - Containers
|
||
|
|
# - Red dedicada
|
||
|
|
# - Volúmenes
|
||
|
|
# - Estado del orquestador
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="topologías"><a class="header" href="#topologías">Topologías</a></h3>
|
||
|
|
<h4 id="test-topology-list"><a class="header" href="#test-topology-list"><code>test topology list</code></a></h4>
|
||
|
|
<p>Listar templates disponibles.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test topology list
|
||
|
|
|
||
|
|
# Salida:
|
||
|
|
# name
|
||
|
|
# kubernetes_3node
|
||
|
|
# kubernetes_single
|
||
|
|
# etcd_cluster
|
||
|
|
# containerd_test
|
||
|
|
# postgres_redis
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="test-topology-load"><a class="header" href="#test-topology-load"><code>test topology load</code></a></h4>
|
||
|
|
<p>Cargar configuración de template.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test topology load <nombre>
|
||
|
|
|
||
|
|
# Retorna configuración JSON/TOML
|
||
|
|
# Se puede usar con pipe para crear cluster
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="quick-test"><a class="header" href="#quick-test">Quick Test</a></h3>
|
||
|
|
<h4 id="test-quick"><a class="header" href="#test-quick"><code>test quick</code></a></h4>
|
||
|
|
<p>Test rápido todo-en-uno.</p>
|
||
|
|
<pre><code class="language-bash">provisioning test quick <taskserv> [opciones]
|
||
|
|
|
||
|
|
# Hace:
|
||
|
|
# 1. Crea entorno single taskserv
|
||
|
|
# 2. Ejecuta tests
|
||
|
|
# 3. Muestra resultados
|
||
|
|
# 4. Limpia automáticamente
|
||
|
|
|
||
|
|
# Opciones
|
||
|
|
--infra <nombre> # Contexto de infraestructura
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Ejemplos:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Test rápido de kubernetes
|
||
|
|
provisioning test quick kubernetes
|
||
|
|
|
||
|
|
# Con contexto
|
||
|
|
provisioning test quick postgres --infra prod-db
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="topologías-y-templates"><a class="header" href="#topologías-y-templates">Topologías y Templates</a></h2>
|
||
|
|
<h3 id="templates-predefinidos"><a class="header" href="#templates-predefinidos">Templates Predefinidos</a></h3>
|
||
|
|
<p>El sistema incluye 5 templates listos para usar:</p>
|
||
|
|
<h4 id="1-kubernetes_3node---cluster-k8s-ha"><a class="header" href="#1-kubernetes_3node---cluster-k8s-ha">1. <strong>kubernetes_3node</strong> - Cluster K8s HA</a></h4>
|
||
|
|
<pre><code class="language-bash"># Configuración:
|
||
|
|
# - 1 Control Plane: etcd, kubernetes, containerd (2 cores, 4GB)
|
||
|
|
# - 2 Workers: kubernetes, containerd, cilium (2 cores, 2GB cada uno)
|
||
|
|
# - Red: 172.20.0.0/16
|
||
|
|
|
||
|
|
# Uso:
|
||
|
|
provisioning test topology load kubernetes_3node | \
|
||
|
|
test env cluster kubernetes --auto-start
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="2-kubernetes_single---k8s-all-in-one"><a class="header" href="#2-kubernetes_single---k8s-all-in-one">2. <strong>kubernetes_single</strong> - K8s All-in-One</a></h4>
|
||
|
|
<pre><code class="language-bash"># Configuración:
|
||
|
|
# - 1 Nodo: etcd, kubernetes, containerd, cilium (4 cores, 8GB)
|
||
|
|
# - Red: 172.22.0.0/16
|
||
|
|
|
||
|
|
# Uso:
|
||
|
|
provisioning test topology load kubernetes_single | \
|
||
|
|
test env cluster kubernetes
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="3-etcd_cluster---cluster-etcd"><a class="header" href="#3-etcd_cluster---cluster-etcd">3. <strong>etcd_cluster</strong> - Cluster etcd</a></h4>
|
||
|
|
<pre><code class="language-bash"># Configuración:
|
||
|
|
# - 3 Miembros etcd (1 core, 1GB cada uno)
|
||
|
|
# - Red: 172.21.0.0/16
|
||
|
|
# - Cluster configurado automáticamente
|
||
|
|
|
||
|
|
# Uso:
|
||
|
|
provisioning test topology load etcd_cluster | \
|
||
|
|
test env cluster etcd --auto-start
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="4-containerd_test---containerd-standalone"><a class="header" href="#4-containerd_test---containerd-standalone">4. <strong>containerd_test</strong> - Containerd standalone</a></h4>
|
||
|
|
<pre><code class="language-bash"># Configuración:
|
||
|
|
# - 1 Nodo: containerd (1 core, 2GB)
|
||
|
|
# - Red: 172.23.0.0/16
|
||
|
|
|
||
|
|
# Uso:
|
||
|
|
provisioning test topology load containerd_test | \
|
||
|
|
test env cluster containerd
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="5-postgres_redis---stack-de-dbs"><a class="header" href="#5-postgres_redis---stack-de-dbs">5. <strong>postgres_redis</strong> - Stack de DBs</a></h4>
|
||
|
|
<pre><code class="language-bash"># Configuración:
|
||
|
|
# - 1 PostgreSQL: (2 cores, 4GB)
|
||
|
|
# - 1 Redis: (1 core, 1GB)
|
||
|
|
# - Red: 172.24.0.0/16
|
||
|
|
|
||
|
|
# Uso:
|
||
|
|
provisioning test topology load postgres_redis | \
|
||
|
|
test env cluster databases --auto-start
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="crear-template-custom"><a class="header" href="#crear-template-custom">Crear Template Custom</a></h3>
|
||
|
|
<ol>
|
||
|
|
<li><strong>Crear archivo TOML:</strong></li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-toml"># /path/to/my-topology.toml
|
||
|
|
|
||
|
|
[mi_cluster]
|
||
|
|
name = "Mi Cluster Custom"
|
||
|
|
description = "Descripción del cluster"
|
||
|
|
cluster_type = "custom"
|
||
|
|
|
||
|
|
[[mi_cluster.nodes]]
|
||
|
|
name = "node-01"
|
||
|
|
role = "primary"
|
||
|
|
taskservs = ["postgres", "redis"]
|
||
|
|
[mi_cluster.nodes.resources]
|
||
|
|
cpu_millicores = 2000
|
||
|
|
memory_mb = 4096
|
||
|
|
[mi_cluster.nodes.environment]
|
||
|
|
POSTGRES_PASSWORD = "secret"
|
||
|
|
|
||
|
|
[[mi_cluster.nodes]]
|
||
|
|
name = "node-02"
|
||
|
|
role = "replica"
|
||
|
|
taskservs = ["postgres"]
|
||
|
|
[mi_cluster.nodes.resources]
|
||
|
|
cpu_millicores = 1000
|
||
|
|
memory_mb = 2048
|
||
|
|
|
||
|
|
[mi_cluster.network]
|
||
|
|
subnet = "172.30.0.0/16"
|
||
|
|
dns_enabled = true
|
||
|
|
</code></pre>
|
||
|
|
<ol start="2">
|
||
|
|
<li><strong>Copiar a config:</strong></li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-bash">cp my-topology.toml provisioning/config/test-topologies.toml
|
||
|
|
</code></pre>
|
||
|
|
<ol start="3">
|
||
|
|
<li><strong>Usar:</strong></li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-bash">provisioning test topology load mi_cluster | \
|
||
|
|
test env cluster custom --auto-start
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="casos-de-uso-prácticos"><a class="header" href="#casos-de-uso-prácticos">Casos de Uso Prácticos</a></h2>
|
||
|
|
<h3 id="desarrollo-de-taskservs"><a class="header" href="#desarrollo-de-taskservs">Desarrollo de Taskservs</a></h3>
|
||
|
|
<h4 id="escenario-desarrollando-nuevo-taskserv"><a class="header" href="#escenario-desarrollando-nuevo-taskserv">Escenario: Desarrollando nuevo taskserv</a></h4>
|
||
|
|
<pre><code class="language-bash"># 1. Test inicial
|
||
|
|
provisioning test quick my-new-taskserv
|
||
|
|
|
||
|
|
# 2. Si falla, debug con logs
|
||
|
|
provisioning test env single my-new-taskserv --auto-start
|
||
|
|
ENV_ID=$(provisioning test env list | tail -1 | awk '{print $1}')
|
||
|
|
provisioning test env logs $ENV_ID
|
||
|
|
|
||
|
|
# 3. Iterar hasta que funcione
|
||
|
|
|
||
|
|
# 4. Cleanup
|
||
|
|
provisioning test env cleanup $ENV_ID
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="validación-pre-despliegue"><a class="header" href="#validación-pre-despliegue">Validación Pre-Despliegue</a></h3>
|
||
|
|
<h4 id="escenario-validar-taskserv-antes-de-producción"><a class="header" href="#escenario-validar-taskserv-antes-de-producción">Escenario: Validar taskserv antes de producción</a></h4>
|
||
|
|
<pre><code class="language-bash"># 1. Test con configuración de producción
|
||
|
|
provisioning test env single kubernetes \
|
||
|
|
--cpu 4000 \
|
||
|
|
--memory 8192 \
|
||
|
|
--infra prod-cluster \
|
||
|
|
--auto-start
|
||
|
|
|
||
|
|
# 2. Revisar resultados
|
||
|
|
provisioning test env status <env-id>
|
||
|
|
|
||
|
|
# 3. Si pasa, desplegar a producción
|
||
|
|
provisioning taskserv create kubernetes --infra prod-cluster
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="test-de-integración"><a class="header" href="#test-de-integración">Test de Integración</a></h3>
|
||
|
|
<h4 id="escenario-validar-stack-completo"><a class="header" href="#escenario-validar-stack-completo">Escenario: Validar stack completo</a></h4>
|
||
|
|
<pre><code class="language-bash"># Test server con stack de aplicación
|
||
|
|
provisioning test env server app-stack [nginx postgres redis] \
|
||
|
|
--cpu 6000 \
|
||
|
|
--memory 12288 \
|
||
|
|
--auto-start \
|
||
|
|
--auto-cleanup
|
||
|
|
|
||
|
|
# El sistema:
|
||
|
|
# 1. Resuelve dependencias automáticamente
|
||
|
|
# 2. Crea containers con recursos especificados
|
||
|
|
# 3. Configura red aislada
|
||
|
|
# 4. Ejecuta tests de integración
|
||
|
|
# 5. Limpia todo al terminar
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="test-de-clusters-ha"><a class="header" href="#test-de-clusters-ha">Test de Clusters HA</a></h3>
|
||
|
|
<h4 id="escenario-validar-cluster-kubernetes"><a class="header" href="#escenario-validar-cluster-kubernetes">Escenario: Validar cluster Kubernetes</a></h4>
|
||
|
|
<pre><code class="language-bash"># 1. Crear cluster 3-nodos
|
||
|
|
provisioning test topology load kubernetes_3node | \
|
||
|
|
test env cluster kubernetes --auto-start
|
||
|
|
|
||
|
|
# 2. Obtener env-id
|
||
|
|
ENV_ID=$(provisioning test env list | grep kubernetes | awk '{print $1}')
|
||
|
|
|
||
|
|
# 3. Ver status del cluster
|
||
|
|
provisioning test env status $ENV_ID
|
||
|
|
|
||
|
|
# 4. Ejecutar tests específicos
|
||
|
|
provisioning test env run $ENV_ID --tests [cluster-health node-ready]
|
||
|
|
|
||
|
|
# 5. Logs si hay problemas
|
||
|
|
provisioning test env logs $ENV_ID
|
||
|
|
|
||
|
|
# 6. Cleanup
|
||
|
|
provisioning test env cleanup $ENV_ID
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="troubleshooting-de-producción"><a class="header" href="#troubleshooting-de-producción">Troubleshooting de Producción</a></h3>
|
||
|
|
<h4 id="escenario-reproducir-issue-de-producción"><a class="header" href="#escenario-reproducir-issue-de-producción">Escenario: Reproducir issue de producción</a></h4>
|
||
|
|
<pre><code class="language-bash"># 1. Crear entorno idéntico a producción
|
||
|
|
# Copiar config de prod a topology custom
|
||
|
|
|
||
|
|
# 2. Cargar y ejecutar
|
||
|
|
provisioning test topology load prod-replica | \
|
||
|
|
test env cluster app --auto-start
|
||
|
|
|
||
|
|
# 3. Reproducir el issue
|
||
|
|
|
||
|
|
# 4. Debug con logs detallados
|
||
|
|
provisioning test env logs <env-id>
|
||
|
|
|
||
|
|
# 5. Fix y re-test
|
||
|
|
|
||
|
|
# 6. Cleanup
|
||
|
|
provisioning test env cleanup <env-id>
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="integración-cicd"><a class="header" href="#integración-cicd">Integración CI/CD</a></h2>
|
||
|
|
<h3 id="gitlab-ci"><a class="header" href="#gitlab-ci">GitLab CI</a></h3>
|
||
|
|
<pre><code class="language-yaml"># .gitlab-ci.yml
|
||
|
|
|
||
|
|
stages:
|
||
|
|
- test
|
||
|
|
- deploy
|
||
|
|
|
||
|
|
variables:
|
||
|
|
ORCHESTRATOR_URL: "http://orchestrator:9090"
|
||
|
|
|
||
|
|
# Test stage
|
||
|
|
test-taskservs:
|
||
|
|
stage: test
|
||
|
|
image: nushell:latest
|
||
|
|
services:
|
||
|
|
- docker:dind
|
||
|
|
before_script:
|
||
|
|
- cd provisioning/platform/orchestrator
|
||
|
|
- ./scripts/start-orchestrator.nu --background
|
||
|
|
- sleep 5 # Wait for orchestrator
|
||
|
|
script:
|
||
|
|
# Quick tests
|
||
|
|
- provisioning test quick kubernetes
|
||
|
|
- provisioning test quick postgres
|
||
|
|
- provisioning test quick redis
|
||
|
|
# Cluster test
|
||
|
|
- provisioning test topology load kubernetes_3node | test env cluster kubernetes --auto-start --auto-cleanup
|
||
|
|
after_script:
|
||
|
|
# Cleanup any remaining environments
|
||
|
|
- provisioning test env list | tail -n +2 | awk '{print $1}' | xargs -I {} provisioning test env cleanup {}
|
||
|
|
|
||
|
|
# Integration test
|
||
|
|
test-integration:
|
||
|
|
stage: test
|
||
|
|
script:
|
||
|
|
- provisioning test env server app-stack [nginx postgres redis] --auto-start --auto-cleanup
|
||
|
|
|
||
|
|
# Deploy only if tests pass
|
||
|
|
deploy-production:
|
||
|
|
stage: deploy
|
||
|
|
script:
|
||
|
|
- provisioning taskserv create kubernetes --infra production
|
||
|
|
only:
|
||
|
|
- main
|
||
|
|
dependencies:
|
||
|
|
- test-taskservs
|
||
|
|
- test-integration
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="github-actions"><a class="header" href="#github-actions">GitHub Actions</a></h3>
|
||
|
|
<pre><code class="language-yaml"># .github/workflows/test.yml
|
||
|
|
|
||
|
|
name: Test Infrastructure
|
||
|
|
|
||
|
|
on:
|
||
|
|
push:
|
||
|
|
branches: [ main, develop ]
|
||
|
|
pull_request:
|
||
|
|
branches: [ main ]
|
||
|
|
|
||
|
|
jobs:
|
||
|
|
test-taskservs:
|
||
|
|
runs-on: ubuntu-latest
|
||
|
|
|
||
|
|
services:
|
||
|
|
docker:
|
||
|
|
image: docker:dind
|
||
|
|
|
||
|
|
steps:
|
||
|
|
- uses: actions/checkout@v3
|
||
|
|
|
||
|
|
- name: Setup Nushell
|
||
|
|
run: |
|
||
|
|
cargo install nu
|
||
|
|
|
||
|
|
- name: Start Orchestrator
|
||
|
|
run: |
|
||
|
|
cd provisioning/platform/orchestrator
|
||
|
|
cargo build --release
|
||
|
|
./target/release/provisioning-orchestrator &
|
||
|
|
sleep 5
|
||
|
|
curl http://localhost:9090/health
|
||
|
|
|
||
|
|
- name: Run Quick Tests
|
||
|
|
run: |
|
||
|
|
provisioning test quick kubernetes
|
||
|
|
provisioning test quick postgres
|
||
|
|
provisioning test quick redis
|
||
|
|
|
||
|
|
- name: Run Cluster Test
|
||
|
|
run: |
|
||
|
|
provisioning test topology load kubernetes_3node | \
|
||
|
|
test env cluster kubernetes --auto-start --auto-cleanup
|
||
|
|
|
||
|
|
- name: Cleanup
|
||
|
|
if: always()
|
||
|
|
run: |
|
||
|
|
for env in $(provisioning test env list | tail -n +2 | awk '{print $1}'); do
|
||
|
|
provisioning test env cleanup $env
|
||
|
|
done
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="jenkins-pipeline"><a class="header" href="#jenkins-pipeline">Jenkins Pipeline</a></h3>
|
||
|
|
<pre><code class="language-groovy">// Jenkinsfile
|
||
|
|
|
||
|
|
pipeline {
|
||
|
|
agent any
|
||
|
|
|
||
|
|
environment {
|
||
|
|
ORCHESTRATOR_URL = 'http://localhost:9090'
|
||
|
|
}
|
||
|
|
|
||
|
|
stages {
|
||
|
|
stage('Setup') {
|
||
|
|
steps {
|
||
|
|
sh '''
|
||
|
|
cd provisioning/platform/orchestrator
|
||
|
|
./scripts/start-orchestrator.nu --background
|
||
|
|
sleep 5
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
stage('Quick Tests') {
|
||
|
|
parallel {
|
||
|
|
stage('Kubernetes') {
|
||
|
|
steps {
|
||
|
|
sh 'provisioning test quick kubernetes'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
stage('PostgreSQL') {
|
||
|
|
steps {
|
||
|
|
sh 'provisioning test quick postgres'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
stage('Redis') {
|
||
|
|
steps {
|
||
|
|
sh 'provisioning test quick redis'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
stage('Integration Test') {
|
||
|
|
steps {
|
||
|
|
sh '''
|
||
|
|
provisioning test env server app-stack [nginx postgres redis] \
|
||
|
|
--auto-start --auto-cleanup
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
stage('Cluster Test') {
|
||
|
|
steps {
|
||
|
|
sh '''
|
||
|
|
provisioning test topology load kubernetes_3node | \
|
||
|
|
test env cluster kubernetes --auto-start --auto-cleanup
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
post {
|
||
|
|
always {
|
||
|
|
sh '''
|
||
|
|
# Cleanup all test environments
|
||
|
|
provisioning test env list | tail -n +2 | awk '{print $1}' | \
|
||
|
|
xargs -I {} provisioning test env cleanup {}
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="troubleshooting"><a class="header" href="#troubleshooting">Troubleshooting</a></h2>
|
||
|
|
<h3 id="problemas-comunes"><a class="header" href="#problemas-comunes">Problemas Comunes</a></h3>
|
||
|
|
<h4 id="1-failed-to-connect-to-docker"><a class="header" href="#1-failed-to-connect-to-docker">1. “Failed to connect to Docker”</a></h4>
|
||
|
|
<p><strong>Error:</strong></p>
|
||
|
|
<pre><code>Error: Failed to connect to Docker daemon
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Solución:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Verificar que Docker está corriendo
|
||
|
|
docker ps
|
||
|
|
|
||
|
|
# Si no funciona, iniciar Docker
|
||
|
|
# macOS
|
||
|
|
open -a Docker
|
||
|
|
|
||
|
|
# Linux
|
||
|
|
sudo systemctl start docker
|
||
|
|
|
||
|
|
# Verificar que tu usuario está en el grupo docker
|
||
|
|
groups | grep docker
|
||
|
|
sudo usermod -aG docker $USER
|
||
|
|
newgrp docker
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="2-connection-refused-port-8080"><a class="header" href="#2-connection-refused-port-8080">2. “Connection refused (port 8080)”</a></h4>
|
||
|
|
<p><strong>Error:</strong></p>
|
||
|
|
<pre><code>Error: Connection refused
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Solución:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Verificar orquestador
|
||
|
|
curl http://localhost:9090/health
|
||
|
|
|
||
|
|
# Si no responde, iniciar
|
||
|
|
cd provisioning/platform/orchestrator
|
||
|
|
./scripts/start-orchestrator.nu --background
|
||
|
|
|
||
|
|
# Verificar logs
|
||
|
|
tail -f ./data/orchestrator.log
|
||
|
|
|
||
|
|
# Verificar que el puerto no está ocupado
|
||
|
|
lsof -i :9090
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="3-out-of-memory--resources"><a class="header" href="#3-out-of-memory--resources">3. “Out of memory / resources”</a></h4>
|
||
|
|
<p><strong>Error:</strong></p>
|
||
|
|
<pre><code>Error: Cannot allocate memory
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Solución:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Verificar recursos disponibles
|
||
|
|
docker info | grep -E "CPUs|Total Memory"
|
||
|
|
docker stats --no-stream
|
||
|
|
|
||
|
|
# Limpiar containers antiguos
|
||
|
|
docker container prune -f
|
||
|
|
|
||
|
|
# Limpiar imágenes no usadas
|
||
|
|
docker image prune -a -f
|
||
|
|
|
||
|
|
# Limpiar todo el sistema
|
||
|
|
docker system prune -af --volumes
|
||
|
|
|
||
|
|
# Ajustar límites de Docker (Docker Desktop)
|
||
|
|
# Settings → Resources → Aumentar Memory/CPU
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="4-network-already-exists"><a class="header" href="#4-network-already-exists">4. “Network already exists”</a></h4>
|
||
|
|
<p><strong>Error:</strong></p>
|
||
|
|
<pre><code>Error: Network test-net-xxx already exists
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Solución:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Listar redes
|
||
|
|
docker network ls | grep test
|
||
|
|
|
||
|
|
# Eliminar red específica
|
||
|
|
docker network rm test-net-xxx
|
||
|
|
|
||
|
|
# Eliminar todas las redes de test
|
||
|
|
docker network ls | grep test | awk '{print $1}' | xargs docker network rm
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="5-image-pull-failed"><a class="header" href="#5-image-pull-failed">5. “Image pull failed”</a></h4>
|
||
|
|
<p><strong>Error:</strong></p>
|
||
|
|
<pre><code>Error: Failed to pull image ubuntu:22.04
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Solución:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Verificar conexión a internet
|
||
|
|
ping docker.io
|
||
|
|
|
||
|
|
# Pull manual
|
||
|
|
docker pull ubuntu:22.04
|
||
|
|
|
||
|
|
# Si persiste, usar mirror
|
||
|
|
# Editar /etc/docker/daemon.json
|
||
|
|
{
|
||
|
|
"registry-mirrors": ["https://mirror.gcr.io"]
|
||
|
|
}
|
||
|
|
|
||
|
|
# Reiniciar Docker
|
||
|
|
sudo systemctl restart docker
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="6-environment-not-found"><a class="header" href="#6-environment-not-found">6. “Environment not found”</a></h4>
|
||
|
|
<p><strong>Error:</strong></p>
|
||
|
|
<pre><code>Error: Environment abc-123 not found
|
||
|
|
</code></pre>
|
||
|
|
<p><strong>Solución:</strong></p>
|
||
|
|
<pre><code class="language-bash"># Listar entornos activos
|
||
|
|
provisioning test env list
|
||
|
|
|
||
|
|
# Verificar logs del orquestador
|
||
|
|
tail -f provisioning/platform/orchestrator/data/orchestrator.log
|
||
|
|
|
||
|
|
# Reiniciar orquestador si es necesario
|
||
|
|
cd provisioning/platform/orchestrator
|
||
|
|
./scripts/start-orchestrator.nu --stop
|
||
|
|
./scripts/start-orchestrator.nu --background
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="debug-avanzado"><a class="header" href="#debug-avanzado">Debug Avanzado</a></h3>
|
||
|
|
<h4 id="ver-logs-de-container-específico"><a class="header" href="#ver-logs-de-container-específico">Ver logs de container específico</a></h4>
|
||
|
|
<pre><code class="language-bash"># 1. Obtener environment
|
||
|
|
provisioning test env get <env-id>
|
||
|
|
|
||
|
|
# 2. Copiar container_id del output
|
||
|
|
|
||
|
|
# 3. Ver logs del container
|
||
|
|
docker logs <container-id>
|
||
|
|
|
||
|
|
# 4. Ver logs en tiempo real
|
||
|
|
docker logs -f <container-id>
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="ejecutar-comandos-dentro-del-container"><a class="header" href="#ejecutar-comandos-dentro-del-container">Ejecutar comandos dentro del container</a></h4>
|
||
|
|
<pre><code class="language-bash"># Obtener container ID
|
||
|
|
CONTAINER_ID=$(provisioning test env get <env-id> | jq -r '.containers[0].container_id')
|
||
|
|
|
||
|
|
# Entrar al container
|
||
|
|
docker exec -it $CONTAINER_ID bash
|
||
|
|
|
||
|
|
# O ejecutar comando directo
|
||
|
|
docker exec $CONTAINER_ID ps aux
|
||
|
|
docker exec $CONTAINER_ID cat /etc/os-release
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="inspeccionar-red"><a class="header" href="#inspeccionar-red">Inspeccionar red</a></h4>
|
||
|
|
<pre><code class="language-bash"># Obtener network ID
|
||
|
|
NETWORK_ID=$(provisioning test env get <env-id> | jq -r '.network_id')
|
||
|
|
|
||
|
|
# Inspeccionar red
|
||
|
|
docker network inspect $NETWORK_ID
|
||
|
|
|
||
|
|
# Ver containers conectados
|
||
|
|
docker network inspect $NETWORK_ID | jq '.[0].Containers'
|
||
|
|
</code></pre>
|
||
|
|
<h4 id="verificar-recursos-del-container"><a class="header" href="#verificar-recursos-del-container">Verificar recursos del container</a></h4>
|
||
|
|
<pre><code class="language-bash"># Stats de un container
|
||
|
|
docker stats <container-id> --no-stream
|
||
|
|
|
||
|
|
# Stats de todos los containers de test
|
||
|
|
docker stats $(docker ps --filter "label=type=test_container" -q) --no-stream
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="mejores-prácticas"><a class="header" href="#mejores-prácticas">Mejores Prácticas</a></h2>
|
||
|
|
<h3 id="1-siempre-usar-auto-cleanup-en-cicd"><a class="header" href="#1-siempre-usar-auto-cleanup-en-cicd">1. Siempre usar Auto-Cleanup en CI/CD</a></h3>
|
||
|
|
<pre><code class="language-bash"># ✅ Bueno
|
||
|
|
provisioning test quick kubernetes
|
||
|
|
|
||
|
|
# ✅ Bueno
|
||
|
|
provisioning test env single postgres --auto-start --auto-cleanup
|
||
|
|
|
||
|
|
# ❌ Malo (deja basura si falla el pipeline)
|
||
|
|
provisioning test env single postgres --auto-start
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="2-ajustar-recursos-según-necesidad"><a class="header" href="#2-ajustar-recursos-según-necesidad">2. Ajustar Recursos según Necesidad</a></h3>
|
||
|
|
<pre><code class="language-bash"># Development: recursos mínimos
|
||
|
|
provisioning test env single redis --cpu 500 --memory 512
|
||
|
|
|
||
|
|
# Integration: recursos medios
|
||
|
|
provisioning test env single postgres --cpu 2000 --memory 4096
|
||
|
|
|
||
|
|
# Production-like: recursos completos
|
||
|
|
provisioning test env single kubernetes --cpu 4000 --memory 8192
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="3-usar-templates-para-clusters"><a class="header" href="#3-usar-templates-para-clusters">3. Usar Templates para Clusters</a></h3>
|
||
|
|
<pre><code class="language-bash"># ✅ Bueno: reutilizable, documentado
|
||
|
|
provisioning test topology load kubernetes_3node | test env cluster kubernetes
|
||
|
|
|
||
|
|
# ❌ Malo: configuración manual, propenso a errores
|
||
|
|
# Crear config manual cada vez
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="4-nombrar-entornos-descriptivamente"><a class="header" href="#4-nombrar-entornos-descriptivamente">4. Nombrar Entornos Descriptivamente</a></h3>
|
||
|
|
<pre><code class="language-bash"># Al crear custom configs, usar nombres claros
|
||
|
|
{
|
||
|
|
"type": "server_simulation",
|
||
|
|
"server_name": "prod-db-replica-test", # ✅ Descriptivo
|
||
|
|
...
|
||
|
|
}
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="5-limpiar-regularmente"><a class="header" href="#5-limpiar-regularmente">5. Limpiar Regularmente</a></h3>
|
||
|
|
<pre><code class="language-bash"># Script de limpieza (añadir a cron)
|
||
|
|
#!/usr/bin/env nu
|
||
|
|
|
||
|
|
# Limpiar entornos viejos (>1 hora)
|
||
|
|
provisioning test env list |
|
||
|
|
where created_at < (date now | date subtract 1hr) |
|
||
|
|
each {|env| provisioning test env cleanup $env.id }
|
||
|
|
|
||
|
|
# Limpiar Docker
|
||
|
|
docker system prune -f
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="referencia-rápida"><a class="header" href="#referencia-rápida">Referencia Rápida</a></h2>
|
||
|
|
<h3 id="comandos-esenciales"><a class="header" href="#comandos-esenciales">Comandos Esenciales</a></h3>
|
||
|
|
<pre><code class="language-bash"># Quick test
|
||
|
|
provisioning test quick <taskserv>
|
||
|
|
|
||
|
|
# Single taskserv
|
||
|
|
provisioning test env single <taskserv> [--auto-start] [--auto-cleanup]
|
||
|
|
|
||
|
|
# Server simulation
|
||
|
|
provisioning test env server <name> [taskservs]
|
||
|
|
|
||
|
|
# Cluster from template
|
||
|
|
provisioning test topology load <template> | test env cluster <type>
|
||
|
|
|
||
|
|
# List & manage
|
||
|
|
provisioning test env list
|
||
|
|
provisioning test env status <id>
|
||
|
|
provisioning test env logs <id>
|
||
|
|
provisioning test env cleanup <id>
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="rest-api"><a class="header" href="#rest-api">REST API</a></h3>
|
||
|
|
<pre><code class="language-bash"># Create
|
||
|
|
curl -X POST http://localhost:9090/test/environments/create \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d @config.json
|
||
|
|
|
||
|
|
# List
|
||
|
|
curl http://localhost:9090/test/environments
|
||
|
|
|
||
|
|
# Status
|
||
|
|
curl http://localhost:9090/test/environments/{id}
|
||
|
|
|
||
|
|
# Run tests
|
||
|
|
curl -X POST http://localhost:9090/test/environments/{id}/run
|
||
|
|
|
||
|
|
# Logs
|
||
|
|
curl http://localhost:9090/test/environments/{id}/logs
|
||
|
|
|
||
|
|
# Cleanup
|
||
|
|
curl -X DELETE http://localhost:9090/test/environments/{id}
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<h2 id="recursos-adicionales"><a class="header" href="#recursos-adicionales">Recursos Adicionales</a></h2>
|
||
|
|
<ul>
|
||
|
|
<li><strong>Documentación de Arquitectura</strong>: <code>docs/architecture/test-environment-architecture.md</code></li>
|
||
|
|
<li><strong>API Reference</strong>: <code>docs/api/test-environment-api.md</code></li>
|
||
|
|
<li><strong>Topologías</strong>: <code>provisioning/config/test-topologies.toml</code></li>
|
||
|
|
<li><strong>Código Fuente</strong>: <code>provisioning/platform/orchestrator/src/test_*.rs</code></li>
|
||
|
|
</ul>
|
||
|
|
<hr />
|
||
|
|
<h2 id="soporte"><a class="header" href="#soporte">Soporte</a></h2>
|
||
|
|
<p><strong>Issues</strong>: https://github.com/tu-org/provisioning/issues
|
||
|
|
<strong>Documentación</strong>: <code>provisioning help test</code>
|
||
|
|
<strong>Logs</strong>: <code>provisioning/platform/orchestrator/data/orchestrator.log</code></p>
|
||
|
|
<hr />
|
||
|
|
<p><strong>Versión del documento</strong>: 1.0.0
|
||
|
|
<strong>Última actualización</strong>: 2025-10-06</p>
|
||
|
|
|
||
|
|
</main>
|
||
|
|
|
||
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
||
|
|
<!-- Mobile navigation buttons -->
|
||
|
|
<a rel="prev" href="../user/test-environment-guide.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
||
|
|
<i class="fa fa-angle-left"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
<a rel="next prefetch" href="../user/troubleshooting-guide.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
||
|
|
<i class="fa fa-angle-right"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
<div style="clear: both"></div>
|
||
|
|
</nav>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
||
|
|
<a rel="prev" href="../user/test-environment-guide.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
||
|
|
<i class="fa fa-angle-left"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
<a rel="next prefetch" href="../user/troubleshooting-guide.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
||
|
|
<i class="fa fa-angle-right"></i>
|
||
|
|
</a>
|
||
|
|
</nav>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Livereload script (if served using the cli tool) -->
|
||
|
|
<script>
|
||
|
|
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||
|
|
const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload";
|
||
|
|
const socket = new WebSocket(wsAddress);
|
||
|
|
socket.onmessage = function (event) {
|
||
|
|
if (event.data === "reload") {
|
||
|
|
socket.close();
|
||
|
|
location.reload();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
window.onbeforeunload = function() {
|
||
|
|
socket.close();
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<script>
|
||
|
|
window.playground_copyable = true;
|
||
|
|
</script>
|
||
|
|
|
||
|
|
|
||
|
|
<script src="../elasticlunr.min.js"></script>
|
||
|
|
<script src="../mark.min.js"></script>
|
||
|
|
<script src="../searcher.js"></script>
|
||
|
|
|
||
|
|
<script src="../clipboard.min.js"></script>
|
||
|
|
<script src="../highlight.js"></script>
|
||
|
|
<script src="../book.js"></script>
|
||
|
|
|
||
|
|
<!-- Custom JS scripts -->
|
||
|
|
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</body>
|
||
|
|
</html>
|