Skip to content

Commit b25ee6c

Browse files
myadlaayefimov-1
authored andcommitted
Add run_chargeback_tests playbook
AI assisted
1 parent 3884754 commit b25ee6c

8 files changed

Lines changed: 199 additions & 23 deletions

File tree

.zuul.yaml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,27 @@
156156
irrelevant-files: *irrelevant_files
157157
required-projects: *required_projects
158158

159+
- job:
160+
name: functional-chargeback-tests-osp18
161+
parent: telemetry-operator-multinode-cloudkitty
162+
description: |
163+
Alias of telemetry-operator-multinode-cloudkitty for testing
164+
irrelevant-files: []
165+
roles:
166+
- zuul: github.com/openstack-k8s-operators/ci-framework
167+
- zuul: github.com/infrawatch/feature-verification-tests
168+
required-projects:
169+
- name: github.com/openstack-k8s-operators/telemetry-operator
170+
override-checkout: main
171+
- name: github.com/infrawatch/feature-verification-tests
172+
vars:
173+
cifmw_extras:
174+
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir }}/scenarios/centos-9/multinode-ci.yml"
175+
# Need a config for CK
176+
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/telemetry-operator'].src_dir }}/ci/vars-cloudkitty-tempest.yml"
177+
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-use-master-containers.yml"
178+
- "@{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/vars-cloudkitty-fvt.yml"
179+
159180
- project:
160181
name: infrawatch/feature-verification-tests
161182
periodic:
@@ -167,26 +188,7 @@
167188
jobs:
168189
- telemetry-openstack-meta-content-provider-master:
169190
override-checkout: main
170-
- feature-verification-tests-noop:
171-
files: *irrelevant_files
172-
- functional-tests-osp18
173-
- functional-logging-tests-osp18:
174-
irrelevant-files: *irrelevant_files
175-
files:
176-
- roles/telemetry_logging/.*
177-
- roles/common/*
178-
- .zuul.yaml
179-
- ci/vars-logging-test.yml
180-
- ci/logging_tests_all.yml
181-
- ci/logging_tests_computes.yml
182-
- ci/logging_tests_controller.yml
183-
- ci/report_result.yml
184-
- .zuul.yaml
185-
- functional-periodic-telemetry-with-ceph:
186-
files:
187-
# Run this job for changes to the volume_pool_metrics test changes as this is
188-
# the only job, where those tests get executed and for changes to zuul.yaml in
189-
# case the job definition changes.
190-
- roles/telemetry_verify_metrics/tasks/verify_ceilometer_volume_pool_metrics.yml
191-
- .zuul.yaml
192-
191+
- functional-chargeback-tests-osp18:
192+
override-checkout: main
193+
dependencies:
194+
- telemetry-openstack-meta-content-provider-master

ci/run_chargeback_tests.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
- name: "Verify all the applicable projects, endpoints, pods & services for cloudkitty"
3+
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4+
gather_facts: no
5+
ignore_errors: true
6+
environment:
7+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
8+
PATH: "{{ cifmw_path }}"
9+
vars_files:
10+
- vars/osp18_env.yml
11+
vars:
12+
common_pod_status_str: "Running"
13+
common_pod_nspace: openstack
14+
common_pod_list:
15+
- cloudkitty-api
16+
- cloudkitty-lokistack-compactor
17+
- cloudkitty-lokistack-distributor
18+
# pod tests expect only one instance of a pod, there are two of this one
19+
# Some work is needed on the pod tests to deal with this test case
20+
#- cloudkitty-lokistack-gateway
21+
- cloudkitty-lokistack-index-gateway
22+
- cloudkitty-lokistack-ingester
23+
- cloudkitty-lokistack-querier
24+
- cloudkitty-lokistack-query-frontend
25+
- cloudkitty-proc
26+
27+
common_project_list:
28+
- openstack
29+
- openstack-operators
30+
31+
common_endpoint_list:
32+
- [cloudkitty,rating,public]
33+
- [cloudkitty,rating,internal]
34+
35+
common_service_nspace: openstack
36+
common_service_list:
37+
- cloudkitty-internal
38+
- cloudkitty-lokistack-compactor-grpc
39+
- cloudkitty-lokistack-compactor-http
40+
- cloudkitty-lokistack-distributor-grpc
41+
- cloudkitty-lokistack-distributor-http
42+
- cloudkitty-lokistack-gateway-http
43+
- cloudkitty-lokistack-gossip-ring
44+
- cloudkitty-lokistack-index-gateway-grpc
45+
- cloudkitty-lokistack-index-gateway-http
46+
- cloudkitty-lokistack-ingester-grpc
47+
- cloudkitty-lokistack-ingester-http
48+
- cloudkitty-lokistack-querier-grpc
49+
- cloudkitty-lokistack-querier-http
50+
- cloudkitty-lokistack-query-frontend-grpc
51+
- cloudkitty-lokistack-query-frontend-http
52+
- cloudkitty-public
53+
54+
tasks:
55+
- name: "Verify cloudkitty infrastructure components"
56+
ansible.builtin.import_role:
57+
name: common
58+
59+
- name: "Verify cloudkitty deployment"
60+
ansible.builtin.import_role:
61+
name: telemetry_chargeback

ci/vars-cloudkitty-fvt.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
pre_tests_01_run_chargeback_tests:
3+
source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/run_chargeback_tests.yml"
4+
type: playbook
5+
config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
telemetry_chargeback
2+
=========
3+
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.
4+
5+
Requirements
6+
------------
7+
It relies on the following being available on the target or control host:
8+
9+
* This role requires **Ansible 2.9** or newer.
10+
* The **OpenStack CLI client** must be installed and configured with administrative credentials.
11+
* Required Python libraries for the `openstack` CLI (e.g., `python3-openstackclient`).
12+
* Connectivity to the OpenStack API endpoint.
13+
14+
It is expected to be run **after** a successful deployment and configuration of the following components:
15+
16+
* **OpenStack:** A functional OpenStack cloud (RHOSO) environment.
17+
* **Cloudkitty:** The Cloudkitty service must be installed, configured, and running.
18+
19+
Role Variables
20+
--------------
21+
The role uses a few primary variables to control the testing environment and execution.
22+
23+
| Variable | Default Value | Description |
24+
|----------|---------------|-------------|
25+
| `openstack_cmd` | `openstack` | The command used to execute OpenStack CLI calls. This can be customized if the binary is not in the standard PATH. |
26+
27+
Dependencies
28+
------------
29+
This role has no direct hard dependencies on other Ansible roles.
30+
31+
Example Playbook
32+
----------------
33+
Each tasks/playbook.yml should be called independently via "ansible.builtin.import_role" with appropriate vars passed:
34+
35+
```yaml
36+
- name: "Run chargeback tests"
37+
hosts: controllers
38+
gather_facts: no
39+
40+
tasks:
41+
- name: "Run chargeback specific tests"
42+
ansible.builtin.import_role:
43+
name: telemetry_chargeback
44+
```
45+
46+
Author Information
47+
------------------
48+
49+
Alex Yefimov, Red Hat
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
openstack_cmd: "openstack"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
galaxy_info:
3+
author: Alex Yefimov
4+
description: Tests the chargeback feature is set up in OpenStack running on OpenShift
5+
company: Red Hat
6+
7+
license: Apache-2.0
8+
9+
min_ansible_version: "2.1"
10+
11+
galaxy_tags: []
12+
13+
dependencies: []
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
- name: Enable Cloudkitty Module (hashmap)
3+
ansible.builtin.command:
4+
cmd: "{{ openstack_cmd }} rating module enable hashmap"
5+
register: enable_hashmap
6+
changed_when: True
7+
failed_when: enable_hashmap.rc != 0
8+
9+
- name: Find the current value of hashmap
10+
ansible.builtin.shell:
11+
cmd: "{{ openstack_cmd }} rating module get hashmap -c Priority -f csv | tail -n +2"
12+
register: get_hashmap_priority
13+
changed_when: false
14+
15+
- name: Change priority for CloudKitty hashmap module
16+
ansible.builtin.command:
17+
cmd: "{{ openstack_cmd }} rating module set priority hashmap 100"
18+
register: set_hashmap_priority
19+
when: get_hashmap_priority.stdout | trim != '100'
20+
failed_when: set_hashmap_priority.rc >= 1 or get_hashmap_priority.stdout == ""
21+
changed_when: True
22+
23+
- name: Get status of all CloudKitty rating modules
24+
ansible.builtin.command:
25+
cmd: "{{ openstack_cmd }} rating module list"
26+
changed_when: false
27+
register: module_list
28+
29+
- name: TEST Validate CloudKitty module states
30+
ansible.builtin.assert:
31+
that:
32+
- "'hashmap' in module_list.stdout and 'True' in (module_list.stdout_lines | select('search', 'hashmap') | first)"
33+
fail_msg: "FAILED: CloudKitty module validation failed . Module states are not as expected."
34+
success_msg: "SUCCESS: CloudKitty modules (hashmap=True) are configured correctly."
35+
36+
- name: TEST Set priority for CloudKitty hashmap module
37+
ansible.builtin.assert:
38+
that:
39+
- "(get_hashmap_priority.stdout | trim == '100') or (set_hashmap_priority.rc is defined and set_hashmap_priority.rc == 0)"
40+
fail_msg: "FAILED: The hashmap priority is not set to 100"
41+
success_msg: "SUCCESS: The hashmap priority is set to 100"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- name: "Validate Chargeback Feature"
3+
ansible.builtin.include_tasks: "chargeback_tests.yml"

0 commit comments

Comments
 (0)