Skip to content

Commit

Permalink
Functional tests - stabilize reporting API network policy test for cl…
Browse files Browse the repository at this point in the history
…oud (#88456) (#88489)

This PR fixes a reporting API network policy test failure that occurred during cloud execution.
  • Loading branch information
pheyos authored Jan 16, 2021
1 parent 8df8ff7 commit e606456
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
*/

import expect from '@kbn/expect';
import * as Rx from 'rxjs';
import { filter, first, map, switchMap, timeout } from 'rxjs/operators';
import { FtrProviderContext } from '../ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const reportingAPI = getService('reportingAPI');
const retry = getService('retry');
const supertest = getService('supertest');
const archive = 'reporting/canvas_disallowed_url';

Expand All @@ -35,17 +34,10 @@ export default function ({ getService }: FtrProviderContext) {
);

// Retry the download URL until a "failed" response status is returned
const fails$: Rx.Observable<string> = Rx.interval(100).pipe(
switchMap(() => supertest.get(downloadPath).then((response) => response.body)),
filter(({ statusCode }) => statusCode === 500),
map(({ message }) => message),
first(),
timeout(120000)
);

const reportFailed = await fails$.toPromise();

expect(reportFailed).to.match(/Reporting generation failed: Error:/);
await retry.tryForTime(120000, async () => {
const { body } = await supertest.get(downloadPath).expect(500);
expect(body.message).to.match(/Reporting generation failed: Error:/);
});
});
});
}

0 comments on commit e606456

Please sign in to comment.