[Reporting] Re-enable some skipped tests (#27094) (#27177)

* [Test/Reporting] Enable "generates a report with/without data"

* navigate to discover before each csv test

* get another test working

* re-enable more tests

* refactor api usage tests

* catch error in createIndex to avoid race condition in test

* delete reports before
This commit is contained in:
Tim Sullivan 2018-12-13 17:56:35 -07:00 committed by GitHub
parent 73df41bd70
commit a34e01a836
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 35 deletions

View file

@ -88,7 +88,17 @@ export function createIndex(client, indexName,
index: indexName,
body: body
})
.then(() => true);
.then(() => true)
.catch(err => {
/* FIXME creating the index will fail if there were multiple jobs staged in parallel.
* Each staged job checks `client.indices.exists` and could each get `false` as a response.
* Only the first job in line can successfully create it though.
* The problem might only happen in automated tests, where the indices are deleted after each test run.
* This catch block is in place to not fail a job if the job runner hits this race condition.
* Unfortunately we don't have a logger in scope to log a warning.
*/
err; // no-op
});
}
return exists;
});

View file

@ -13,11 +13,10 @@ export default function ({ getService }) {
const usageAPI = getService('usageAPI');
describe('reporting usage', () => {
before(async () => {
await reportingAPI.deleteAllReportingIndexes();
});
before(() => reportingAPI.deleteAllReportingIndexes());
afterEach(() => reportingAPI.deleteAllReportingIndexes());
describe('initial usage', () => {
describe('initial state', () => {
let usage;
before(async () => {
@ -45,7 +44,7 @@ export default function ({ getService }) {
});
});
describe('includes usage from reporting indexes', () => {
describe('from archive data', () => {
it('generated from 6.2', async () => {
await esArchiver.load('bwc/6_2');
const usage = await usageAPI.getUsageStats();
@ -79,8 +78,8 @@ export default function ({ getService }) {
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 0);
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 0);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 3);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 19);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 2);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 12);
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 3);
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 3);
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 3);
@ -88,35 +87,56 @@ export default function ({ getService }) {
});
});
describe('usage updated when new jobs are posted', async () => {
it('post jobs', async () => {
const reportPaths = [];
reportPaths.push(await reportingAPI.postJob(GenerationUrls.CSV_DISCOVER_KUERY_AND_FILTER_6_3));
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_DASHBOARD_FILTER_6_3));
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_PIE_VISUALIZATION_6_3));
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRINT_DASHBOARD_6_3));
reportPaths.push(await reportingAPI.postJob(
GenerationUrls.PDF_PRINT_PIE_VISUALIZATION_FILTER_AND_SAVED_SEARCH_6_3));
describe('from new jobs posted', () => {
it('csv', async () => {
await reportingAPI.expectAllJobsToFinishSuccessfully(await Promise.all([
reportingAPI.postJob(GenerationUrls.CSV_DISCOVER_KUERY_AND_FILTER_6_3),
]));
await reportingAPI.expectAllJobsToFinishSuccessfully(reportPaths);
}).timeout(1540000);
it('usage updated', async () => {
const usage = await usageAPI.getUsageStats();
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 2);
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 2);
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 2);
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 2);
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 0);
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 0);
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 0);
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 0);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 1);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 4);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 0);
});
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 5);
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 5);
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 5);
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 5);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 4);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 23);
it('preserve_layout pdf', async () => {
await reportingAPI.expectAllJobsToFinishSuccessfully(await Promise.all([
reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_DASHBOARD_FILTER_6_3),
reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_PIE_VISUALIZATION_6_3),
]));
const usage = await usageAPI.getUsageStats();
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 1);
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 1);
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 2);
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 0);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 0);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 2);
});
it('print_layout pdf', async () => {
await reportingAPI.expectAllJobsToFinishSuccessfully(await Promise.all([
reportingAPI.postJob(GenerationUrls.PDF_PRINT_DASHBOARD_6_3),
reportingAPI.postJob(GenerationUrls.PDF_PRINT_PIE_VISUALIZATION_FILTER_AND_SAVED_SEARCH_6_3),
]));
const usage = await usageAPI.getUsageStats();
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 1);
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 1);
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 0);
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 2);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 0);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 2);
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 1);
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 1);
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 0);
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 2);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 0);
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 2);
});
});
});

View file

@ -263,26 +263,29 @@ export default function ({ getService, getPageObjects }) {
describe('Discover', () => {
describe('Generate CSV button', () => {
beforeEach(() => PageObjects.common.navigateToApp('discover'));
it('is not available if new', async () => {
await PageObjects.common.navigateToApp('discover');
await PageObjects.reporting.openCsvReportingPanel();
await expectDisabledGenerateReportButton();
});
it('becomes available when saved', async () => {
await PageObjects.discover.saveSearch('my search');
await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton');
await PageObjects.reporting.openCsvReportingPanel();
await expectEnabledGenerateReportButton();
});
it('generates a report with data', async () => {
await PageObjects.reporting.setTimepickerInDataRange();
await PageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated');
await PageObjects.reporting.openCsvReportingPanel();
await expectReportCanBeCreated();
});
it('generates a report with no data', async () => {
await PageObjects.reporting.setTimepickerInNoDataRange();
await PageObjects.discover.saveSearch('my search - no data - expectReportCanBeCreated');
await PageObjects.reporting.openCsvReportingPanel();
await expectReportCanBeCreated();
});