-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.9] [Security Solution] Tests: Filter by rule execution status (#16…
…0502) (#161618) # Backport This will backport the following commits from `main` to `8.9`: - [[Security Solution] Tests: Filter by rule execution status (#160502)](#160502) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nikita Indik","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-07-11T08:12:37Z","message":"[Security Solution] Tests: Filter by rule execution status (#160502)\n\n**Resolves: https://github.com/elastic/kibana/issues/138903**\r\n\r\n## Summary\r\n\r\nAdds an E2E Cypress test to check filtering by execution status in the\r\nrules table.\r\n<img width=\"953\" alt=\"Screenshot 2023-06-26 at 14 10 10\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/e1eb67ed-779c-42ad-8194-04a26598cfbc\">","sha":"c30a7d47eb4a467734b08bfea1d8d3c3c301b5cb","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","test_ui_functional","release_note:skip","Team:Detections and Resp","Team: SecuritySolution","Feature:Rule Management","Team:Detection Rule Management","v8.9.0","v8.10.0"],"number":160502,"url":"https://github.com/elastic/kibana/pull/160502","mergeCommit":{"message":"[Security Solution] Tests: Filter by rule execution status (#160502)\n\n**Resolves: https://github.com/elastic/kibana/issues/138903**\r\n\r\n## Summary\r\n\r\nAdds an E2E Cypress test to check filtering by execution status in the\r\nrules table.\r\n<img width=\"953\" alt=\"Screenshot 2023-06-26 at 14 10 10\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/e1eb67ed-779c-42ad-8194-04a26598cfbc\">","sha":"c30a7d47eb4a467734b08bfea1d8d3c3c301b5cb"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160502","number":160502,"mergeCommit":{"message":"[Security Solution] Tests: Filter by rule execution status (#160502)\n\n**Resolves: https://github.com/elastic/kibana/issues/138903**\r\n\r\n## Summary\r\n\r\nAdds an E2E Cypress test to check filtering by execution status in the\r\nrules table.\r\n<img width=\"953\" alt=\"Screenshot 2023-06-26 at 14 10 10\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/e1eb67ed-779c-42ad-8194-04a26598cfbc\">","sha":"c30a7d47eb4a467734b08bfea1d8d3c3c301b5cb"}}]}] BACKPORT--> Co-authored-by: Nikita Indik <[email protected]>
- Loading branch information
1 parent
4115904
commit d844b83
Showing
6 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
x-pack/plugins/security_solution/cypress/e2e/detection_rules/rule_fiters.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { cleanKibana, resetRulesTableState, deleteAlertsAndRules } from '../../tasks/common'; | ||
import { login, visitWithoutDateRange } from '../../tasks/login'; | ||
import { esArchiverResetKibana } from '../../tasks/es_archiver'; | ||
import { | ||
expectRulesWithExecutionStatus, | ||
filterByExecutionStatus, | ||
expectNumberOfRulesShownOnPage, | ||
} from '../../tasks/rule_filters'; | ||
|
||
import { SECURITY_DETECTIONS_RULES_URL } from '../../urls/navigation'; | ||
|
||
import { waitForRulesTableToBeLoaded } from '../../tasks/alerts_detection_rules'; | ||
|
||
import { createRule, waitForRulesToFinishExecution } from '../../tasks/api_calls/rules'; | ||
import { deleteIndex, createIndex, createDocument } from '../../tasks/api_calls/elasticsearch'; | ||
|
||
import { getNewRule } from '../../objects/rule'; | ||
|
||
describe('Rule management filters', () => { | ||
before(() => { | ||
cleanKibana(); | ||
}); | ||
|
||
beforeEach(() => { | ||
login(); | ||
// Make sure persisted rules table state is cleared | ||
resetRulesTableState(); | ||
deleteAlertsAndRules(); | ||
esArchiverResetKibana(); | ||
}); | ||
|
||
describe('Last response filter', () => { | ||
it('Filters rules by last response', function () { | ||
deleteIndex('test_index'); | ||
|
||
createIndex('test_index', { | ||
'@timestamp': { | ||
type: 'date', | ||
}, | ||
}); | ||
|
||
createDocument('test_index', {}); | ||
|
||
createRule( | ||
getNewRule({ | ||
name: 'Successful rule', | ||
rule_id: 'successful_rule', | ||
index: ['test_index'], | ||
}) | ||
); | ||
|
||
createRule( | ||
getNewRule({ | ||
name: 'Warning rule', | ||
rule_id: 'warning_rule', | ||
index: ['non_existent_index'], | ||
}) | ||
); | ||
|
||
createRule( | ||
getNewRule({ | ||
name: 'Failed rule', | ||
rule_id: 'failed_rule', | ||
index: ['test_index'], | ||
// Setting a crazy large "Additional look-back time" to force a failure | ||
from: 'now-9007199254746990s', | ||
}) | ||
); | ||
|
||
waitForRulesToFinishExecution(['successful_rule', 'warning_rule', 'failed_rule'], new Date()); | ||
|
||
visitWithoutDateRange(SECURITY_DETECTIONS_RULES_URL); | ||
|
||
waitForRulesTableToBeLoaded(); | ||
|
||
// Initial table state - before filtering by status | ||
expectNumberOfRulesShownOnPage(3); | ||
expectRulesWithExecutionStatus(1, 'Succeeded'); | ||
expectRulesWithExecutionStatus(1, 'Warning'); | ||
expectRulesWithExecutionStatus(1, 'Failed'); | ||
|
||
// Table state after filtering by Succeeded status | ||
filterByExecutionStatus('Succeeded'); | ||
expectNumberOfRulesShownOnPage(1); | ||
expectRulesWithExecutionStatus(1, 'Succeeded'); | ||
|
||
// Table state after filtering by Warning status | ||
filterByExecutionStatus('Warning'); | ||
expectNumberOfRulesShownOnPage(1); | ||
expectRulesWithExecutionStatus(1, 'Warning'); | ||
|
||
// Table state after filtering by Failed status | ||
filterByExecutionStatus('Failed'); | ||
expectNumberOfRulesShownOnPage(1); | ||
expectRulesWithExecutionStatus(1, 'Failed'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/security_solution/cypress/tasks/rule_filters.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { | ||
RULE_EXECUTION_STATUS_BADGE, | ||
EXECUTION_STATUS_FILTER_BUTTON, | ||
EXECUTION_STATUS_FILTER_OPTION, | ||
} from '../screens/alerts_detection_rules'; | ||
|
||
export const expectRulesWithExecutionStatus = (expectedCount: number, status: string) => { | ||
cy.get(`${RULE_EXECUTION_STATUS_BADGE}:contains("${status}")`).should( | ||
'have.length', | ||
expectedCount | ||
); | ||
}; | ||
|
||
export const expectNumberOfRulesShownOnPage = (expectedCount: number) => | ||
cy.get(RULE_EXECUTION_STATUS_BADGE).should('have.length', expectedCount); | ||
|
||
export const filterByExecutionStatus = (status: string) => { | ||
cy.get(EXECUTION_STATUS_FILTER_BUTTON).click(); | ||
cy.get(`${EXECUTION_STATUS_FILTER_OPTION}:contains("${status}")`).click(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters