Skip to content

Add local test framework for Strigo init scripts on Ubuntu#58

Open
ysebastia wants to merge 8 commits into
mainfrom
feat/tools/tests-scripts
Open

Add local test framework for Strigo init scripts on Ubuntu#58
ysebastia wants to merge 8 commits into
mainfrom
feat/tools/tests-scripts

Conversation

@ysebastia

Copy link
Copy Markdown
Contributor

Introduces a Vagrant-based harness to validate Strigo init scripts locally before a live training session, without needing to go through Strigo itself.

  • vagrant/ — Ubuntu 24 VM with a mock Strigo context (env variables, ec2metadata shim, GH_TOKEN forwarding)
  • tools/test-script.sh — replays a formation's full strigo.json init sequence (--sequence), tests a single shared script (--script), or a formation-local script (--local-script); supports --resource for multi-VM formations, Windows resources are skipped automatically
  • tools/lib.sh — assertion library (assert_command, assert_service, assert_port, assert_port_eventually, …)
  • tests/ — test files for 10 shared scripts
  • fix — ubuntu-24.04-apt-fix.sh: add --batch --yes to gpg to avoid interactive prompt on re-run

Vagrant + libvirt VM with bento/ubuntu-24.04, provisioned with an ubuntu
user and a mock Strigo context (/etc/profile.d/00_strigo_context.sh).
GH_TOKEN is forwarded from the host via ssh ForwardEnv. Results are saved
to vagrant/results/ and retrieved with fetch-results.sh.
test-script.sh replays a formation's strigo.json init sequence on the local VM (--sequence), tests a single shared script (--script), or a formation-local script (--local-script). Supports --branch, --resource, --output and --log. Produces a merged script of the full sequence as executed (templates substituted, ec2metadata replaced).
Covers: ubuntu-24.04-apt-fix, strigo, docker, docker-compose, nvm, increase-watchers-limit, http-server, code-server, tls-certificate, materials-helper_v2.
@ysebastia ysebastia self-assigned this Jun 19, 2026
@ysebastia ysebastia added the enhancement New feature or request label Jun 19, 2026
@ysebastia ysebastia requested a review from gmembre-zenika June 19, 2026 05:31
Comment thread tools/lib.sh
@@ -0,0 +1,117 @@
#!/bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l'idée est super, néanmoins, connais tu bats ? https://github.com/bats-core/bats-core. C'est un framework de test pour bash. Si c'est applicable, cela permettrait, je pense, de réduire un peu le code produit ici.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non, je connais pas, je vais regarder et voir comment on peut faire cela !
Merci du retour :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En fait, le mini framework de test est dans lib.sh qui fait une centaine de ligne.
l'objectif pour moi est plutôt le fichier test-scripts.sh qui régénère un fichier bash agrégeant tout les scripts en un unique, et qui exécute le tout dans Vagrant en une passe comme si c'était une VM strigo avec cloud-init. Cela me permet de tester les script pour une ubuntu 24 sans devoir aller dans strigo, faire une instance, changer la branche, toussa. Le coup des tests que j'ai ajouté, c'est une "sucrerie", ce qui m'intéresse surtout c'est de tester la compatibilité des scripts d'une distrib à l'autre, et que le probleme se reposera avec la prochaine version...
du coup bats je ne suis pas persuadé de la plus value car il n'intégre pas la méacnique de prendre sur github la conf, d'aller chercher les scripts et d'agréger le tout, tout en permettant de lancer le script généré à la volée.
A ta dispo pour en reparler :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parfait, je voulais te montrer qu'il était possible de ne pas réinventer la roue :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants