Skip to content

Commit ea91306

Browse files
Merge pull request #753 from Tai-RedHat/coo-1562
COO-1562: update acm alerting UI test case
2 parents 57ecd27 + 1628224 commit ea91306

3 files changed

Lines changed: 90 additions & 17 deletions

File tree

web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// 02.acm_alerting_ui.cy.ts
22
// E2E test for validating ACM Alerting UI integration with Cluster Observability Operator (COO)
33
import '../../support/commands/auth-commands';
4+
import { commonPages } from '../../views/common';
45
import { nav } from '../../views/nav';
56
import { acmAlertingPage } from '../../views/acm-alerting-page';
67

@@ -25,9 +26,11 @@ describe('ACM Alerting UI', { tags: ['@coo', '@alerts'] }, () => {
2526
});
2627

2728
it('Navigate to Fleet Management > local-cluster > Observe > Alerting', () => {
28-
// wait for console page loading completed
29-
cy.visit('/');
30-
cy.get('body', { timeout: 60000 }).should('contain.text', 'Administrator');
29+
// check monitoring-plugin UI is not been affected
30+
nav.sidenav.clickNavLink(['Observe', 'Alerting']);
31+
commonPages.titleShouldHaveText('Alerting')
32+
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
33+
commonPages.titleShouldHaveText('Metrics');
3134
// switch to Fleet Management page
3235
cy.switchPerspective('Fleet Management');
3336
// close pop-up window
@@ -42,14 +45,11 @@ describe('ACM Alerting UI', { tags: ['@coo', '@alerts'] }, () => {
4245
});
4346
// click side menu -> Observe -> Alerting
4447
nav.sidenav.clickNavLink(['Observe', 'Alerting']);
45-
// Wait for alert tab content to become visible
46-
cy.get('section#alerts-tab-content', { timeout: 60000 })
47-
.should('be.visible');
4848
// confirm Alerting page loading completed
4949
acmAlertingPage.shouldBeLoaded();
50-
// check three test alerts exist
50+
// check test alerts exist
5151
expectedAlerts.forEach((alert) => {
52-
cy.contains('a[data-test-id="alert-resource-link"]', alert, { timeout: 60000 })
52+
cy.contains('a[data-test-id="alert-resource-link"]', alert, { timeout: 120000 })
5353
.should('be.visible');
5454
});
5555
cy.log('Verified all expected alerts are visible on the Alerting page');

web/cypress/fixtures/coo/acm-install.sh

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
#!/bin/bash
2-
set -eux
3-
oc patch Scheduler cluster --type='json' -p '[{ "op": "replace", "path": "/spec/mastersSchedulable", "value": true }]'
2+
#set -eux
3+
set -x
4+
# This script will install ACM, MCH, MCO, and other test resources.
5+
# The script will skip installation when MCO CR existed.
46

7+
echo "[INFO] Checking for existing MultiClusterObservability CR..."
8+
MCO_NAMESPACE="open-cluster-management-observability"
9+
MCO_NAME="observability"
10+
# The 'oc get ...' command will have a non-zero exit code if the resource is not found.
11+
if oc get multiclusterobservability ${MCO_NAME} -n ${MCO_NAMESPACE} >/dev/null 2>&1; then
12+
echo "[INFO] MultiClusterObservability CR '${MCO_NAME}' already exists in '${MCO_NAMESPACE}'."
13+
echo "[INFO] Skipping installation to avoid conflicts and assuming a previous step is managing it."
14+
exit 0
15+
else
16+
echo "[INFO] No existing MultiClusterObservability CR found. Proceeding with installation."
17+
fi
18+
# patch node
19+
oc patch Scheduler cluster --type='json' -p '[{ "op": "replace", "path": "/spec/mastersSchedulable", "value": true }]'
20+
# install acm
521
oc apply -f - <<EOF
622
apiVersion: v1
723
kind: Namespace
@@ -43,6 +59,7 @@ while [[ $tries -gt 0 ]] &&
4359
((tries--))
4460
done
4561
oc wait -n open-cluster-management --for=condition=Available deploy/multiclusterhub-operator --timeout=300s
62+
# install mch
4663
oc apply -f - <<EOF
4764
apiVersion: operator.open-cluster-management.io/v1
4865
kind: MultiClusterHub
@@ -56,7 +73,7 @@ oc wait -n open-cluster-management --for=condition=Available deploy/search-api -
5673
oc wait -n open-cluster-management --for=condition=Available deploy/search-collector --timeout=300s
5774
oc wait -n open-cluster-management --for=condition=Available deploy/search-indexer --timeout=300s
5875
oc -n open-cluster-management get pod
59-
#create multi-cluster
76+
# create mco
6077
if ! oc get ns open-cluster-management-observability >/dev/null 2>&1; then
6178
echo "[INFO] Creating namespace open-cluster-management-observability"
6279
oc create ns open-cluster-management-observability
@@ -168,5 +185,64 @@ spec:
168185
EOF
169186
sleep 1m
170187
oc wait --for=condition=Ready pod -l alertmanager=observability,app=multicluster-observability-alertmanager -n open-cluster-management-observability --timeout=300s
171-
oc -n open-cluster-management-observability get pod
172-
oc -n open-cluster-management-observability get svc | grep -E 'alertmanager|rbac-query'
188+
# enable UIPlugin
189+
oc apply -f - <<EOF
190+
apiVersion: observability.openshift.io/v1alpha1
191+
kind: UIPlugin
192+
metadata:
193+
name: monitoring
194+
spec:
195+
monitoring:
196+
acm:
197+
enabled: true
198+
alertmanager:
199+
url: 'https://alertmanager.open-cluster-management-observability.svc:9095'
200+
thanosQuerier:
201+
url: 'https://rbac-query-proxy.open-cluster-management-observability.svc:8443'
202+
type: Monitoring
203+
EOF
204+
# apply custom-rules
205+
oc apply -f - <<EOF
206+
apiVersion: v1
207+
kind: ConfigMap
208+
metadata:
209+
name: thanos-ruler-custom-rules
210+
namespace: open-cluster-management-observability
211+
data:
212+
custom_rules.yaml: |
213+
groups:
214+
- name: alertrule-testing
215+
rules:
216+
- alert: Watchdog
217+
annotations:
218+
summary: An alert that should always be firing to certify that Alertmanager is working properly.
219+
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
220+
expr: vector(1)
221+
labels:
222+
instance: "local"
223+
cluster: "local"
224+
clusterID: "111111111"
225+
severity: info
226+
- alert: Watchdog-spoke
227+
annotations:
228+
summary: An alert that should always be firing to certify that Alertmanager is working properly.
229+
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
230+
expr: vector(1)
231+
labels:
232+
instance: "spoke"
233+
cluster: "spoke"
234+
clusterID: "22222222"
235+
severity: warn
236+
- name: cluster-health
237+
rules:
238+
- alert: ClusterCPUHealth-jb
239+
annotations:
240+
summary: Notify when CPU utilization on a cluster is greater than the defined utilization limit
241+
description: "The cluster has a high CPU usage: core for"
242+
expr: |
243+
max(cluster:cpu_usage_cores:sum) by (clusterID, cluster, prometheus) > 0
244+
labels:
245+
cluster: "{{ $labels.cluster }}"
246+
prometheus: "{{ $labels.prometheus }}"
247+
severity: critical
248+
EOF

web/cypress/support/commands/operator-commands.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,15 +896,12 @@ Cypress.Commands.add('beforeBlock', (MP: { namespace: string, operatorName: stri
896896

897897
Cypress.Commands.add('beforeBlockACM', (MCP, MP) => {
898898
cy.beforeBlockCOO(MCP, MP);
899-
cy.log('=== [Setup] Installing ACM Operator & MCO ===');
899+
cy.log('=== [Setup] Installing ACM test resources ===');
900900
cy.exec('bash ./cypress/fixtures/coo/acm-install.sh', {
901901
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH'), },
902902
failOnNonZeroExit: false,
903903
timeout: 1200000, // long time script
904904
});
905-
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-uiplugin.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
906-
// add example alerts for test
907-
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-alerrule-test.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
908905
cy.log('ACM environment setup completed');
909906
});
910907

0 commit comments

Comments
 (0)