Skip to content

Commit 3b1a680

Browse files
committed
feat(telco-kpis): Add RDS compare test
Add RDS (Reference Design Spec) comparison test for validating spoke cluster configuration against reference deployments. ## Features **Playbook:** playbooks/telco-kpis/run-rds-compare.yml **Task:** tasks/run-rds-compare-test.yml **Implementation:** - Ensures test-runner container image exists before execution - Uses kubectl-cluster_compare tool (added to test-runner Containerfile) - Mounts spoke-specific artifact directory for report generation - Artifacts mounted to both /workspace/reports/podman-runs and /workspace/reports/rds-compare - Generates JUnit XML test results **Container Image Management:** - Checks for kubectl-cluster_compare binary in test-runner image - Uses telco-kpis-test-runner:latest container **Artifact Structure:** - Reports written to /workspace/reports/podman-runs/{spoke}/ - Dual mount paths for compatibility with report generator Related: Telco-KPIs configuration validation Signed-off-by: Carlos Cardenosa <ccardeno@redhat.com>
1 parent 3a886d7 commit 3b1a680

2 files changed

Lines changed: 192 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
# RDS Compare Playbook for Telco-KPIs
3+
# Purpose: Validate spoke cluster against RAN RDS metadata from telco-reference
4+
# Required parameters:
5+
# - spoke_cluster: Spoke cluster name
6+
# - spoke_kubeconfig: Path to spoke kubeconfig
7+
# - version: OCP version (maps to telco-reference branch)
8+
# - reference_repo_url: telco-reference Git repository URL
9+
# - metadata_relpath: Path to metadata.yaml within repo
10+
# Optional parameters:
11+
# - reference_branch: Override telco-reference branch (default: release-${version})
12+
# - compare_extra_args: Extra arguments for kubectl-cluster_compare
13+
# - baseline: Baseline mode (collect results without failing on mismatches)
14+
15+
- name: Run RDS comparison validation on spoke cluster
16+
hosts: bastion
17+
gather_facts: true
18+
tasks:
19+
- name: Load telco-kpis default configuration
20+
ansible.builtin.include_role:
21+
name: telco-kpis-defaults
22+
23+
24+
- name: Validate spoke_cluster parameter
25+
ansible.builtin.fail:
26+
msg: "spoke_cluster parameter is required"
27+
when: spoke_cluster is not defined or spoke_cluster == ''
28+
29+
- name: Validate spoke_kubeconfig parameter
30+
ansible.builtin.fail:
31+
msg: "spoke_kubeconfig parameter is required"
32+
when: spoke_kubeconfig is not defined or spoke_kubeconfig == ''
33+
34+
- name: Validate version parameter
35+
ansible.builtin.fail:
36+
msg: "version parameter is required"
37+
when: version is not defined or version == ''
38+
39+
- name: Validate reference_repo_url parameter
40+
ansible.builtin.fail:
41+
msg: "reference_repo_url parameter is required"
42+
when: reference_repo_url is not defined or reference_repo_url == ''
43+
44+
- name: Validate metadata_relpath parameter
45+
ansible.builtin.fail:
46+
msg: "metadata_relpath parameter is required"
47+
when: metadata_relpath is not defined or metadata_relpath == ''
48+
49+
- name: Execute RDS comparison tasks
50+
ansible.builtin.include_tasks: "tasks/run-rds-compare-test.yml"
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
# RDS Compare Test task for Telco-KPIs
3+
# Purpose: Validate spoke cluster against RAN RDS metadata from telco-reference
4+
# Output: cluster-compare.log with comparison results
5+
# Uses: kubectl-cluster_compare in podman container
6+
7+
- name: Ensure test-runner container image exists on bastion
8+
ansible.builtin.import_tasks: setup-test-runner.yml
9+
10+
- name: Create artifacts directory on bastion
11+
ansible.builtin.tempfile:
12+
state: directory
13+
suffix: .rds-compare-{{ spoke_cluster }}
14+
path: /tmp
15+
register: artifacts_dir
16+
17+
- name: Display RDS compare configuration
18+
ansible.builtin.debug:
19+
msg:
20+
- "=========================================="
21+
- "RDS Comparison Configuration"
22+
- "=========================================="
23+
- "Spoke Cluster: {{ spoke_cluster }}"
24+
- "OCP Version: {{ version }}"
25+
- "Reference Repo: {{ reference_repo_url }}"
26+
- "Metadata Path: {{ metadata_relpath }}"
27+
- "Baseline Mode: {{ baseline | default(false) }}"
28+
- "Kubeconfig: {{ spoke_kubeconfig }}"
29+
- "Artifacts: {{ artifacts_dir.path }}"
30+
- "=========================================="
31+
32+
- name: Determine reference branch
33+
ansible.builtin.set_fact:
34+
reference_branch: "{{ reference_branch if reference_branch else 'release-' + version }}"
35+
36+
- name: Set telco-reference clone path
37+
ansible.builtin.set_fact:
38+
reference_repo_path: "/tmp/telco-reference-{{ spoke_cluster }}"
39+
40+
- name: Clone or update telco-reference repo on bastion
41+
ansible.builtin.git:
42+
repo: "{{ reference_repo_url }}"
43+
dest: "{{ reference_repo_path }}"
44+
version: "{{ reference_branch }}"
45+
update: yes
46+
force: yes
47+
register: git_clone
48+
49+
- name: Validate metadata file exists
50+
ansible.builtin.stat:
51+
path: "{{ reference_repo_path }}/{{ metadata_relpath }}"
52+
register: metadata_file
53+
failed_when: not metadata_file.stat.exists
54+
55+
- name: Display repository details
56+
ansible.builtin.debug:
57+
msg:
58+
- "Repository: {{ reference_repo_path }}"
59+
- "Branch: {{ reference_branch }}"
60+
- "Commit: {{ git_clone.after }}"
61+
- "Metadata: {{ metadata_relpath }}"
62+
63+
- name: Ensure kubeconfig is readable by podman container
64+
ansible.builtin.file:
65+
path: "{{ spoke_kubeconfig }}"
66+
mode: '0644'
67+
68+
- name: Run kubectl-cluster_compare in podman container
69+
ansible.builtin.shell: |
70+
podman run --rm \
71+
-v {{ spoke_kubeconfig }}:/tmp/kubeconfig-ro:ro,Z \
72+
-v {{ reference_repo_path }}:/workspace/reference:ro,Z \
73+
-v {{ artifacts_dir.path }}:/workspace/artifacts:rw,Z \
74+
-e KUBECONFIG=/tmp/kubeconfig-ro \
75+
telco-kpis-test-runner:latest \
76+
bash -c "
77+
set -euo pipefail
78+
cd /workspace/reference
79+
echo '[INFO] Running kubectl-cluster_compare'
80+
echo '[INFO] Metadata: {{ metadata_relpath }}'
81+
echo '[INFO] Extra args: {{ compare_extra_args | default('(none)') }}'
82+
set +e
83+
kubectl-cluster_compare -r '{{ metadata_relpath }}' {{ compare_extra_args | default('') }} 2>&1 | tee /workspace/artifacts/cluster-compare.log
84+
exit \${PIPESTATUS[0]}
85+
"
86+
register: compare_result
87+
failed_when: false
88+
changed_when: false
89+
90+
- name: Count comparison results
91+
ansible.builtin.set_fact:
92+
compare_exit_code: "{{ compare_result.rc }}"
93+
compare_success: "{{ compare_result.rc == 0 }}"
94+
95+
- name: Display comparison summary
96+
ansible.builtin.debug:
97+
msg:
98+
- "=========================================="
99+
- "RDS Comparison Summary"
100+
- "=========================================="
101+
- "Exit Code: {{ compare_exit_code }}"
102+
- "Status: {{ 'PASS (all resources match)' if compare_success else 'FAIL (mismatches found)' }}"
103+
- "Baseline Mode: {{ 'Yes (non-failing)' if (baseline | default(false)) else 'No' }}"
104+
- "Log: {{ artifacts_dir.path }}/cluster-compare.log"
105+
- "=========================================="
106+
107+
- name: Manage test artifacts (collect, share, report)
108+
ansible.builtin.include_role:
109+
name: artifact-management
110+
vars:
111+
artifact_management_test_name: "rds-compare"
112+
artifact_management_spoke_cluster: "{{ spoke_cluster }}"
113+
artifact_management_temp_dir: "{{ artifacts_dir.path }}"
114+
artifact_management_test_rc: "{{ compare_result.rc }}"
115+
artifact_management_test_duration: "600" # RDS compare doesn't have duration, use default
116+
117+
- name: Cleanup artifacts directory on bastion
118+
ansible.builtin.file:
119+
path: "{{ artifacts_dir.path }}"
120+
state: absent
121+
122+
- name: Cleanup telco-reference clone on bastion
123+
ansible.builtin.file:
124+
path: "{{ reference_repo_path }}"
125+
state: absent
126+
127+
- name: Fail if comparison found mismatches (unless baseline mode)
128+
ansible.builtin.fail:
129+
msg: "RDS comparison failed: cluster state does not match reference metadata. Review cluster-compare.log for details."
130+
when:
131+
- not compare_success
132+
- not (baseline | default(false))
133+
134+
- name: Display completion message
135+
ansible.builtin.debug:
136+
msg:
137+
- "=========================================="
138+
- "RDS Comparison Complete"
139+
- "=========================================="
140+
- "Result: {{ 'PASSED' if compare_success else ('BASELINE COLLECTED' if (baseline | default(false)) else 'FAILED') }}"
141+
- "Comparison log saved to artifacts"
142+
- "=========================================="

0 commit comments

Comments
 (0)