mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Unskip] x-pack/.../summary_actions.ts (#193120)
## Summary Use retryForTime instead. Test against local (fake mki) and mki; both were security projects. Tested against `x-pack/test_serverless/api_integration/test_suites/security/common_configs/config.group1.ts` Resolves: https://github.com/elastic/kibana/issues/193061 --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
bfbcf6291e
commit
78b21cd9f9
2 changed files with 43 additions and 7 deletions
|
@ -39,8 +39,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
const alertingApi = getService('alertingApi');
|
||||
let roleAdmin: RoleCredentials;
|
||||
|
||||
// Failing: See https://github.com/elastic/kibana/issues/193061
|
||||
describe.skip('Summary actions', function () {
|
||||
describe('Summary actions', function () {
|
||||
const RULE_TYPE_ID = '.es-query';
|
||||
const ALERT_ACTION_INDEX = 'alert-action-es-query';
|
||||
const ALERT_INDEX = '.alerts-stack.alerts-default';
|
||||
|
@ -491,16 +490,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
ruleId = createdRule.id;
|
||||
|
||||
const resp = await alertingApi.helpers.waitForDocumentInIndex({
|
||||
const resp = await alertingApi.helpers.waitForDocumentInIndexForTime({
|
||||
esClient,
|
||||
indexName: ALERT_ACTION_INDEX,
|
||||
ruleId,
|
||||
num: 2,
|
||||
sort: 'asc',
|
||||
retryOptions: {
|
||||
retryCount: 20,
|
||||
retryDelay: 10_000,
|
||||
},
|
||||
timeout: 180_000,
|
||||
});
|
||||
|
||||
const resp2 = await alertingApi.helpers.waitForAlertInIndex({
|
||||
|
|
|
@ -102,6 +102,46 @@ export function AlertingApiProvider({ getService }: FtrProviderContext) {
|
|||
);
|
||||
},
|
||||
|
||||
async waitForDocumentInIndexForTime({
|
||||
esClient,
|
||||
indexName,
|
||||
ruleId,
|
||||
num = 1,
|
||||
sort = 'desc',
|
||||
timeout = 1000,
|
||||
}: {
|
||||
esClient: Client;
|
||||
indexName: string;
|
||||
ruleId: string;
|
||||
num?: number;
|
||||
sort?: 'asc' | 'desc';
|
||||
timeout?: number;
|
||||
}): Promise<SearchResponse> {
|
||||
return await retry.tryForTime(timeout, async () => {
|
||||
const response = await esClient.search({
|
||||
index: indexName,
|
||||
sort: `date:${sort}`,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
{
|
||||
term: {
|
||||
'ruleId.keyword': ruleId,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (response.hits.hits.length < num) {
|
||||
throw new Error(`Only found ${response.hits.hits.length} / ${num} documents`);
|
||||
}
|
||||
return response;
|
||||
});
|
||||
},
|
||||
|
||||
async waitForDocumentInIndex({
|
||||
esClient,
|
||||
indexName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue