From 1628224d665f0a21ce595725dbfce4773e9764ea Mon Sep 17 00:00:00 2001 From: Tai Gao Date: Thu, 5 Feb 2026 16:28:08 +0800 Subject: [PATCH] update acm alerting UI test case --- web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts | 16 ++-- web/cypress/fixtures/coo/acm-install.sh | 86 +++++++++++++++++-- .../support/commands/operator-commands.ts | 5 +- 3 files changed, 90 insertions(+), 17 deletions(-) diff --git a/web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts b/web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts index 58b72fe87..248b95d1d 100644 --- a/web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts +++ b/web/cypress/e2e/coo/02.acm_alerting_ui.cy.ts @@ -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'; @@ -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 @@ -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'); diff --git a/web/cypress/fixtures/coo/acm-install.sh b/web/cypress/fixtures/coo/acm-install.sh index 661bd0a1f..893e9ed0d 100755 --- a/web/cypress/fixtures/coo/acm-install.sh +++ b/web/cypress/fixtures/coo/acm-install.sh @@ -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 - </dev/null 2>&1; then echo "[INFO] Creating namespace open-cluster-management-observability" oc create ns open-cluster-management-observability @@ -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 - < 0 + labels: + cluster: "{{ $labels.cluster }}" + prometheus: "{{ $labels.prometheus }}" + severity: critical +EOF diff --git a/web/cypress/support/commands/operator-commands.ts b/web/cypress/support/commands/operator-commands.ts index 927ace76d..6710fd621 100644 --- a/web/cypress/support/commands/operator-commands.ts +++ b/web/cypress/support/commands/operator-commands.ts @@ -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'); });