Relecture : le serveur ne construit jamais l image, réseau retenu par le .env, tâches arrêter

- docs/production.md : seuls compose.yml, compose.reseau.yml et verifier.py vont sur le serveur ; docker compose up -d --no-build ; COMPOSE_FILE dans ~/ollama/.env ; relance par Compose plutôt que docker start ; docker logout après le pull.
- verifier.py lisible par Python 3.8/3.9.
- Tâches « Instance de test : arrêter » et « Ollama : arrêter ».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-12 09:57:55 +01:00
1 parent f4c493770e
commit 3e0b5d03a3
6 files changed
+90 -9

No files matched your search

+13
View File
@@ -1,4 +1,5 @@
"""L'image Ollama : le script de vérification (contre un faux serveur) et les garde-fous du lancement (design §2, §5)."""
import ast
import json
import socket
import sys
@@ -80,6 +81,18 @@ class TestVerifier(unittest.TestCase):
verifier(f"http://127.0.0.1:{port}/v1")
class TestCompatibilite(unittest.TestCase):
def test_verifier_lisible_par_un_vieux_python(self): # le Python du serveur est inconnu (3.8, 3.9…)
texte = (OLLAMA / "verifier.py").read_text()
arbre = ast.parse(texte)
futur = any(isinstance(n, ast.ImportFrom) and n.module == "__future__"
and any(a.name == "annotations" for a in n.names) for n in arbre.body)
unions = [n for n in ast.walk(arbre) if isinstance(n, (ast.FunctionDef, ast.arg))
for a in [n.returns if isinstance(n, ast.FunctionDef) else n.annotation]
if a is not None and any(isinstance(b, ast.BinOp) for b in ast.walk(a))]
self.assertTrue(futur or not unions, "annotations « X | None » évaluées à la définition : Python ≥ 3.10")
class TestLancement(unittest.TestCase):
def test_port_lie_a_localhost_par_defaut(self): # Ollama n'a pas d'authentification
self.assertIn('"${OLLAMA_BIND:-127.0.0.1}:${OLLAMA_PORT:-11434}:11434"', COMPOSE.read_text())
+30
View File
@@ -0,0 +1,30 @@
"""Les gestes de production (docs/production.md) ne peuvent pas abîmer le serveur partagé avec LibreDesk (design §2)."""
import re
import unittest
from pathlib import Path
PRODUCTION = Path(__file__).resolve().parents[1] / "docs" / "production.md"
def lignes_compose() -> list[str]:
return [l for l in PRODUCTION.read_text(encoding="utf-8").splitlines() if re.search(r"docker compose\b.*\bup\b", l)]
class TestProduction(unittest.TestCase):
def test_le_serveur_ne_construit_jamais_l_image(self): # un build tirerait ~10 Go sur le disque de LibreDesk
texte = PRODUCTION.read_text(encoding="utf-8")
self.assertNotIn("scp -r ollama", texte) # pas de Dockerfile sur le serveur
self.assertNotIn("Dockerfile <serveur>", texte)
self.assertTrue(lignes_compose())
for l in lignes_compose():
self.assertIn("--no-build", l, l)
def test_le_reseau_de_libredesk_est_retenu_par_le_env(self): # un « up » sans -f ne doit pas couper Ollama
texte = PRODUCTION.read_text(encoding="utf-8")
self.assertIn("COMPOSE_FILE=compose.yml:compose.reseau.yml", texte)
self.assertNotIn("-f compose.reseau.yml", texte)
self.assertNotIn("-f compose.yml", texte)
if __name__ == "__main__":
unittest.main()
+5
View File
@@ -53,6 +53,11 @@ class TestTaches(unittest.TestCase):
c = next(c for l, c in commandes().items() if "down -v" in c)
self.assertIn('[ "${input:confirmation}" = oui ]', c)
def test_arreter_sans_effacer(self): # design §5 : démarrage ET arrêt de l'instance de test
cmds = list(commandes().values())
self.assertTrue(any("-p ldtest stop" in c for c in cmds), "pas de tâche qui arrête l'instance de test")
self.assertTrue(any("ollama/compose.yml" in c and " stop" in c for c in cmds), "pas de tâche qui arrête Ollama")
def test_scripts_references_existent(self):
for libelle, c in commandes().items():
for chemin in re.findall(r"(?:instance-de-test|ollama)/[\w.-]+\.(?:py|sh|yml)", c):