Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
82 changes: 51 additions & 31 deletions x-pack/test/reporting/api/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -79,44 +78,65 @@ 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);
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 3);
});
});

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));

await reportingAPI.expectAllJobsToFinishSuccessfully(reportPaths);
}).timeout(1540000);
describe('from new jobs posted', () => {
it('csv', async () => {
await reportingAPI.expectAllJobsToFinishSuccessfully(await Promise.all([
reportingAPI.postJob(GenerationUrls.CSV_DISCOVER_KUERY_AND_FILTER_6_3),
]));

it('usage updated', async () => {
const usage = await usageAPI.getUsageStats();
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', 0);
});

reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 2);
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 2);
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', 1);
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 4);

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);
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);
});
});
});
Expand Down
7 changes: 5 additions & 2 deletions x-pack/test/reporting/functional/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down