Skip to content

Commit

Permalink
[ML] Functional tests - add retry to Fleet package install and removal (
Browse files Browse the repository at this point in the history
elastic#120076)

This PR stabilizes the module test setup and teardown by adding retries to the Fleet package install and removal service methods.
  • Loading branch information
pheyos authored and gbamparop committed Jan 12, 2022
1 parent ffd1488 commit fc218be
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions x-pack/test/functional/services/ml/test_resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,12 @@ export function MachineLearningTestResourcesProvider({ getService }: FtrProvider
const version = await this.getFleetPackageVersion(packageName);
const packageWithVersion = `${packageName}-${version}`;

await supertest
.post(`/api/fleet/epm/packages/${packageWithVersion}`)
.set(COMMON_REQUEST_HEADERS)
.expect(200);
await retry.tryForTime(30 * 1000, async () => {
await supertest
.post(`/api/fleet/epm/packages/${packageWithVersion}`)
.set(COMMON_REQUEST_HEADERS)
.expect(200);
});

log.debug(` > Installed`);
return packageWithVersion;
Expand All @@ -488,10 +490,12 @@ export function MachineLearningTestResourcesProvider({ getService }: FtrProvider
async removeFleetPackage(packageWithVersion: string) {
log.debug(`Removing Fleet package '${packageWithVersion}'`);

await supertest
.delete(`/api/fleet/epm/packages/${packageWithVersion}`)
.set(COMMON_REQUEST_HEADERS)
.expect(200);
await retry.tryForTime(30 * 1000, async () => {
await supertest
.delete(`/api/fleet/epm/packages/${packageWithVersion}`)
.set(COMMON_REQUEST_HEADERS)
.expect(200);
});

log.debug(` > Removed`);
},
Expand Down

0 comments on commit fc218be

Please sign in to comment.