mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[APM] Add retry mechanism to synthtrace (#159623)
Closes https://github.com/elastic/kibana/issues/159614 Add retry mechanism to `synthtraceKibanaClient.installApmPackage` to reduce possible flakiness in tests.
This commit is contained in:
parent
5df612ef64
commit
b8823520d0
1 changed files with 9 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import fetch from 'node-fetch';
|
||||
import pRetry from 'p-retry';
|
||||
import { Logger } from '../../utils/create_logger';
|
||||
|
||||
export class ApmSynthtraceKibanaClient {
|
||||
|
@ -42,17 +43,20 @@ export class ApmSynthtraceKibanaClient {
|
|||
async installApmPackage(packageVersion: string) {
|
||||
this.logger.debug(`Installing APM package ${packageVersion}`);
|
||||
|
||||
const response = await fetch(`${this.target}/api/fleet/epm/packages/apm/${packageVersion}`, {
|
||||
method: 'POST',
|
||||
headers: kibanaHeaders(),
|
||||
body: '{"force":true}',
|
||||
const url = `${this.target}/api/fleet/epm/packages/apm/${packageVersion}`;
|
||||
const response = await pRetry(() => {
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
headers: kibanaHeaders(),
|
||||
body: '{"force":true}',
|
||||
});
|
||||
});
|
||||
|
||||
const responseJson = await response.json();
|
||||
|
||||
if (!responseJson.items) {
|
||||
throw new Error(
|
||||
`Failed to install APM package version ${packageVersion}, received HTTP ${response.status} and message: ${responseJson.message}`
|
||||
`Failed to install APM package version ${packageVersion}, received HTTP ${response.status} and message: ${responseJson.message} for url ${url}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue