Skip to content

Commit 4c29f9e

Browse files
refactor(tmachine): publish test variables through a shared task file
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent 5d0d194 commit 4c29f9e

2 files changed

Lines changed: 36 additions & 24 deletions

File tree

‎tests/tmachine/ansible/playbooks/keycloak.yaml‎

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,22 @@
44
# Run Keycloak in the environment and publish how tests reach it.
55
#
66
# Environment setup applies this once and caches the disk, so the container
7-
# restarts on every boot (see the keycloak role). Tests read the variables in
8-
# the env file below through openshell-test-runner, which passes every
9-
# /etc/openshell-test/env.d/*.env file to them. The keycloak features suite
10-
# (tests/suites/features/keycloak) reads them.
7+
# restarts on every boot (see the keycloak role). The keycloak features suite
8+
# (tests/suites/features/keycloak) reads the variables published below.
119
---
1210
- name: Keycloak for tests
1311
hosts: all
1412
gather_facts: false
1513
roles:
1614
- keycloak
1715
tasks:
18-
- name: Create the test environment directory
19-
become: true
20-
ansible.builtin.file:
21-
path: /etc/openshell-test/env.d
22-
state: directory
23-
owner: root
24-
group: root
25-
mode: "0755"
26-
2716
# The values are the throwaway fixture realm's (scripts/keycloak-realm.json).
2817
- name: Publish Keycloak test variables
29-
become: true
30-
ansible.builtin.copy:
31-
dest: /etc/openshell-test/env.d/keycloak.env
32-
owner: tmachine
33-
group: tmachine
34-
mode: "0600"
35-
content: |
36-
OPENSHELL_TEST_KEYCLOAK_ISSUER=http://127.0.0.1:{{ keycloak_port }}/realms/{{ keycloak_realm }}
37-
OPENSHELL_TEST_KEYCLOAK_CLIENT_ID=openshell-cli
38-
OPENSHELL_TEST_KEYCLOAK_USERNAME=admin@test
39-
OPENSHELL_TEST_KEYCLOAK_PASSWORD=admin
18+
ansible.builtin.include_tasks: test-env.yaml
19+
vars:
20+
test_env_name: keycloak
21+
test_env_vars:
22+
OPENSHELL_TEST_KEYCLOAK_ISSUER: "http://127.0.0.1:{{ keycloak_port }}/realms/{{ keycloak_realm }}"
23+
OPENSHELL_TEST_KEYCLOAK_CLIENT_ID: openshell-cli
24+
OPENSHELL_TEST_KEYCLOAK_USERNAME: admin@test
25+
OPENSHELL_TEST_KEYCLOAK_PASSWORD: admin
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Publish how tests reach a service the environment runs. Include it with
5+
# `test_env_name` (the file name) and `test_env_vars` (OPENSHELL_TEST_* names
6+
# to values). openshell-test-runner passes every
7+
# /etc/openshell-test/env.d/*.env file to the tests, and the suite's fixture
8+
# reads the variables.
9+
---
10+
- name: Create the test environment directory
11+
become: true
12+
ansible.builtin.file:
13+
path: /etc/openshell-test/env.d
14+
state: directory
15+
owner: root
16+
group: root
17+
mode: "0755"
18+
19+
- name: Publish {{ test_env_name }} test variables
20+
become: true
21+
ansible.builtin.copy:
22+
dest: /etc/openshell-test/env.d/{{ test_env_name }}.env
23+
owner: tmachine
24+
group: tmachine
25+
mode: "0600"
26+
content: "{% for key, value in test_env_vars.items() %}{{ key }}={{ value }}\n{% endfor %}"

0 commit comments

Comments
 (0)