Skip to content

Commit c89fe68

Browse files
Merge pull request #601 from DavidRajnoha/cypress-tags
OBSINTA-857: implement grep tags for selective test execution
2 parents 516050c + a2205a3 commit c89fe68

25 files changed

+213
-53
lines changed

web/cypress.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineConfig } from 'cypress';
22
import * as fs from 'fs-extra';
33
import * as console from 'console';
44
import * as path from 'path';
5+
import registerCypressGrep from '@cypress/grep/src/plugin';
56

67
export default defineConfig({
78
screenshotsFolder: './cypress/screenshots',
@@ -39,6 +40,8 @@ export default defineConfig({
3940
viewportWidth: 1920,
4041
viewportHeight: 1080,
4142
setupNodeEvents(on, config) {
43+
registerCypressGrep(config);
44+
4245
on(
4346
'before:browser:launch',
4447
(

web/cypress/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,90 @@ npm run cypress:run --spec "cypress/e2e/**/incidents*.cy.ts"
236236

237237
---
238238

239+
### Running tests by tags
240+
241+
Tests are organized using tags for selective execution using [@cypress/grep](https://github.com/cypress-io/cypress/tree/develop/npm/grep).
242+
243+
#### Tag Categories
244+
245+
**1. Basic Tags:**
246+
- `@smoke` - Fast BVT tests
247+
- `@demo` - Interactive demo tests (no assertions, skipped in CI)
248+
- `@flaky` - Tests that don't pass reliably
249+
- `@xfail` - Tests for known bugs expected to fail
250+
- `@slow` - Long-running e2e tests (15+ minutes)
251+
252+
**2. High-Level Component Tags:**
253+
- `@monitoring` - Monitoring plugin tests
254+
- `@incidents` - Incidents feature tests
255+
- `@coo` - Cluster Observability Operator functionality tests (operator installation, ACM integration)
256+
- `@virtualization` - Virtualization integration tests
257+
- `@alerts` - Alert-related tests
258+
- `@metrics` - Metrics-related tests
259+
- `@dashboards` - Dashboard-related tests (includes Perses)
260+
261+
**3. Specific Feature Tags** (format: `@{component}-{label}`):
262+
- Example: `@incidents-redux`
263+
- Add specific feature tags as needed
264+
265+
**4. JIRA Tags** (format: `@JIRA-{ID}`):
266+
- Example: `@JIRA-OU-1033`
267+
- Link tests to specific JIRA issues
268+
269+
#### Running Tests by Tags
270+
271+
**Run smoke tests (BVT):**
272+
```bash
273+
npx cypress run --env grepTags=@smoke
274+
# or
275+
npm run test-cypress-smoke
276+
```
277+
278+
**Run regression tests (all non-smoke tests):**
279+
```bash
280+
npx cypress run --env grepTags="-@smoke -@flaky -@demo"
281+
```
282+
283+
**Run component-specific tests:**
284+
```bash
285+
npm run test-cypress-monitoring # All monitoring tests
286+
npm run test-cypress-incidents # All incidents tests
287+
npm run test-cypress-coo # COO operator functionality tests
288+
npm run test-cypress-virtualization # All virtualization integration tests
289+
npm run test-cypress-alerts # All alerts tests
290+
npm run test-cypress-metrics # All metrics tests
291+
npm run test-cypress-dashboards # All dashboards tests (includes Perses)
292+
```
293+
294+
**Run smoke tests for specific component:**
295+
```bash
296+
npm run test-cypress-monitoring-bvt # Monitoring smoke tests
297+
npm run test-cypress-coo-bvt # COO smoke tests
298+
```
299+
300+
**Run regression for specific component:**
301+
```bash
302+
npm run test-cypress-monitoring-regression # All monitoring except smoke
303+
```
304+
305+
**Run tests with multiple tags (OR logic):**
306+
```bash
307+
npx cypress run --env grepTags="@smoke @slow"
308+
```
309+
310+
**Run tests with BOTH tags (AND logic):**
311+
```bash
312+
npx cypress run --env grepTags="@smoke+@incidents"
313+
```
314+
315+
**Complex filtering:**
316+
```bash
317+
npx cypress run --env grepTags="@incidents -@slow -@flaky"
318+
```
319+
320+
---
321+
322+
239323
## Test Results
240324

241325
### Videos

web/cypress/e2e/coo/01.coo_bvt.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const MP = {
1818
operatorName: 'Cluster Monitoring Operator',
1919
};
2020

21-
describe('BVT: COO', () => {
21+
describe('BVT: COO', { tags: ['@smoke', '@coo'] }, () => {
2222

2323
before(() => {
2424
cy.beforeBlockCOO(MCP, MP);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Classes } from '../../../src/components/data-test';
2+
import { commonPages } from '../../views/common';
3+
import { nav } from '../../views/nav';
4+
import { guidedTour } from '../../views/tour';
5+
6+
// Set constants for the operators that need to be installed for tests.
7+
const KBV = {
8+
namespace: 'openshift-cnv',
9+
packageName: 'kubevirt-hyperconverged',
10+
operatorName: 'kubevirt-hyperconverged-operator.v4.19.6',
11+
config: {
12+
kind: 'HyperConverged',
13+
name: 'kubevirt-hyperconverged',
14+
},
15+
crd: {
16+
kubevirt: 'kubevirts.kubevirt.io',
17+
hyperconverged: 'hyperconvergeds.hco.kubevirt.io',
18+
}
19+
};
20+
21+
describe('IVT: Monitoring UIPlugin + Virtualization', { tags: ['@smoke', '@coo'] }, () => {
22+
23+
before(() => {
24+
cy.beforeBlockVirtualization(KBV);
25+
});
26+
27+
it('1. Virtualization perspective - Observe Menu', () => {
28+
cy.log('Virtualization perspective - Observe Menu and verify all submenus');
29+
cy.switchPerspective('Virtualization');
30+
cy.byAriaLabel('Welcome modal').should('be.visible');
31+
guidedTour.closeKubevirtTour();
32+
cy.switchPerspective('Administrator');
33+
34+
});
35+
36+
/**
37+
* TODO: To be replaced by COO validation such as Dashboards (Perses) scenarios
38+
*/
39+
40+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const MP = {
1919
};
2020
const expectedAlerts = ['Watchdog', 'Watchdog-spoke', 'ClusterCPUHealth-jb'];
2121

22-
describe('ACM Alerting UI', () => {
22+
describe('ACM Alerting UI', { tags: ['@coo', '@alerts'] }, () => {
2323
before(() => {
2424
cy.beforeBlockACM(MCP, MP);
2525
});

web/cypress/e2e/incidents/00.coo_incidents_e2e.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const MP = {
2121
operatorName: 'Cluster Monitoring Operator',
2222
};
2323

24-
describe('BVT: Incidents - e2e', () => {
24+
describe('BVT: Incidents - e2e', { tags: ['@smoke', '@slow', '@incidents'] }, () => {
2525
let currentAlertName: string;
2626

2727
before(() => {

web/cypress/e2e/incidents/01.incidents.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const NAMESPACE = 'openshift-monitoring';
3131
const SEVERITY = 'Critical';
3232
const ALERT_DESC = 'This is an alert meant to ensure that the entire alerting pipeline is functional. This alert is always firing, therefore it should always be firing in Alertmanager and always fire against a receiver. There are integrations with various notification mechanisms that send a notification when this alert is not firing. For example the "DeadMansSnitch" integration in PagerDuty.'
3333
const ALERT_SUMMARY = 'An alert that should always be firing to certify that Alertmanager is working properly.'
34-
describe('BVT: Incidents - UI', () => {
34+
describe('BVT: Incidents - UI', { tags: ['@smoke', '@incidents'] }, () => {
3535
before(() => {
3636
cy.beforeBlockCOO(MCP, MP);
3737
});

web/cypress/e2e/incidents/02.incidents-mocking-example.cy.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const MP = {
2626
operatorName: 'Cluster Monitoring Operator',
2727
};
2828

29-
describe('Incidents - Mocking Examples', () => {
29+
describe('Incidents - Mocking Examples', { tags: ['@demo', '@incidents'] }, () => {
3030

3131
before(() => {
3232
cy.beforeBlockCOO(MCP, MP);
@@ -37,37 +37,45 @@ describe('Incidents - Mocking Examples', () => {
3737
incidentsPage.goTo();
3838
});
3939

40-
it('1. Mock healthy cluster from fixture', () => {
40+
it('1. Mock silenced and firing incidents with mixed severity', () => {
41+
cy.log('Setting up silenced critical and firing warning incidents');
42+
cy.mockIncidentFixture('incident-scenarios/silenced-and-firing-mixed-severity.yaml');
43+
44+
cy.log('One silenced critical incident (resolved) and one firing warning incident should be visible');
45+
cy.pause();
46+
});
47+
48+
it('2. Mock healthy cluster from fixture', () => {
4149
cy.log('Setting up healthy cluster scenario from fixture');
4250
cy.mockIncidentFixture('incident-scenarios/0-healthy-cluster.yaml');
4351

4452
cy.pause();
4553
});
4654

47-
it('2. Mock single incident with critical and warning alerts', () => {
55+
it('3. Mock single incident with critical and warning alerts', () => {
4856
cy.log('Setting up single incident with critical and warning alerts from fixture');
4957
cy.mockIncidentFixture('incident-scenarios/1-single-incident-firing-critical-and-warning-alerts.yaml');
5058
cy.log('Single incident with mixed severity alerts should be visible');
5159
cy.pause();
5260
});
5361

54-
it('3. Mock multi-incidents with resolved and firing alerts', () => {
62+
it('4. Mock multi-incidents with resolved and firing alerts', () => {
5563
cy.log('Setting up multi-incidents with resolved and firing alerts from fixture');
5664
cy.mockIncidentFixture('incident-scenarios/2-multi-incidents-multi-alerts-resolved-and-firing.yaml');
5765

5866
cy.log('Multiple incidents with mixed alert states should be visible');
5967
cy.pause();
6068
});
6169

62-
it('4. Mock multi-severity overlapping incidents', () => {
70+
it('5. Mock multi-severity overlapping incidents', () => {
6371
cy.log('Setting up multi-severity overlapping incidents from fixture');
6472
cy.mockIncidentFixture('incident-scenarios/3-multi-severity-overlapping-incidents.yaml');
6573

6674
cy.log('Overlapping incidents with different severity distributions should be visible');
6775
cy.pause();
6876
});
6977

70-
it('5. Mock single incident with escalating severity alerts', () => {
78+
it('6. Mock single incident with escalating severity alerts', () => {
7179
cy.log('Setting up single incident with escalating severity alerts from fixture');
7280
cy.mockIncidentFixture('incident-scenarios/5-escalating-severity-incident.yaml');
7381

@@ -76,7 +84,7 @@ describe('Incidents - Mocking Examples', () => {
7684

7785
});
7886

79-
it('6. Mock empty incident state', () => {
87+
it('7. Mock empty incident state', () => {
8088
cy.log('Setting up empty incident state');
8189
cy.mockIncidents([]);
8290

web/cypress/e2e/incidents/regression/01.reg_filtering.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const MP = {
2525
operatorName: 'Cluster Monitoring Operator',
2626
};
2727

28-
describe('Regression: Incidents Filtering', () => {
28+
describe('Regression: Incidents Filtering', { tags: ['@incidents'] }, () => {
2929

3030
before(() => {
3131
cy.beforeBlockCOO(MCP, MP);

web/cypress/e2e/incidents/regression/02.reg_ui_charts_comprehensive.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const MP = {
8484
operatorName: 'Cluster Monitoring Operator',
8585
};
8686

87-
describe('Regression: Charts UI - Comprehensive', () => {
87+
describe('Regression: Charts UI - Comprehensive', { tags: ['@incidents'] }, () => {
8888

8989
before(() => {
9090
cy.beforeBlockCOO(MCP, MP);

0 commit comments

Comments
 (0)