Skip to content

Commit 78214f9

Browse files
committed
Increased timeout thresholds for alerting cypress tests to reduce flakiness when running on slow domains.
Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
1 parent 34a2630 commit 78214f9

10 files changed

+268
-150
lines changed

cypress/integration/plugins/alerting-dashboards-plugin/acknowledge_alerts_modal_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const BUCKET_TRIGGER = 'sample_alerts_flyout_bucket_level_trigger';
1616
const QUERY_MONITOR = 'sample_alerts_flyout_query_level_monitor';
1717
const QUERY_TRIGGER = 'sample_alerts_flyout_query_level_trigger';
1818

19-
const TWENTY_SECONDS = 20000;
19+
const TWENTY_SECONDS = 60000;
2020

2121
describe('AcknowledgeAlertsModal', () => {
2222
before(() => {

cypress/integration/plugins/alerting-dashboards-plugin/alert_spec.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { ALERTING_PLUGIN_NAME } from '../../../utils/plugins/alerting-dashboards-plugin/constants';
6+
import {
7+
ALERTING_PLUGIN_NAME,
8+
ALERTING_PLUGIN_TIMEOUT,
9+
} from '../../../utils/plugins/alerting-dashboards-plugin/constants';
710
import sampleQueryLevelMonitorWithAlwaysTrueTrigger from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_query_level_monitor_with_always_true_trigger';
811
import sampleQueryLevelMonitorWorkflow from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_query_level_monitor_workflow';
912
import { BASE_PATH } from '../../../utils/base_constants';
@@ -19,7 +22,7 @@ describe('Alerts', () => {
1922
cy.visit(`${BASE_PATH}/app/${ALERTING_PLUGIN_NAME}#/dashboard`);
2023

2124
// Common text to wait for to confirm page loaded, give up to 30 seconds for initial load
22-
cy.contains('Acknowledge', { timeout: 30000 });
25+
cy.contains('Acknowledge', { timeout: ALERTING_PLUGIN_TIMEOUT });
2326
});
2427

2528
describe("can be in 'Active' state", () => {

cypress/integration/plugins/alerting-dashboards-plugin/alerts_dashboard_flyout_spec.js

+181-100
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import {
77
ALERTING_INDEX,
88
ALERTING_PLUGIN_NAME,
9+
ALERTING_PLUGIN_TIMEOUT,
910
} from '../../../utils/plugins/alerting-dashboards-plugin/constants';
1011
import sampleAlertsFlyoutBucketMonitor from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_alerts_flyout_bucket_level_monitor.json';
1112
import sampleAlertsFlyoutQueryMonitor from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_alerts_flyout_query_level_monitor.json';
@@ -44,8 +45,8 @@ describe('Alerts by trigger flyout', () => {
4445
cy.visit(`${BASE_PATH}/app/${ALERTING_PLUGIN_NAME}#/monitors`);
4546

4647
// Confirm test monitors were created successfully
47-
cy.contains(BUCKET_MONITOR_NAME);
48-
cy.contains(QUERY_MONITOR_NAME);
48+
cy.contains(BUCKET_MONITOR_NAME, { timeout: ALERTING_PLUGIN_TIMEOUT });
49+
cy.contains(QUERY_MONITOR_NAME, { timeout: ALERTING_PLUGIN_TIMEOUT });
4950

5051
// Wait 1 minutes for the test monitors to trigger alerts,
5152
// then go to the 'Alerts by trigger' dashboard page to view alerts
@@ -57,8 +58,8 @@ describe('Alerts by trigger flyout', () => {
5758
cy.visit(`${BASE_PATH}/app/${ALERTING_PLUGIN_NAME}#/dashboard`);
5859

5960
// Confirm dashboard is displaying rows for the test monitors.
60-
cy.contains(BUCKET_MONITOR_NAME);
61-
cy.contains(QUERY_MONITOR_NAME);
61+
cy.contains(BUCKET_MONITOR_NAME, { timeout: ALERTING_PLUGIN_TIMEOUT });
62+
cy.contains(QUERY_MONITOR_NAME, { timeout: ALERTING_PLUGIN_TIMEOUT });
6263

6364
// Waiting 5 seconds for alerts to finish loading.
6465
// This short wait period alleviates flakiness observed during these tests.
@@ -67,91 +68,144 @@ describe('Alerts by trigger flyout', () => {
6768

6869
it('Bucket-level monitor flyout test', () => {
6970
// Click the link for the flyout.
70-
cy.get(`[data-test-subj="euiLink_${BUCKET_TRIGGER}"]`).click();
71+
cy.get(`[data-test-subj="euiLink_${BUCKET_TRIGGER}"]`, {
72+
timeout: ALERTING_PLUGIN_TIMEOUT,
73+
}).click();
7174

7275
// Perform the test checks within the flyout component.
73-
cy.get(`[data-test-subj="alertsDashboardFlyout_${BUCKET_TRIGGER}"]`).within(
74-
() => {
75-
// Confirm flyout header contains expected text.
76-
cy.get(
77-
`[data-test-subj="alertsDashboardFlyout_header_${BUCKET_TRIGGER}"]`
78-
).contains(`Alerts by ${BUCKET_TRIGGER}`);
79-
80-
// Confirm 'Trigger name' sections renders as expected.
81-
cy.get(
82-
`[data-test-subj="alertsDashboardFlyout_triggerName_${BUCKET_TRIGGER}"]`
83-
).as('triggerName');
84-
cy.get('@triggerName').contains('Trigger name');
85-
cy.get('@triggerName').contains(BUCKET_TRIGGER);
86-
87-
// Confirm 'Severity' sections renders as expected.
88-
cy.get(
89-
`[data-test-subj="alertsDashboardFlyout_severity_${BUCKET_TRIGGER}"]`
90-
).as('severity');
91-
cy.get('@severity').contains('Severity');
92-
cy.get('@severity').contains('4 (Low)');
93-
94-
// Confirm 'Monitor' sections renders as expected.
95-
cy.get(
96-
`[data-test-subj="alertsDashboardFlyout_monitor_${BUCKET_TRIGGER}"]`
97-
).as('monitor');
98-
cy.get('@monitor').contains('Monitor');
99-
cy.get('@monitor').contains(BUCKET_MONITOR_NAME);
100-
101-
// Confirm 'Conditions' sections renders as expected.
102-
cy.get(
103-
`[data-test-subj="alertsDashboardFlyout_conditions_${BUCKET_TRIGGER}"]`
104-
).as('conditions');
105-
cy.get('@conditions').contains('Conditions');
106-
107-
// Confirm the 'Conditions' sections renders with all of the expected conditions.
108-
[
109-
'params._count < 10000',
110-
'OR',
111-
'params.avg_products_price == 10',
112-
].forEach((entry) => cy.get('@conditions').contains(entry));
113-
114-
// Confirm 'Time range for the last' sections renders as expected.
115-
cy.get(
116-
`[data-test-subj="alertsDashboardFlyout_timeRange_${BUCKET_TRIGGER}"]`
117-
).as('timeRange');
118-
cy.get('@timeRange').contains('Time range for the last');
119-
cy.get('@timeRange').contains('10 day(s)');
120-
121-
// Confirm 'Filters' sections renders as expected.
122-
cy.get(
123-
`[data-test-subj="alertsDashboardFlyout_filters_${BUCKET_TRIGGER}"]`
124-
).as('filters');
125-
cy.get('@filters').contains('Filters');
126-
cy.get('@filters').contains('All fields are included');
127-
128-
// Confirm 'Group by' sections renders as expected.
129-
cy.get(
130-
`[data-test-subj="alertsDashboardFlyout_groupBy_${BUCKET_TRIGGER}"]`
131-
).as('groupBy');
132-
cy.get('@groupBy').contains('Group by');
133-
cy.get('@groupBy').contains('customer_gender, user');
134-
135-
// Set the 'severity' filter to only display ACTIVE alerts.
136-
cy.get('[data-test-subj="dashboardAlertStateFilter"]').select('Active');
137-
138-
// This monitor configuration consistently returns 46 alerts when testing locally.
139-
// Confirm the flyout dashboard contains more than 1 ACTIVE alert.
140-
cy.get('tbody > tr').should(($tr) =>
141-
expect($tr).to.have.length.greaterThan(1)
142-
);
143-
144-
// Select the first and last alerts in the table.
145-
cy.get('input[data-test-subj^="checkboxSelectRow-"]').first().click();
146-
cy.get('input[data-test-subj^="checkboxSelectRow-"]').last().click();
147-
148-
// Press the flyout 'Acknowledge button, and wait for the AcknowledgeAlerts API call to complete.
149-
cy.get('[data-test-subj="flyoutAcknowledgeAlertsButton"]').click();
150-
}
151-
);
76+
cy.get(`[data-test-subj="alertsDashboardFlyout_${BUCKET_TRIGGER}"]`, {
77+
timeout: ALERTING_PLUGIN_TIMEOUT,
78+
}).within(() => {
79+
// Confirm flyout header contains expected text.
80+
cy.get(
81+
`[data-test-subj="alertsDashboardFlyout_header_${BUCKET_TRIGGER}"]`,
82+
{ timeout: ALERTING_PLUGIN_TIMEOUT }
83+
).contains(`Alerts by ${BUCKET_TRIGGER}`, {
84+
timeout: ALERTING_PLUGIN_TIMEOUT,
85+
});
86+
87+
// Confirm 'Trigger name' sections renders as expected.
88+
cy.get(
89+
`[data-test-subj="alertsDashboardFlyout_triggerName_${BUCKET_TRIGGER}"]`,
90+
{ timeout: ALERTING_PLUGIN_TIMEOUT }
91+
).as('triggerName');
92+
cy.get('@triggerName').contains('Trigger name', {
93+
timeout: ALERTING_PLUGIN_TIMEOUT,
94+
});
95+
cy.get('@triggerName').contains(BUCKET_TRIGGER, {
96+
timeout: ALERTING_PLUGIN_TIMEOUT,
97+
});
98+
99+
// Confirm 'Severity' sections renders as expected.
100+
cy.get(
101+
`[data-test-subj="alertsDashboardFlyout_severity_${BUCKET_TRIGGER}"]`,
102+
{ timeout: ALERTING_PLUGIN_TIMEOUT }
103+
).as('severity');
104+
cy.get('@severity', { timeout: ALERTING_PLUGIN_TIMEOUT }).contains(
105+
'Severity',
106+
{ timeout: ALERTING_PLUGIN_TIMEOUT }
107+
);
108+
cy.get('@severity', { timeout: ALERTING_PLUGIN_TIMEOUT }).contains(
109+
'4 (Low)',
110+
{ timeout: ALERTING_PLUGIN_TIMEOUT }
111+
);
112+
113+
// Confirm 'Monitor' sections renders as expected.
114+
cy.get(
115+
`[data-test-subj="alertsDashboardFlyout_monitor_${BUCKET_TRIGGER}"]`
116+
).as('monitor');
117+
cy.get('@monitor').contains('Monitor', {
118+
timeout: ALERTING_PLUGIN_TIMEOUT,
119+
});
120+
cy.get('@monitor').contains(BUCKET_MONITOR_NAME, {
121+
timeout: ALERTING_PLUGIN_TIMEOUT,
122+
});
123+
124+
// Confirm 'Conditions' sections renders as expected.
125+
cy.get(
126+
`[data-test-subj="alertsDashboardFlyout_conditions_${BUCKET_TRIGGER}"]`
127+
).as('conditions');
128+
cy.get('@conditions').contains('Conditions', {
129+
timeout: ALERTING_PLUGIN_TIMEOUT,
130+
});
131+
132+
// Confirm the 'Conditions' sections renders with all of the expected conditions.
133+
[
134+
'params._count < 10000',
135+
'OR',
136+
'params.avg_products_price == 10',
137+
].forEach((entry) =>
138+
cy
139+
.get('@conditions')
140+
.contains(entry, { timeout: ALERTING_PLUGIN_TIMEOUT })
141+
);
142+
143+
// Confirm 'Time range for the last' sections renders as expected.
144+
cy.get(
145+
`[data-test-subj="alertsDashboardFlyout_timeRange_${BUCKET_TRIGGER}"]`
146+
).as('timeRange');
147+
cy.get('@timeRange').contains('Time range for the last', {
148+
timeout: ALERTING_PLUGIN_TIMEOUT,
149+
});
150+
cy.get('@timeRange').contains('10 day(s)', {
151+
timeout: ALERTING_PLUGIN_TIMEOUT,
152+
});
153+
154+
// Confirm 'Filters' sections renders as expected.
155+
cy.get(
156+
`[data-test-subj="alertsDashboardFlyout_filters_${BUCKET_TRIGGER}"]`
157+
).as('filters');
158+
cy.get('@filters').contains('Filters', {
159+
timeout: ALERTING_PLUGIN_TIMEOUT,
160+
});
161+
cy.get('@filters').contains('All fields are included', {
162+
timeout: ALERTING_PLUGIN_TIMEOUT,
163+
});
164+
165+
// Confirm 'Group by' sections renders as expected.
166+
cy.get(
167+
`[data-test-subj="alertsDashboardFlyout_groupBy_${BUCKET_TRIGGER}"]`
168+
).as('groupBy');
169+
cy.get('@groupBy').contains('Group by', {
170+
timeout: ALERTING_PLUGIN_TIMEOUT,
171+
});
172+
cy.get('@groupBy').contains('customer_gender, user', {
173+
timeout: ALERTING_PLUGIN_TIMEOUT,
174+
});
175+
176+
// Set the 'severity' filter to only display ACTIVE alerts.
177+
cy.get('[data-test-subj="dashboardAlertStateFilter"]', {
178+
timeout: ALERTING_PLUGIN_TIMEOUT,
179+
}).select('Active');
180+
181+
// This monitor configuration consistently returns 46 alerts when testing locally.
182+
// Confirm the flyout dashboard contains more than 1 ACTIVE alert.
183+
cy.get('tbody > tr').should(($tr) =>
184+
expect($tr).to.have.length.greaterThan(1)
185+
);
186+
187+
// Select the first and last alerts in the table.
188+
cy.get('input[data-test-subj^="checkboxSelectRow-"]', {
189+
timeout: ALERTING_PLUGIN_TIMEOUT,
190+
})
191+
.first()
192+
.click();
193+
cy.get('input[data-test-subj^="checkboxSelectRow-"]', {
194+
timeout: ALERTING_PLUGIN_TIMEOUT,
195+
})
196+
.last()
197+
.click();
198+
199+
// Press the flyout 'Acknowledge button, and wait for the AcknowledgeAlerts API call to complete.
200+
cy.get('[data-test-subj="flyoutAcknowledgeAlertsButton"]', {
201+
timeout: ALERTING_PLUGIN_TIMEOUT,
202+
}).click();
203+
});
152204

153205
// Confirm acknowledge alerts toast displays expected text.
154-
cy.contains('Successfully acknowledged 2 alerts.');
206+
cy.contains('Successfully acknowledged 2 alerts.', {
207+
timeout: ALERTING_PLUGIN_TIMEOUT,
208+
});
155209

156210
// Confirm alerts were acknowledged as expected.
157211
cy.get(`[data-test-subj="alertsDashboardFlyout_${BUCKET_TRIGGER}"]`).within(
@@ -185,58 +239,85 @@ describe('Alerts by trigger flyout', () => {
185239
// Confirm flyout header contains expected text.
186240
cy.get(
187241
`[data-test-subj="alertsDashboardFlyout_header_${QUERY_TRIGGER}"]`
188-
).contains(`Alerts by ${QUERY_TRIGGER}`);
242+
).contains(`Alerts by ${QUERY_TRIGGER}`, {
243+
timeout: ALERTING_PLUGIN_TIMEOUT,
244+
});
189245

190246
// Confirm 'Trigger name' sections renders as expected.
191247
cy.get(
192248
`[data-test-subj="alertsDashboardFlyout_triggerName_${QUERY_TRIGGER}"]`
193249
).as('triggerName');
194-
cy.get('@triggerName').contains('Trigger name');
195-
cy.get('@triggerName').contains(QUERY_TRIGGER);
250+
cy.get('@triggerName').contains('Trigger name', {
251+
timeout: ALERTING_PLUGIN_TIMEOUT,
252+
});
253+
cy.get('@triggerName').contains(QUERY_TRIGGER, {
254+
timeout: ALERTING_PLUGIN_TIMEOUT,
255+
});
196256

197257
// Confirm 'Severity' sections renders as expected.
198258
cy.get(
199259
`[data-test-subj="alertsDashboardFlyout_severity_${QUERY_TRIGGER}"]`
200260
).as('severity');
201-
cy.get('@severity').contains('Severity');
202-
cy.get('@severity').contains('2 (High)');
261+
cy.get('@severity').contains('Severity', {
262+
timeout: ALERTING_PLUGIN_TIMEOUT,
263+
});
264+
cy.get('@severity').contains('2 (High)', {
265+
timeout: ALERTING_PLUGIN_TIMEOUT,
266+
});
203267

204268
// Confirm 'Monitor' sections renders as expected.
205269
cy.get(
206270
`[data-test-subj="alertsDashboardFlyout_monitor_${QUERY_TRIGGER}"]`
207271
).as('monitor');
208-
cy.get('@monitor').contains('Monitor');
209-
cy.get('@monitor').contains(QUERY_MONITOR_NAME);
272+
cy.get('@monitor').contains('Monitor', {
273+
timeout: ALERTING_PLUGIN_TIMEOUT,
274+
});
275+
cy.get('@monitor').contains(QUERY_MONITOR_NAME, {
276+
timeout: ALERTING_PLUGIN_TIMEOUT,
277+
});
210278

211279
// Confirm 'Conditions' sections renders as expected.
212280
cy.get(
213281
`[data-test-subj="alertsDashboardFlyout_conditions_${QUERY_TRIGGER}"]`
214282
).as('conditions');
215-
cy.get('@conditions').contains('Condition');
283+
cy.get('@conditions').contains('Condition', {
284+
timeout: ALERTING_PLUGIN_TIMEOUT,
285+
});
216286
cy.get('@conditions').contains(
217-
`ctx.results[0].hits.total.value < 10000`
287+
`ctx.results[0].hits.total.value < 10000`,
288+
{ timeout: ALERTING_PLUGIN_TIMEOUT }
218289
);
219290

220291
// Confirm 'Time range for the last' sections renders as expected.
221292
cy.get(
222293
`[data-test-subj="alertsDashboardFlyout_timeRange_${QUERY_TRIGGER}"]`
223294
).as('timeRange');
224-
cy.get('@timeRange').contains('Time range for the last');
225-
cy.get('@timeRange').contains('10 day(s)');
295+
cy.get('@timeRange').contains('Time range for the last', {
296+
timeout: ALERTING_PLUGIN_TIMEOUT,
297+
});
298+
cy.get('@timeRange').contains('10 day(s)', {
299+
timeout: ALERTING_PLUGIN_TIMEOUT,
300+
});
226301

227302
// Confirm 'Filters' sections renders as expected.
228303
cy.get(
229304
`[data-test-subj="alertsDashboardFlyout_filters_${QUERY_TRIGGER}"]`
230305
).as('filters');
231-
cy.get('@filters').contains('Filters');
232-
cy.get('@filters').contains('-');
306+
cy.get('@filters').contains('Filters', {
307+
timeout: ALERTING_PLUGIN_TIMEOUT,
308+
});
309+
cy.get('@filters').contains('-', { timeout: ALERTING_PLUGIN_TIMEOUT });
233310

234311
// Confirm 'Group by' sections renders as expected.
235312
cy.get(
236313
`[data-test-subj="alertsDashboardFlyout_groupBy_${QUERY_TRIGGER}"]`
237314
).as('groupBy');
238-
cy.get('@groupBy').contains('Group by');
239-
cy.get('@groupBy').contains('user');
315+
cy.get('@groupBy').contains('Group by', {
316+
timeout: ALERTING_PLUGIN_TIMEOUT,
317+
});
318+
cy.get('@groupBy').contains('user', {
319+
timeout: ALERTING_PLUGIN_TIMEOUT,
320+
});
240321

241322
// Set the 'severity' filter to only display ACTIVE alerts.
242323
cy.get('[data-test-subj="dashboardAlertStateFilter"]').select('Active');

0 commit comments

Comments
 (0)