Skip to content

Commit fa7d242

Browse files
committed
Adding the rating calculations for uploaded and downloaded
data. This data will then be validated
1 parent 2c16339 commit fa7d242

File tree

9 files changed

+163
-323
lines changed

9 files changed

+163
-323
lines changed

roles/telemetry_chargeback/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ These variables are used internally by the role and typically do not need to be
4646
| `cloudkitty_scenario_dir` | `{{ role_path }}/files` | Directory containing scenario files (`test_*.yml`). |
4747
| `cloudkitty_synth_data_suffix` | `-synth_data.json` | Suffix for generated synthetic data files. |
4848
| `cloudkitty_loki_data_suffix` | `-loki_data.json` | Suffix for Loki query result JSON files. |
49-
| `cloudkitty_synth_totals_suffix` | `-synth_metrics_totals.yml` | Suffix for generated metric totals files (from synthetic data). |
50-
| `cloudkitty_loki_totals_suffix` | `-loki_totals.yml` | Suffix for CloudKitty rating summary output files (from loki_rate task). |
51-
| `cloudkitty_loki_totals_metrics_suffix` | `-loki_metrics_totals.yml` | Suffix for metric totals computed from Loki-retrieved JSON (retrieve_loki_data task). |
49+
| `cloudkitty_synth_totals_metrics_suffix` | `-synth_metrics_summary.yml` | Suffix for YAML totals from synthetic JSON (`gen_db_summary.py`). |
50+
| `cloudkitty_loki_totals_suffix` | `-rating.yml` | Suffix for CloudKitty `openstack rating summary` text saved by `loki_rate.yml`. |
51+
| `cloudkitty_loki_totals_metrics_suffix` | `-loki_metrics_summary.yml` | Suffix for YAML from Loki-retrieved JSON (`gen_db_summary.py` in `retrieve_loki_data.yml`). |
5252
| `cloudkitty_synth_script` | `{{ role_path }}/files/gen_synth_loki_data.py` | Path to the synthetic data generation script. |
5353
| `cloudkitty_data_template` | `{{ role_path }}/templates/loki_data_templ.j2` | Path to the Jinja2 template for Loki data format. |
5454
| `cloudkitty_summary_script` | `{{ role_path }}/files/gen_db_summary.py` | Path to the summary script (gen_db_summary.py). |
@@ -87,13 +87,15 @@ Loki push/query URLs are set dynamically in `setup_loki_env.yml` from the Cloudk
8787
| `-r`, `--reverse` | Reverse timestamp order in JSON output (youngest first, oldest last). |
8888
| `--debug` | Enable debug logging. |
8989

90-
**gen_synth_loki_metrics_totals.py** — Reads the synthetic (or Loki-retrieved) JSON and writes a YAML with aggregated metrics and time bounds. The output is used by the role for validation and for the Loki query time range.
90+
**gen_db_summary.py** (`cloudkitty_summary_script`) — This is what the role runs for **both** synthetic totals and Loki-retrieved totals (`gen_synth_loki_data.yml` and `retrieve_loki_data.yml`). It parses Loki-style JSON (streams or `data.result`), sorts entries by timestamp, and writes a single YAML summary used for assertions and for the Loki query window (`time.begin_step.nanosec`).
9191

9292
Output YAML structure:
9393

94-
* **time**`begin`, `end` (ISO strings), `begin_nano`, `end_nano` (nanosecond timestamps for the first and last time step; used by the Loki query in `retrieve_loki_data.yml`).
95-
* **data_log**`total_time_steps`, `metrics_per_step`, `log_count`.
96-
* **synth_rate** — Per-metric rates and `total_rate`.
94+
* **time**`begin_step` / `end_step`, each with `nanosec`, `begin`, `end` (ISO window strings from the log payload).
95+
* **data_log**`total_timesteps`, `metrics_per_step`, `log_count`.
96+
* **rate**`by_types` (per-type `Rate`) and `total.Rating`.
97+
98+
**gen_synth_loki_metrics_totals.py** — Standalone helper that also reads Loki JSON and emits YAML totals, but with a **different schema** (flat `time` with `begin_nano` / `end_nano`, `data_log.total_time_steps`, and a flat `synth_rate` map including `total_rate`). The role does **not** invoke it; it remains in the repo for manual runs, one-off comparisons, or older workflows. Prefer `gen_db_summary.py` for anything that must match the role’s artifacts and `retrieve_loki_data.yml` expectations.
9799

98100
### Dynamically Set Variables
99101

@@ -109,7 +111,7 @@ Set in **gen_synth_loki_data.yml** for each scenario file during the loop:
109111
| Variable | Description |
110112
|----------|-------------|
111113
| `cloudkitty_data_file` | Local path for generated JSON data (`{{ artifacts_dir_zuul }}/{{ scenario_name }}-synth_data.json`) |
112-
| `cloudkitty_synth_totals_file` | Local path for calculated metric totals (`{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_synth_totals_suffix }}`) |
114+
| `cloudkitty_synth_totals_file` | Local path for calculated metric totals (`{{ artifacts_dir_zuul }}/{{ scenario_name }}{{ cloudkitty_synth_totals_metrics_suffix }}`) |
113115
| `cloudkitty_test_file` | Path to the scenario configuration file (`{{ cloudkitty_scenario_dir }}/{{ scenario_name }}.yml`) |
114116

115117
Scenario Configuration

0 commit comments

Comments
 (0)