Files
computer-playbook/roles/test-e2e-cli/tasks/main.yml
evangelostsak 47372f0c1d fix(test-e2e-cli): run a controller-only CLI test only on the controller
CLI tests are discovered by group membership alone, so a test that builds
its own fixtures from the controller's checkout ran on every host carrying
its role. The meshed swarm arm puts svc-net-wireguard on every node, and run
38864400393 failed Pretix#2, Magento and Matrix#2 with
"cd: /home/runner/work/infinito.nexus/infinito.nexus: No such file or
directory" on each node.

A role now declares cli.controller_only in meta/tests.yml, read through the
role_tests lookup like cli.timeout and cli.container_service_key, and its
test runs only on a host reached over a local connection. Every other role
runs exactly as before. Checked against a local-connection host and a
docker-connection host: svc-net-wireguard ran on the first and was skipped
on the second, and svc-net-tor ran on both.
2026-10-16 13:55:11 +02:00

62 lines
1.9 KiB
YAML

---
- name: 🧩 Apply role include/exclude filters
ansible.builtin.set_fact:
_cli_apps: >-
{{
playbook_dir
| discover_cli_roles(
group_names=group_names,
only_roles=TEST_E2E_CLI_ONLY_ROLES,
skip_roles=TEST_E2E_CLI_SKIP_ROLES
)
}}
- name: 🔍 Show detected CLI test roles
ansible.builtin.debug:
msg: "CLI-test-enabled roles: {{ _cli_apps }}"
changed_when: false
- name: 📂 Ensure stage base dir exists
ansible.builtin.file:
path: "{{ TEST_E2E_CLI_STAGE_BASE_DIR }}"
state: directory
mode: "0700"
- name: 📦 Install DB client modules for the CLI tests
ansible.builtin.command:
argv:
- python3
- -m
- pip
- install
- --quiet
- --break-system-packages
- pymysql
- psycopg2-binary
- ldap3
register: _cli_pip_install
changed_when: "'Successfully installed' in _cli_pip_install.stdout"
when: (_cli_apps | length) > 0
- name: 🧪 Run CLI tests, always purging the staged secrets afterwards
block:
- name: 🚀 Run CLI test for each detected role
ansible.builtin.include_tasks: run_one.yml
loop: "{{ _cli_apps }}"
loop_control:
loop_var: application_id # nocheck: loop-var-shadow the item IS the role id, so run_one reads the same value the tested role declares
label: "{{ application_id }}"
when: >-
not (lookup('role_tests', application_id, 'cli.controller_only', default=false) | bool)
or (ansible_connection | default('')) == 'local'
- name: ✅ Fail if there were CLI test failures
ansible.builtin.fail:
msg: "CLI tests failed for roles: {{ _cli_failures }}"
when: (_cli_failures | default([])) | length > 0
always:
- name: 🧹 Remove CLI test stage dir (holds decodable DB secrets)
ansible.builtin.file:
path: "{{ TEST_E2E_CLI_STAGE_BASE_DIR }}"
state: absent