build: justfile: simplify test orchestration.

This commit is contained in:
Alexandre Pujol 2025-07-22 23:31:14 +02:00
parent dd5284532f
commit b30abed34f
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
4 changed files with 87 additions and 53 deletions

View file

@ -284,6 +284,18 @@ destroy dist flavor:
ssh dist flavor:
@ssh {{sshopt}} {{username}}@`just get_ip {{dist}} {{flavor}}`
[group('vm')]
[doc('Mount the shared directory on the machine')]
mount dist flavor:
@ssh {{sshopt}} {{username}}@`just get_ip {{dist}} {{flavor}}` \
sh -c 'mount | grep 0a31bc478ef8e2461a4b1cc10a24cc4 || sudo mount 0a31bc478ef8e2461a4b1cc10a24cc4'
[group('vm')]
[doc('Unmout the shared directory on the machine')]
umount dist flavor:
@ssh {{sshopt}} {{username}}@`just get_ip {{dist}} {{flavor}}` \
sh -c 'true; sudo umount /home/{{username}}/Projects/apparmor.d || true'
[group('vm')]
[doc('List the machines')]
list:
@ -324,7 +336,6 @@ available:
}
'
[group('tests')]
[doc('Install dependencies for the integration tests')]
init:
@ -349,30 +360,18 @@ tests-sync dist flavor:
[group('tests')]
[doc('Re-synchronize the integration tests (machine)')]
tests-resync dist flavor: (tests-mount dist flavor) \
tests-resync dist flavor: (mount dist flavor) \
(tests-sync dist flavor) \
(tests-umount dist flavor)
[group('tests')]
[doc('Unmout the integration tests (machine)')]
tests-umount dist flavor:
@ssh {{sshopt}} {{username}}@`just get_ip {{dist}} {{flavor}}` \
sudo umount /home/{{username}}/Projects/apparmor.d
(umount dist flavor)
[group('tests')]
[doc('Run the integration tests (machine)')]
tests-run dist flavor name="":
tests-run dist flavor name="": (tests-resync dist flavor)
ssh {{sshopt}} {{username}}@`just get_ip {{dist}} {{flavor}}` \
TERM=xterm \
bats --recursive --pretty --timing --print-output-on-failure \
/home/{{username}}/Projects/tests/integration/{{name}}
[group('tests')]
[doc('Mount integration tests (machine)')]
tests-mount dist flavor:
@ssh {{sshopt}} {{username}}@`just get_ip {{dist}} {{flavor}}` \
sudo mount 0a31bc478ef8e2461a4b1cc10a24cc4
[private]
get_ip dist flavor:
@virsh --quiet --readonly {{c}} domifaddr {{prefix}}{{dist}}-{{flavor}} | \

View file

@ -14,15 +14,43 @@ Although the integration test suite is intended to be run in a [Development VM](
## Getting started
Prepare the test environment:
**Prepare the test environment:**
```sh
just img <dist> <flavor>
just vm <dist> <flavor>
just create <dist> <flavor>
```
Run the integration tests on the test VM:
Example:
```sh
just integration <dist> <flavor>
just img ubuntu25 desktop
just create ubuntu25 desktop
```
**Install dependencies for the integration tests**
```sh
just tests-init <dist> <flavor>
```
Example:
```sh
just tests-init ubuntu25 desktop
```
**Run the integration tests**
It: synchronizes the tests, unmount the shared directory, then run the tests.
```sh
just tests-run <dist> <flavor>
```
Example:
```sh
just tests-run ubuntu25 desktop
```
Partial tests can also be run. For example the following command will only run the tests in the `tests/integration/apt` directory on the `ubuntu25` `desktop` machine:
```sh
just tests-run ubuntu25 desktop apt
```
## Create integration tests

View file

@ -37,8 +37,12 @@ Available recipes:
[tests]
tests # Run the unit tests
init dist flavor # Install dependencies for the bats integration tests
integration dist flavor # Run the integration tests on the machine
init # Install dependencies for the integration tests
integration # Run the integration tests
tests-init dist flavor # Install dependencies for the integration tests (machine)
tests-sync dist flavor # Synchronize the integration tests (machine)
tests-resync dist flavor # Re-synchronize the integration tests (machine)
tests-run dist flavor name="" # Run the integration tests (machine)
[linter]
lint # Run the linters
@ -57,6 +61,8 @@ Available recipes:
reboot dist flavor # Reboot the machine
destroy dist flavor # Destroy the machine
ssh dist flavor # Connect to the machine
mount dist flavor # Mount the shared directory on the machine
umount dist flavor # Unmout the shared directory on the machine
list # List the machines
images # List the VM images
available # List the VM images that can be created

View file

@ -37,6 +37,7 @@ The following desktop environments are supported:
**Build dependency**
* Go >= 1.23
* [just](https://github.com/casey/just)
## Configure AppArmor