[8.x] [Security Solution][Detection Engine] fix cypress MKI flaky test (#194866) (#195550)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution][Detection Engine] fix cypress MKI flaky test
(#194866)](https://github.com/elastic/kibana/pull/194866)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Vitalii
Dmyterko","email":"92328789+vitaliidm@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-09T09:14:16Z","message":"[Security
Solution][Detection Engine] fix cypress MKI flaky test (#194866)\n\n##
Summary\r\n\r\nThis an attempt to fix flaky Cypress
test:\r\n9cd134bd-fa8b-8ff3-858e-ba1733d30e2c?branch=main\r\n\r\nI
was not able to reproduce it locally.\r\nAlso, old version of test was
very stable on flaky test runner
too:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7078\r\n\r\nI
changed test a bit by re-arranging order of form filling.
So,\r\nsuppression fields will be last. Maybe it can reduce possibility
of race\r\ncondition when form is just rendered and fields being
interacted with by\r\nCypress.\r\nAlso, added assertion if threshold
checkbox changed it status to enabled\r\nbefore interacting with other
suppression inputs.\r\nIf this won't help, next step can be using
default suppression\r\nconfiguration instead.\r\n\r\nNew version of
test: 200 runs w/o
failures\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7084\r\n\r\n---------\r\n\r\nCo-authored-by:
Ryland Herrick
<ryalnd@gmail.com>","sha":"7fdd90d148660256d822c45f5a4594d82d21af38","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:
SecuritySolution","backport:prev-minor","Team:Detection Engine","8.16
candidate"],"title":"[Security Solution][Detection Engine] fix cypress
MKI flaky
test","number":194866,"url":"https://github.com/elastic/kibana/pull/194866","mergeCommit":{"message":"[Security
Solution][Detection Engine] fix cypress MKI flaky test (#194866)\n\n##
Summary\r\n\r\nThis an attempt to fix flaky Cypress
test:\r\n9cd134bd-fa8b-8ff3-858e-ba1733d30e2c?branch=main\r\n\r\nI
was not able to reproduce it locally.\r\nAlso, old version of test was
very stable on flaky test runner
too:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7078\r\n\r\nI
changed test a bit by re-arranging order of form filling.
So,\r\nsuppression fields will be last. Maybe it can reduce possibility
of race\r\ncondition when form is just rendered and fields being
interacted with by\r\nCypress.\r\nAlso, added assertion if threshold
checkbox changed it status to enabled\r\nbefore interacting with other
suppression inputs.\r\nIf this won't help, next step can be using
default suppression\r\nconfiguration instead.\r\n\r\nNew version of
test: 200 runs w/o
failures\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7084\r\n\r\n---------\r\n\r\nCo-authored-by:
Ryland Herrick
<ryalnd@gmail.com>","sha":"7fdd90d148660256d822c45f5a4594d82d21af38"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194866","number":194866,"mergeCommit":{"message":"[Security
Solution][Detection Engine] fix cypress MKI flaky test (#194866)\n\n##
Summary\r\n\r\nThis an attempt to fix flaky Cypress
test:\r\n9cd134bd-fa8b-8ff3-858e-ba1733d30e2c?branch=main\r\n\r\nI
was not able to reproduce it locally.\r\nAlso, old version of test was
very stable on flaky test runner
too:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7078\r\n\r\nI
changed test a bit by re-arranging order of form filling.
So,\r\nsuppression fields will be last. Maybe it can reduce possibility
of race\r\ncondition when form is just rendered and fields being
interacted with by\r\nCypress.\r\nAlso, added assertion if threshold
checkbox changed it status to enabled\r\nbefore interacting with other
suppression inputs.\r\nIf this won't help, next step can be using
default suppression\r\nconfiguration instead.\r\n\r\nNew version of
test: 200 runs w/o
failures\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7084\r\n\r\n---------\r\n\r\nCo-authored-by:
Ryland Herrick
<ryalnd@gmail.com>","sha":"7fdd90d148660256d822c45f5a4594d82d21af38"}}]}]
BACKPORT-->

Co-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2024-10-09 22:26:33 +11:00 committed by GitHub
parent 6eb8471c31
commit 0d0b492018
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View file

@ -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';
@ -68,7 +70,7 @@ import { CREATE_RULE_URL } from '../../../../urls/navigation';
describe(
'Threshold rules',
{
tags: ['@ess', '@serverless', '@skipInServerlessMKI'],
tags: ['@ess', '@serverless'],
},
() => {
const rule = getNewThresholdRule();
@ -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');

View file

@ -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;
@ -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) => {
@ -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);