[UPD] qemu manage : nom de VM sans la version d'une publication continue
Une distribution en publication continue n'a qu'une version, latest : le
segment ne distingue aucune VM d'une autre et sort du nom. Une version
nommée qui coexiste avec d'autres au catalogue y reste, tumbleweed comme
les numérotées.
Le nom se relit dans l'autre sens pour retrouver (distro, version) et
filtrer les outils par distribution : une VM déjà déployée sous l'ancien
nom n'y est plus résolue, la renommer suffit. Vérifié : catalogue rejoué
sans collision, aller-retour du nom, 6 tests.
--- EN ---
A rolling-release distribution has a single version, latest: the segment
tells no VM apart from another and leaves the name. A named version that
coexists with others in the catalogue stays, tumbleweed as much as the
numbered ones.
The name is read back the other way to recover (distro, version) and filter
tools by distribution: a VM already deployed under the old name no longer
resolves there, renaming it is enough. Checked: catalogue replayed without
collision, name round trip, 6 tests.
Assisted-by: Claude Opus 5
2026-09-02 04:13:48 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# © 2021-2026 TechnoLibre (http://www.technolibre.ca)
|
|
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
|
|
|
|
|
|
|
|
|
"""Le nom de VM du parc : que porte-t-il, et que retrouve-t-on dedans ?
|
|
|
|
|
|
|
|
|
|
Le nom se lit dans les deux sens. `_qemu_infra_name` le fabrique à partir de
|
|
|
|
|
(distro, version, archi) ; `_qemu_vm_meta` remonte de ce nom à la version en
|
|
|
|
|
rejouant le catalogue. Les deux doivent rester en miroir : une règle ajoutée
|
|
|
|
|
d'un seul côté rend une VM introuvable dans son propre parc.
|
|
|
|
|
|
|
|
|
|
Une distribution en publication continue n'a qu'une version, « latest », qui
|
|
|
|
|
ne distingue donc rien — elle sort du nom. Une version nommée qui coexiste
|
|
|
|
|
avec d'autres au catalogue, tumbleweed, reste.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
from unittest.mock import patch
|
|
|
|
|
|
|
|
|
|
from script.todo.todo import TODO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestInfraName(unittest.TestCase):
|
|
|
|
|
"""Ce que le nom porte selon la distribution et l'architecture."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
patcher = patch.object(
|
|
|
|
|
TODO, "_native_arch", staticmethod(lambda: "amd64")
|
|
|
|
|
)
|
|
|
|
|
patcher.start()
|
|
|
|
|
self.addCleanup(patcher.stop)
|
|
|
|
|
|
|
|
|
|
def test_rolling_release_drops_the_version(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
TODO._qemu_infra_name("arch", "latest", "amd64"), "erplibre-arch"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_rolling_release_keeps_the_foreign_arch(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
TODO._qemu_infra_name("arch", "latest", "arm64"),
|
|
|
|
|
"erplibre-arch-arm64",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_named_version_stays(self):
|
|
|
|
|
"""tumbleweed coexiste avec Leap au catalogue : le nom doit trancher."""
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
TODO._qemu_infra_name("opensuse", "tumbleweed", "amd64"),
|
|
|
|
|
"erplibre-opensuse-tumbleweed",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_numbered_version_loses_only_its_dots(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
TODO._qemu_infra_name("ubuntu", "24.04", "amd64"),
|
|
|
|
|
"erplibre-ubuntu-2404",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_every_catalogue_entry_yields_a_distinct_name(self):
|
|
|
|
|
"""Deux entrées du catalogue ne peuvent pas porter le même nom."""
|
|
|
|
|
import importlib.util
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
path = (
|
|
|
|
|
Path(__file__).resolve().parent.parent
|
|
|
|
|
/ "script"
|
|
|
|
|
/ "qemu"
|
|
|
|
|
/ "deploy_qemu.py"
|
|
|
|
|
)
|
|
|
|
|
spec = importlib.util.spec_from_file_location("deploy_qemu", path)
|
|
|
|
|
mod = importlib.util.module_from_spec(spec)
|
|
|
|
|
spec.loader.exec_module(mod)
|
|
|
|
|
|
|
|
|
|
noms = [
|
|
|
|
|
TODO._qemu_infra_name(distro, version, "amd64")
|
|
|
|
|
for distro, (versions, _default) in mod.DISTROS.items()
|
|
|
|
|
for version in versions
|
|
|
|
|
]
|
|
|
|
|
self.assertEqual(len(noms), len(set(noms)), sorted(noms))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestNameRoundTrip(unittest.TestCase):
|
|
|
|
|
"""_qemu_vm_meta retrouve la version que _qemu_infra_name a effacée."""
|
|
|
|
|
|
|
|
|
|
def test_rolling_release_resolves_back_to_latest(self):
|
|
|
|
|
todo = TODO()
|
[REF] format : passer l'outillage et les tests sous ruff
Le formateur de ce dépôt est ruff depuis qu'il remplace black, qui ne connaît
aucune cible au-delà de py313 ; ce passage applique sa norme à l'arbre entier,
d'un coup, pour qu'aucun commit de fond n'ait à porter du style. L'écart tient
presque entièrement aux chaînes coupées à la main que ruff recolle quand elles
tiennent sur une ligne, et aux « with » multiples qu'il regroupe : aucune
valeur ne change, et les clés de traduction non plus.
Vérifié : la suite unitaire reste verte après le passage, et le contrôle de
syntaxe ne signale rien.
--- EN ---
This repository's formatter is ruff since it replaced black, which knows no
target beyond py313; this pass applies its standard to the whole tree at once,
so that no substantive commit has to carry style. The difference is almost
entirely the hand-split strings ruff joins back when they fit on one line, and
the multiple "with" it merges: no value changes, nor do the translation keys.
Checked: the unit suite stays green after the pass, and the syntax check
reports nothing.
Assisted-by: Claude Opus 5
2026-09-24 13:30:31 -04:00
|
|
|
with (
|
|
|
|
|
patch.object(TODO, "_qemu_vm_arch", lambda self, name: "amd64"),
|
|
|
|
|
patch.object(TODO, "_native_arch", staticmethod(lambda: "amd64")),
|
|
|
|
|
):
|
[UPD] qemu manage : nom de VM sans la version d'une publication continue
Une distribution en publication continue n'a qu'une version, latest : le
segment ne distingue aucune VM d'une autre et sort du nom. Une version
nommée qui coexiste avec d'autres au catalogue y reste, tumbleweed comme
les numérotées.
Le nom se relit dans l'autre sens pour retrouver (distro, version) et
filtrer les outils par distribution : une VM déjà déployée sous l'ancien
nom n'y est plus résolue, la renommer suffit. Vérifié : catalogue rejoué
sans collision, aller-retour du nom, 6 tests.
--- EN ---
A rolling-release distribution has a single version, latest: the segment
tells no VM apart from another and leaves the name. A named version that
coexists with others in the catalogue stays, tumbleweed as much as the
numbered ones.
The name is read back the other way to recover (distro, version) and filter
tools by distribution: a VM already deployed under the old name no longer
resolves there, renaming it is enough. Checked: catalogue replayed without
collision, name round trip, 6 tests.
Assisted-by: Claude Opus 5
2026-09-02 04:13:48 -04:00
|
|
|
|
|
|
|
|
class Catalogue:
|
|
|
|
|
DISTROS = {"arch": (["latest"], "latest")}
|
|
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
todo._qemu_vm_meta("erplibre-arch", Catalogue()),
|
|
|
|
|
("arch", "latest", "amd64"),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main()
|