Skip to content

Commit 9362bef

Browse files
ayefimov-1myadla
andauthored
Add synthetic date generation to telemetry_chargeback role in FVT repo (#331)
Generate synthetic data and write results to a json file Push json file to log directory so that during debug file is available for review Controller/ci-framework-data/tests/feature-verification-tests Do not overwrite syth data json if it already exists Using Gemini and Cursor Closes https://issues.redhat.com/browse/OSPRH-23746 Update the synthetic data generation process to ensure that existing JSON files are not overwritten. This change allows for better debugging by preserving previous data outputs. Closes https://issues.redhat.com/browse/OSPRH-23746 Co-authored-by: Muneesha Yadla <myadla@redhat.com>
1 parent 45bd5f1 commit 9362bef

File tree

10 files changed

+550
-5
lines changed

10 files changed

+550
-5
lines changed

ci/run_chargeback_tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
22
- name: "Verify all the applicable projects, endpoints, pods & services for cloudkitty"
33
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4-
gather_facts: no
4+
gather_facts: true
55
ignore_errors: true
66
environment:
77
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
88
PATH: "{{ cifmw_path }}"
99
vars_files:
10+
- vars/common.yml
1011
- vars/osp18_env.yml
1112
vars:
1213
common_pod_status_str: "Running"

roles/telemetry_chargeback/README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ telemetry_chargeback
22
=========
33
The **`telemetry_chargeback`** role is designed to test the **RHOSO Cloudkitty** feature. These tests are specific to the Cloudkitty feature. Tests that are not specific to this feature (e.g., standard OpenStack deployment validation, basic networking) should be added to a common role.
44

5+
The role performs two main functions:
6+
7+
1. **CloudKitty Validation** - Enables and configures the CloudKitty hashmap rating module, then validates its state.
8+
2. **Synthetic Data Generation** - Generates synthetic Loki log data for testing chargeback scenarios using a Python script and Jinja2 template.
9+
510
Requirements
611
------------
712
It relies on the following being available on the target or control host:
@@ -10,6 +15,9 @@ It relies on the following being available on the target or control host:
1015
* The **OpenStack CLI client** must be installed and configured with administrative credentials.
1116
* Required Python libraries for the `openstack` CLI (e.g., `python3-openstackclient`).
1217
* Connectivity to the OpenStack API endpoint.
18+
* **Python 3** with the following libraries for synthetic data generation:
19+
* `PyYAML`
20+
* `Jinja2`
1321

1422
It is expected to be run **after** a successful deployment and configuration of the following components:
1523

@@ -18,12 +26,38 @@ It is expected to be run **after** a successful deployment and configuration of
1826

1927
Role Variables
2028
--------------
21-
The role uses a few primary variables to control the testing environment and execution.
29+
The role uses the following variables to control the testing environment and execution.
30+
31+
### User-Configurable Variables (defaults/main.yml)
2232

2333
| Variable | Default Value | Description |
2434
|----------|---------------|-------------|
2535
| `openstack_cmd` | `openstack` | The command used to execute OpenStack CLI calls. This can be customized if the binary is not in the standard PATH. |
2636

37+
### Internal Variables (vars/main.yml)
38+
39+
These variables are used internally by the role and typically do not need to be modified.
40+
41+
| Variable | Default Value | Description |
42+
|----------|---------------|-------------|
43+
| `logs_dir_zuul` | `/home/zuul/ci-framework-data/logs` | Remote directory for log files. |
44+
| `artifacts_dir_zuul` | `/home/zuul/ci-framework-data/artifacts` | Directory for generated artifacts. |
45+
| `ck_synth_script` | `{{ role_path }}/files/gen_synth_loki_data.py` | Path to the synthetic data generation script. |
46+
| `ck_data_template` | `{{ role_path }}/template/loki_data_templ.j2` | Path to the Jinja2 template for Loki data format. |
47+
| `ck_data_config` | `{{ role_path }}/files/test_static.yml` | Path to the scenario configuration file. |
48+
| `ck_output_file_local` | `{{ artifacts_dir_zuul }}/loki_synth_data.json` | Local path for generated synthetic data. |
49+
| `ck_output_file_remote` | `{{ logs_dir_zuul }}/gen_loki_synth_data.log` | Remote destination for synthetic data. |
50+
51+
Scenario Configuration
52+
----------------------
53+
The synthetic data generation is controlled by a YAML configuration file (`files/test_static.yml`). This file defines:
54+
55+
* **generation** - Time range configuration (days, step_seconds)
56+
* **log_types** - List of log type definitions with name, type, unit, qty, price, groupby, and metadata
57+
* **required_fields** - Fields required for validation
58+
* **date_fields** - Date fields to add to groupby (week_of_the_year, day_of_the_year, month, year)
59+
* **loki_stream** - Loki stream configuration (service name)
60+
2761
Dependencies
2862
------------
2963
This role has no direct hard dependencies on other Ansible roles.
@@ -36,7 +70,7 @@ Example Playbook
3670
gather_facts: no
3771

3872
tasks:
39-
- name: "Run chargeback specific tests"
73+
- name: "Run chargeback specific tests"
4074
ansible.builtin.import_role:
4175
name: telemetry_chargeback
4276
```

0 commit comments

Comments
 (0)