Skip to content

Commit 7e9b823

Browse files
committed
enhance install & remove after
1 parent c883fba commit 7e9b823

3 files changed

Lines changed: 50 additions & 52 deletions

File tree

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// 02.acm_alerting_ui.cy.ts
22
// E2E test for validating ACM Alerting UI integration with Cluster Observability Operator (COO)
3-
import { commonPages } from '../../views/common';
4-
import { nav } from '../../views/nav';
5-
63
const MCP = {
74
namespace: 'openshift-cluster-observability-operator',
85
packageName: 'cluster-observability-operator',
@@ -12,12 +9,10 @@ const MCP = {
129
name: 'monitoring',
1310
},
1411
};
15-
1612
const MP = {
1713
namespace: 'openshift-monitoring',
1814
operatorName: 'Cluster Monitoring Operator',
1915
};
20-
2116
const expectedAlerts = ['Watchdog', 'Watchdog-spoke', 'ClusterCPUHealth-jb'];
2217

2318
// ignore error message
@@ -26,27 +21,18 @@ Cypress.on('uncaught:exception', (err) => {
2621
'Unauthorized',
2722
"Cannot read properties of null (reading 'default')",
2823
'ResizeObserver loop limit exceeded',
24+
'Bad Gateway',
25+
'(intermediate value) is not a function',
2926
];
3027
if (ignoreList.some((txt) => err.message.includes(txt))) {
31-
console.warn('⚠️ Ignored frontend exception:', err.message);
28+
console.warn('Ignored frontend exception:', err.message);
3229
return false;
3330
}
3431
});
3532

3633
describe('ACM Alerting UI', () => {
3734
before(() => {
38-
cy.beforeBlockCOO(MCP, MP);
39-
cy.log('=== [Setup] Installing ACM operator and MultiCluster Observability ===');
40-
// install acm through shell script
41-
cy.exec('bash ./cypress/fixtures/coo/acm-install.sh', {
42-
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH'), },
43-
failOnNonZeroExit: false,
44-
timeout: 1200000, // long time script
45-
});
46-
// update UIPlugin with the acm related content, (OCP enabled since installed from operatorHub)
47-
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-uiplugin.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
48-
// add thanos-ruler-custom-rules
49-
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-alerrule-test.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
35+
cy.beforeBlockACM(MCP, MP);
5036
});
5137

5238
it('Navigate to Fleet Management > local-cluster > Observe > Alerting', () => {
@@ -61,52 +47,29 @@ describe('ACM Alerting UI', () => {
6147
.contains('Fleet Management')
6248
.should('be.visible')
6349
.click();
64-
6550
// close pop-up window
66-
cy.get('body').then(($body) => {
67-
const modalCloseBtn = $body.find('button[data-ouia-component-id="clustersOnboardingModal-ModalBoxCloseButton"]');
68-
if (modalCloseBtn.length > 0) {
69-
cy.wrap(modalCloseBtn)
70-
.should('be.visible')
71-
.should('not.be.disabled')
72-
.click({ force: true });
73-
cy.log('✅ Closed onboarding modal');
74-
} else {
75-
cy.log('ℹ️ No onboarding modal found');
76-
}
77-
});
78-
51+
cy.closeOnboardingModalIfPresent();
7952
// click “local-cluster” when visible
80-
cy.contains('a', 'local-cluster', { timeout: 90000 })
53+
cy.log('Waiting for local-cluster link to appear...');
54+
cy.contains('local-cluster', { timeout: 120000 })
55+
.should('exist')
8156
.should('be.visible')
82-
.should('not.be.disabled')
83-
.click({ force: true });
84-
57+
.then(($el) => {
58+
cy.wrap($el).click({ force: true });
59+
});
8560
// click side menu -> Observe -> Alerting
8661
cy.contains('Observe', { timeout: 20000 }).should('be.visible').click();
8762
cy.contains('Alerting', { timeout: 20000 }).should('be.visible').click();
88-
8963
// Wait for alert tab content to become visible
9064
cy.get('section#alerts-tab-content', { timeout: 60000 })
9165
.should('be.visible');
92-
9366
// confirm Alerting page loading completed then check three alert exist
9467
cy.get('body', { timeout: 60000 }).should('contain.text', 'Alerting');
9568
expectedAlerts.forEach((alert) => {
9669
cy.contains('a[data-test-id="alert-resource-link"]', alert, { timeout: 60000 })
9770
.should('be.visible');
9871
});
99-
100-
cy.log('✅ Verified all expected alerts are visible on the Alerting page');
101-
cy.log('✅ ACM Alerting UI test completed successfully');
102-
});
103-
104-
after(() => {
105-
cy.log('=== [Teardown] Uninstalling ACM operator and cleaning up ===');
106-
cy.exec('bash ./cypress/fixtures/coo/acm-uninstall.sh', {
107-
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH') },
108-
failOnNonZeroExit: false,
109-
timeout: 600000,
110-
});
72+
cy.log('Verified all expected alerts are visible on the Alerting page');
73+
cy.log('ACM Alerting UI test completed successfully');
11174
});
11275
});

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# this scrpit use to uninstall ACM test resources and do not excute automatlly with test
23
set -eux
34
echo "[ACM Uninstall] Using KUBECONFIG=${KUBECONFIG:-~/.kube/config}"
45

@@ -19,7 +20,7 @@ oc delete MultiClusterHub multiclusterhub -n open-cluster-management --ignore-no
1920

2021
# wait for MultiClusterHub deleted
2122
echo "[ACM Uninstall] Waiting for MultiClusterHub cleanup..."
22-
oc wait MultiClusterHub multiclusterhub -n open-cluster-management --for=delete --timeout=180s || true
23+
oc wait MultiClusterHub multiclusterhub -n open-cluster-management --for=delete --timeout=300s || true
2324

2425
# --- Step 4: delete Subscription and OperatorGroup ---
2526
echo "[ACM Uninstall] Deleting ACM Operator Subscription & OperatorGroup..."

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ declare global {
2020
cleanupCOO(MCP: { namespace: string, operatorName: string, packageName: string }, MP: { namespace: string, operatorName: string});
2121
RemoveClusterAdminRole();
2222
setupCOO(MCP: { namespace: string, operatorName: string, packageName: string }, MP: { namespace: string, operatorName: string });
23+
beforeBlockACM( MCP: { namespace: string; operatorName: string; packageName: string }, MP: { namespace: string; operatorName: string },): Chainable<void>;
24+
closeOnboardingModalIfPresent(): Chainable<void>;
2325
}
2426
}
2527
}
@@ -567,4 +569,36 @@ Cypress.Commands.add('beforeBlock', (MP: { namespace: string, operatorName: stri
567569
cy.log('Remove cluster-admin role from user.');
568570
operatorUtils.RemoveClusterAdminRole();
569571
cy.log('Remove cluster-admin role from user completed');
570-
});
572+
});
573+
574+
Cypress.Commands.add('beforeBlockACM', (MCP, MP) => {
575+
cy.beforeBlockCOO(MCP, MP);
576+
cy.log('=== [Setup] Installing ACM Operator & MCO ===');
577+
cy.exec('bash ./cypress/fixtures/coo/acm-install.sh', {
578+
env: { KUBECONFIG: Cypress.env('KUBECONFIG_PATH'), },
579+
failOnNonZeroExit: false,
580+
timeout: 1200000, // long time script
581+
});
582+
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-uiplugin.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
583+
cy.exec(`oc apply -f ./cypress/fixtures/coo/acm-alerrule-test.yaml --kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`);
584+
cy.log('ACM environment setup completed');
585+
});
586+
587+
Cypress.Commands.add('closeOnboardingModalIfPresent', () => {
588+
cy.get('body').then(($body) => {
589+
const modalSelector = 'button[data-ouia-component-id="clustersOnboardingModal-ModalBoxCloseButton"]';
590+
if ($body.find(modalSelector).length > 0) {
591+
cy.log('Onboarding modal detected, attempting to close...');
592+
cy.get(modalSelector, { timeout: 20000 })
593+
.should('be.visible')
594+
.should('not.be.disabled')
595+
.click({ force: true });
596+
597+
cy.get(modalSelector, { timeout: 10000 })
598+
.should('not.exist')
599+
.then(() => cy.log('Modal successfully closed'));
600+
} else {
601+
cy.log('No onboarding modal found');
602+
}
603+
});
604+
});

0 commit comments

Comments
 (0)