Skip to content

Commit

Permalink
[Security Solution][Detection Engine] fix cypress MKI flaky test (ela…
Browse files Browse the repository at this point in the history
…stic#194866)

## Summary

This an attempt to fix flaky Cypress test:
https://buildkite.com/organizations/elastic/analytics/suites/serverless-mki-cypress-detection-engine/tests/9cd134bd-fa8b-8ff3-858e-ba1733d30e2c?branch=main

I was not able to reproduce it locally.
Also, old version of test was very stable on flaky test runner too:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7078

I changed test a bit by re-arranging order of form filling. So,
suppression fields will be last. Maybe it can reduce possibility of race
condition when form is just rendered and fields being interacted with by
Cypress.
Also, added assertion if threshold checkbox changed it status to enabled
before interacting with other suppression inputs.
If this won't help, next step can be using default suppression
configuration instead.

New version of test: 200 runs w/o failures
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7084

---------

Co-authored-by: Ryland Herrick <ryalnd@gmail.com>
  • Loading branch information
vitaliidm and rylnd authored Oct 9, 2024
1 parent f4a4a68 commit 7fdd90d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import {
fillScheduleRuleAndContinue,
selectThresholdRuleType,
waitForAlertsToPopulate,
fillDefineThresholdRule,
continueFromDefineStep,
} from '../../../../tasks/create_new_rule';
import { login } from '../../../../tasks/login';
import { visit } from '../../../../tasks/navigation';
Expand All @@ -68,7 +70,7 @@ import { CREATE_RULE_URL } from '../../../../urls/navigation';
describe(
'Threshold rules',
{
tags: ['@ess', '@serverless', '@skipInServerlessMKI'],
tags: ['@ess', '@serverless'],
},
() => {
const rule = getNewThresholdRule();
Expand Down Expand Up @@ -152,8 +154,10 @@ describe(
it('Creates a new threshold rule with suppression enabled', () => {
selectThresholdRuleType();

fillDefineThresholdRule(rule);
enablesAndPopulatesThresholdSuppression(5, 'h');
fillDefineThresholdRuleAndContinue(rule);
continueFromDefineStep();

// ensures duration displayed on define step in preview mode
cy.get(DEFINITION_DETAILS).within(() => {
getDetails(SUPPRESS_FOR_DETAILS).should('have.text', '5h');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ export const fillRuleActionFilters = (alertsFilter: AlertsFilter) => {
.type(`{selectall}${alertsFilter.timeframe.timezone}{enter}`);
};

export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRuleCreateProps) => {
export const fillDefineThresholdRule = (rule: ThresholdRuleCreateProps) => {
const thresholdField = 0;
const threshold = 1;

Expand All @@ -578,7 +578,11 @@ export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRuleCreateProp
cy.wrap(inputs[threshold]).clear();
cy.wrap(inputs[threshold]).type(`${rule.threshold.value}`);
});
cy.get(DEFINE_CONTINUE_BUTTON).should('exist').click({ force: true });
};

export const fillDefineThresholdRuleAndContinue = (rule: ThresholdRuleCreateProps) => {
fillDefineThresholdRule(rule);
continueFromDefineStep();
};

export const fillDefineEqlRule = (rule: EqlRuleCreateProps) => {
Expand Down Expand Up @@ -908,6 +912,7 @@ export const enablesAndPopulatesThresholdSuppression = (
// enables suppression for threshold rule
cy.get(THRESHOLD_ENABLE_SUPPRESSION_CHECKBOX).should('not.be.checked');
cy.get(THRESHOLD_ENABLE_SUPPRESSION_CHECKBOX).click();
cy.get(THRESHOLD_ENABLE_SUPPRESSION_CHECKBOX).should('be.checked');

setAlertSuppressionDuration(interval, timeUnit);

Expand Down

0 comments on commit 7fdd90d

Please sign in to comment.