Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 02.acm_alerting_ui.cy.ts
// E2E test for validating ACM Alerting UI integration with Cluster Observability Operator (COO)
import '../../support/commands/auth-commands';
import { commonPages } from '../../views/common';
import { nav } from '../../views/nav';
import { acmAlertingPage } from '../../views/acm-alerting-page';

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

it('Navigate to Fleet Management > local-cluster > Observe > Alerting', () => {
// wait for console page loading completed
cy.visit('/');
cy.get('body', { timeout: 60000 }).should('contain.text', 'Administrator');
// check monitoring-plugin UI is not been affected
nav.sidenav.clickNavLink(['Observe', 'Alerting']);
commonPages.titleShouldHaveText('Alerting')
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
commonPages.titleShouldHaveText('Metrics');
// switch to Fleet Management page
cy.switchPerspective('Fleet Management');
// close pop-up window
Expand All @@ -42,14 +45,11 @@ describe('ACM Alerting UI', { tags: ['@coo', '@alerts'] }, () => {
});
// click side menu -> Observe -> Alerting
nav.sidenav.clickNavLink(['Observe', 'Alerting']);
// Wait for alert tab content to become visible
cy.get('section#alerts-tab-content', { timeout: 60000 })
.should('be.visible');
// confirm Alerting page loading completed
acmAlertingPage.shouldBeLoaded();
// check three test alerts exist
// check test alerts exist
expectedAlerts.forEach((alert) => {
cy.contains('a[data-test-id="alert-resource-link"]', alert, { timeout: 60000 })
cy.contains('a[data-test-id="alert-resource-link"]', alert, { timeout: 120000 })
.should('be.visible');
});
cy.log('Verified all expected alerts are visible on the Alerting page');
Expand Down
86 changes: 81 additions & 5 deletions web/cypress/fixtures/coo/acm-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#!/bin/bash
set -eux
oc patch Scheduler cluster --type='json' -p '[{ "op": "replace", "path": "/spec/mastersSchedulable", "value": true }]'
#set -eux
set -x
# This script will install ACM, MCH, MCO, and other test resources.
# The script will skip installation when MCO CR existed.

echo "[INFO] Checking for existing MultiClusterObservability CR..."
MCO_NAMESPACE="open-cluster-management-observability"
MCO_NAME="observability"
# The 'oc get ...' command will have a non-zero exit code if the resource is not found.
if oc get multiclusterobservability ${MCO_NAME} -n ${MCO_NAMESPACE} >/dev/null 2>&1; then
echo "[INFO] MultiClusterObservability CR '${MCO_NAME}' already exists in '${MCO_NAMESPACE}'."
echo "[INFO] Skipping installation to avoid conflicts and assuming a previous step is managing it."
exit 0
else
echo "[INFO] No existing MultiClusterObservability CR found. Proceeding with installation."
fi
# patch node
oc patch Scheduler cluster --type='json' -p '[{ "op": "replace", "path": "/spec/mastersSchedulable", "value": true }]'
# install acm
oc apply -f - <<EOF
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -43,6 +59,7 @@ while [[ $tries -gt 0 ]] &&
((tries--))
done
oc wait -n open-cluster-management --for=condition=Available deploy/multiclusterhub-operator --timeout=300s
# install mch
oc apply -f - <<EOF
apiVersion: operator.open-cluster-management.io/v1
kind: MultiClusterHub
Expand All @@ -56,7 +73,7 @@ oc wait -n open-cluster-management --for=condition=Available deploy/search-api -
oc wait -n open-cluster-management --for=condition=Available deploy/search-collector --timeout=300s
oc wait -n open-cluster-management --for=condition=Available deploy/search-indexer --timeout=300s
oc -n open-cluster-management get pod
#create multi-cluster
# create mco
if ! oc get ns open-cluster-management-observability >/dev/null 2>&1; then
echo "[INFO] Creating namespace open-cluster-management-observability"
oc create ns open-cluster-management-observability
Expand Down Expand Up @@ -168,5 +185,64 @@ spec:
EOF
sleep 1m
oc wait --for=condition=Ready pod -l alertmanager=observability,app=multicluster-observability-alertmanager -n open-cluster-management-observability --timeout=300s
oc -n open-cluster-management-observability get pod
oc -n open-cluster-management-observability get svc | grep -E 'alertmanager|rbac-query'
# enable UIPlugin
oc apply -f - <<EOF
apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
name: monitoring
spec:
monitoring:
acm:
enabled: true
alertmanager:
url: 'https://alertmanager.open-cluster-management-observability.svc:9095'
thanosQuerier:
url: 'https://rbac-query-proxy.open-cluster-management-observability.svc:8443'
type: Monitoring
EOF
# apply custom-rules
oc apply -f - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: thanos-ruler-custom-rules
namespace: open-cluster-management-observability
data:
custom_rules.yaml: |
groups:
- name: alertrule-testing
rules:
- alert: Watchdog
annotations:
summary: An alert that should always be firing to certify that Alertmanager is working properly.
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
expr: vector(1)
labels:
instance: "local"
cluster: "local"
clusterID: "111111111"
severity: info
- alert: Watchdog-spoke
annotations:
summary: An alert that should always be firing to certify that Alertmanager is working properly.
description: This is an alert meant to ensure that the entire alerting pipeline is functional.
expr: vector(1)
labels:
instance: "spoke"
cluster: "spoke"
clusterID: "22222222"
severity: warn
- name: cluster-health
rules:
- alert: ClusterCPUHealth-jb
annotations:
summary: Notify when CPU utilization on a cluster is greater than the defined utilization limit
description: "The cluster has a high CPU usage: core for"
expr: |
max(cluster:cpu_usage_cores:sum) by (clusterID, cluster, prometheus) > 0
labels:
cluster: "{{ $labels.cluster }}"
prometheus: "{{ $labels.prometheus }}"
severity: critical
EOF
5 changes: 1 addition & 4 deletions web/cypress/support/commands/operator-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,15 +893,12 @@ Cypress.Commands.add('beforeBlock', (MP: { namespace: string, operatorName: stri

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

Expand Down