-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Unskip related integrations Cypress tests in ESS (#…
…166659) **Related to: #165359 **Resolves: #165504 ## Summary This PR unskips skipped rule integrations ESS tests. ## Details Besides just unskipping ESS tests this PR simplifies the test by fetching alert data from the ES directly instead of using multiple steps in UI to validate an expected field has an expected value. ## Flaky test runner ESS [related_integrations.cy.ts 100 runs](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3199) 🟢
- Loading branch information
Showing
4 changed files
with
110 additions
and
40 deletions.
There are no files selected for viewing
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
77 changes: 77 additions & 0 deletions
77
x-pack/test/security_solution_cypress/cypress/tasks/api_calls/alerts.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,77 @@ | ||
/* | ||
* 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 { | ||
RuleObjectId, | ||
RuleSignatureId, | ||
} from '@kbn/security-solution-plugin/common/api/detection_engine'; | ||
import { rootRequest } from '../common'; | ||
|
||
export const DEFAULT_ALERTS_INDEX_PATTERN = '.alerts-security.alerts-*'; | ||
|
||
interface FetchRuleAlertsParams { | ||
ruleId: RuleObjectId | RuleSignatureId; | ||
fields: string[]; | ||
size?: number; | ||
} | ||
|
||
interface AlertFields { | ||
fields: Record<string, unknown>; | ||
} | ||
|
||
interface AlertsResponse { | ||
hits: { | ||
total: { | ||
value: number; | ||
}; | ||
hits: AlertFields[]; | ||
}; | ||
} | ||
|
||
/** | ||
* Returns rule's generated alerts | ||
* | ||
* @param ruleId a rule id representing either RuleObjectId (Saved Object id) or RuleSignatureId (rule_id) | ||
* @param fields fields to fetch (fetch only fields you need to do assertions on) | ||
* @param size a number of alerts to fetch | ||
* | ||
* @returns rule's generated alerts | ||
*/ | ||
export function fetchRuleAlerts({ | ||
ruleId, | ||
fields, | ||
size, | ||
}: FetchRuleAlertsParams): Cypress.Chainable<Cypress.Response<AlertsResponse>> { | ||
return rootRequest<AlertsResponse>({ | ||
method: 'GET', | ||
url: `${Cypress.env('ELASTICSEARCH_URL')}/${DEFAULT_ALERTS_INDEX_PATTERN}/_search`, | ||
body: { | ||
query: { | ||
bool: { | ||
should: [ | ||
{ | ||
term: { | ||
'kibana.alert.rule.rule_id': ruleId, | ||
}, | ||
}, | ||
{ | ||
term: { | ||
'kibana.alert.rule.uuid': ruleId, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
fields, | ||
sort: { | ||
'@timestamp': 'desc', | ||
}, | ||
size, | ||
_source: false, | ||
}, | ||
}); | ||
} |
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