Skip to content

Commit

Permalink
[Unskip] x-pack/.../summary_actions.ts (elastic#193120)
Browse files Browse the repository at this point in the history
## 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: elastic#193061

---------

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
wayneseymour and elasticmachine committed Sep 18, 2024
1 parent bfbcf62 commit 78b21cd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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({
Expand Down
40 changes: 40 additions & 0 deletions x-pack/test_serverless/shared/services/alerting_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 78b21cd

Please sign in to comment.