forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase alerting test stability and reduce flakiness (elastic#50246) (…
…elastic#50944) * Increase alerting test stability * More changes to test methodology + bug fix in throttling * Fix comments * Cleanup * Typo * Fix broken tests * Fix integration tests * Fix typo
- Loading branch information
Showing
16 changed files
with
226 additions
and
95 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
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
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
46 changes: 46 additions & 0 deletions
46
x-pack/test/alerting_api_integration/common/lib/task_manager_utils.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,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export class TaskManagerUtils { | ||
private readonly es: any; | ||
private readonly retry: any; | ||
|
||
constructor(es: any, retry: any) { | ||
this.es = es; | ||
this.retry = retry; | ||
} | ||
|
||
async waitForIdle(taskRunAtFilter: Date) { | ||
return await this.retry.try(async () => { | ||
const searchResult = await this.es.search({ | ||
index: '.kibana_task_manager', | ||
body: { | ||
query: { | ||
bool: { | ||
must: [ | ||
{ | ||
terms: { | ||
'task.scope': ['actions', 'alerting'], | ||
}, | ||
}, | ||
{ | ||
range: { | ||
'task.scheduledAt': { | ||
gte: taskRunAtFilter, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}); | ||
if (searchResult.hits.total.value) { | ||
throw new Error(`Expected 0 tasks but received ${searchResult.hits.total.value}`); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.