Skip to content

Commit f7023bb

Browse files
authored
Merge branch 'master' into alexy_ck_job_6c
2 parents 743d057 + 1936df5 commit f7023bb

3 files changed

Lines changed: 38 additions & 18 deletions

File tree

roles/telemetry_chargeback/README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Role Variables
5151
| `openstackpod` | `"openstackclient"` | OpenStack client pod name for exec/cp operations |
5252
| `lookback` | `6` | Days to look back for Loki query time range |
5353
| `limit` | `50` | Limit for Loki query results |
54+
| `cloudkitty_test_scenarios` | `["test_static.yml", "test_dyn_basic.yml"]` | List of test scenario files to run|
5455

5556
How It Works
5657
------------
@@ -67,8 +68,8 @@ The role executes the following workflow:
6768
- Retrieves certificates from secrets/configmaps
6869
- Configures Loki push/query URLs
6970

70-
3. **Test Scenario Discovery**
71-
- Automatically finds all `test_*.yml` files in `files/` directory
71+
3. **Test Scenario Selection**
72+
- Uses scenarios defined in `cloudkitty_test_scenarios` variable
7273

7374
4. **Scenario Execution Loop** (for each discovered scenario)
7475
- Generates synthetic Loki log data (`gen_synth_loki_data.py`)
@@ -204,7 +205,7 @@ When `--debug` is enabled, the script writes a `<stem>_diff.txt` file containing
204205
Scenario Configuration
205206
----------------------
206207

207-
Test scenarios are defined in YAML files located in the `files/` directory. Any file matching the pattern `test_*.yml` will be automatically discovered and executed.
208+
Test scenarios are defined in YAML files located in the `files/` directory. The scenarios to run are specified by the `cloudkitty_test_scenarios` variable.
208209

209210
### Available Scenarios
210211

@@ -265,7 +266,7 @@ This role has no direct hard dependencies on other Ansible roles.
265266
Example Playbook
266267
----------------
267268

268-
**Basic usage (auto-discover scenarios):**
269+
**Basic usage (runs default scenarios):**
269270
```yaml
270271
- name: "Run chargeback tests"
271272
hosts: controllers
@@ -293,6 +294,27 @@ Example Playbook
293294
lookback: 10
294295
```
295296

297+
**Run specific test scenarios:**
298+
```yaml
299+
- name: "Run chargeback tests with specific scenarios"
300+
hosts: controllers
301+
gather_facts: false
302+
303+
tasks:
304+
- name: "Run chargeback validation with custom scenarios"
305+
ansible.builtin.import_role:
306+
name: telemetry_chargeback
307+
vars:
308+
cloudkitty_test_scenarios:
309+
- "test_static.yml"
310+
```
311+
312+
**Run custom scenarios via extra-vars:**
313+
```bash
314+
ansible-playbook playbook.yml \
315+
-e '{"cloudkitty_test_scenarios": ["test_static.yml", "test_custom.yml"]}'
316+
```
317+
296318
License
297319
-------
298320

@@ -303,5 +325,5 @@ Author Information
303325

304326
Alex Yefimov, Red Hat
305327

306-
**Project:** RHOSO (Red Hat OpenStack Services on OpenShift)
328+
**Project:** RHOSO (Red Hat OpenStack Services on OpenShift)
307329
**Component:** Telemetry - CloudKitty Chargeback

roles/telemetry_chargeback/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ openstackpod: "openstackclient"
2828
# Time window settings
2929
lookback: 6
3030
limit: 50
31+
32+
# List of test scenario files to run
33+
cloudkitty_test_scenarios: ["test_static.yml" , "test_dyn_basic.yml"]

roles/telemetry_chargeback/tasks/main.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,19 @@
55
- name: "Setup Loki Environment"
66
ansible.builtin.include_tasks: "setup_loki_env.yml"
77

8-
- name: "Find test files"
9-
ansible.builtin.find:
10-
paths: "{{ cloudkitty_scenario_dir }}"
11-
patterns: "test_*.yml"
12-
register: found_files_raw
13-
14-
- name: "Extract only the filenames into a clean list"
8+
# Scenario name is file name without extension
9+
- name: "Generate clean list of scenario names"
1510
ansible.builtin.set_fact:
16-
found_files: "{{ found_files_raw.files | map(attribute='path') | map('basename') | map('regex_replace', '\\.yml$', '') | list }}"
11+
scenarios_to_run: "{{ cloudkitty_test_scenarios | map('regex_replace', '\\.yml$', '') | list }}"
1712

18-
- name: "Run scenario file through workflow"
13+
- name: "Run scenarios through workflow"
1914
block:
2015
- name: "Process and Loop if files exist"
21-
ansible.builtin.include_tasks: run_test_scenarios.yml
22-
loop: "{{ found_files }}"
16+
ansible.builtin.include_tasks: "run_test_scenarios.yml"
17+
loop: "{{ scenarios_to_run }}"
2318
loop_control:
2419
loop_var: scenario_name
25-
when: found_files | length > 0
20+
when: scenarios_to_run | length > 0
2621

2722
rescue:
2823
- name: "Log failure"
@@ -31,4 +26,4 @@
3126

3227
always:
3328
- name: "Cleanup after job run"
34-
ansible.builtin.include_tasks: cleanup_ck.yml
29+
ansible.builtin.include_tasks: "cleanup_ck.yml"

0 commit comments

Comments
 (0)