Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unskip] x-pack/.../summary_actions.ts #193120

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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