Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reporting] Re-enable some skipped tests #27094

Merged
merged 8 commits into from
Dec 14, 2018
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
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally, we would want to log a warning here, but there is no logger in context in this function.

We could also check the statusCode on the err object to try to be certain it's a case of attempt to create an index that already exists. It isn't super specific though, the statusCode will just be 400.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The FIXME was that we should log a warning here. That'll take a bit of refactoring to get a logger in scope

}
return exists;
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/reporting/api/bwc_existing_indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ({ getService }) {
let expectedCompletedReportCount;
let cleanupIndexAlias;

describe.skip('existing 6_2 index', () => {
describe('existing 6_2 index', () => {
before('load data and add index alias', async () => {
await reportingAPI.deleteAllReportingIndexes();
await esArchiver.load('bwc/6_2');
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/reporting/api/bwc_generation_urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function ({ getService }) {
}).timeout(500000);
});

describe.skip('6_2', () => {
describe('6_2', () => {
before(async () => {
await reportingAPI.deleteAllReportingIndexes();
});
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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup here

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.skip('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
11 changes: 7 additions & 4 deletions x-pack/test/reporting/functional/reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,26 +261,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.skip('generates a report with data', async () => {
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.skip('generates a report with no data', async () => {
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