Skip to content

Commit ec77572

Browse files
committed
Determine API versions based on observability startegy
Depending on the observability strategy that STF uses, observability components will be installed from community or Red hat sources. These crate the same CRDs, but with different APIs e.g. prometheusrules.monitoring.rhobs vs prometheusrules.monitoring.coreos.com. An apiVersion needs to be set when creating these resources during the tests, and the tests will fail if the correct version is not available. The test_alerts role will select which observability APIs to use based on which observability_straegy is set. The tests will also explicitly use the fully qualified name of the objects using ``oc get``. The following roles are updated: * test_alerts * test_verify_email
1 parent e7ee198 commit ec77572

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: "Get the observability strategy"
3+
ansible.builtin.shell:
4+
cmd: |
5+
oc get stf default -ojsonpath='{.spec.observabilityStrategy}'
6+
changed_when: false
7+
register: observability_strategy
8+
9+
- name: "Set the observability api based on the observability strategy"
10+
ansible.builtin.set_fact:
11+
observability_api: "{{ 'monitoring.rhobs' if observability_strategy.stdout == 'use_redhat' else 'monitoring.coreos.com' }}"
12+

roles/test_alerts/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
2+
- name: "Get the observability strategy and set the observability_api"
3+
ansible.builtin.include_tasks:
4+
file: get_observability_api.yml
5+
26
- name: "Test Creating an alert rule in Prometheus"
37
ansible.builtin.include_tasks:
48
file: test_create_an_alert.yml

roles/test_alerts/tasks/test_create_an_alert.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ansible.builtin.shell:
99
cmd: |
1010
oc apply -f - <<EOF
11-
apiVersion: monitoring.coreos.com/v1
11+
apiVersion: {{ observability_api }}/v1
1212
kind: PrometheusRule
1313
metadata:
1414
creationTimestamp: null

roles/test_verify_email/tasks/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
---
22
# tasks file for roles/test_verify_email
33

4+
- name: "Get the observability strategy and set observability_api"
5+
ansible.builtin.include_role:
6+
name: test_alerts
7+
tasks_from: get_observability_api.yml
8+
49
- name: "RHELOSP-176042"
510
# "Create the alert"
611
ansible.builtin.shell:
712
cmd: |
813
oc apply -f - <<EOF
9-
apiVersion: monitoring.coreos.com/v1
14+
apiVersion: {{ observability_api }}/v1
1015
kind: PrometheusRule
1116
metadata:
1217
creationTimestamp: null

0 commit comments

Comments
 (0)