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 API test expansion and clean up #18986

Merged
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
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,4 @@
}
}
}
}
}
65 changes: 65 additions & 0 deletions x-pack/test/api_integration/apis/reporting/bwc_existing_indexes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as GenerationUrls from './generation_urls';


/**
* This file tests the situation when a reporting index spans releases. By default reporting indexes are created
* on a weekly basis, but this is configurable so it is possible a user has this set to yearly. In that event, it
* is possible report data is getting posted to an index that was created by a very old version. We don't have a
* reporting index migration plan, so this test is important to ensure BWC, or that in the event we decide to make
* a major change in a major release, we handle it properly.
*/

export default function ({ getService }) {
const esArchiver = getService('esArchiver');
const reportingAPI = getService('reportingAPI');
const usageAPI = getService('usageAPI');

describe('BWC report generation into existing indexes', async () => {
let expectedCompletedReportCount;
let cleanupIndexAlias;

describe('existing 6_2 index', () => {
before('load data and add index alias', async () => {
await reportingAPI.deleteAllReportingIndexes();
await esArchiver.load('reporting/bwc/6_2');

// The index name in the 6_2 archive.
const ARCHIVED_REPORTING_INDEX = '.reporting-2018.03.11';
cleanupIndexAlias = await reportingAPI.coerceReportsIntoExistingIndex(ARCHIVED_REPORTING_INDEX);

const stats = await usageAPI.getUsageStats();
expectedCompletedReportCount = await reportingAPI.getCompletedReportCount(stats);
});

after('remove index alias', async () => {
await cleanupIndexAlias();
});

// Might not be great test practice to lump all these jobs together but reporting takes awhile and it'll be
// more efficient to post them all up front, then sequentially.
it('multiple jobs posted', 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);

it('jobs completed successfully', async () => {
const stats = await usageAPI.getUsageStats();
expectedCompletedReportCount += 5;
reportingAPI.expectCompletedReportCount(stats, expectedCompletedReportCount);
});
});
});
}
39 changes: 39 additions & 0 deletions x-pack/test/api_integration/apis/reporting/bwc_generation_urls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as GenerationUrls from './generation_urls';

export default function ({ getService }) {
const reportingAPI = getService('reportingAPI');
const usageAPI = getService('usageAPI');

describe('BWC report generation urls', () => {
describe('6_2', () => {
before(async () => {
await reportingAPI.deleteAllReportingIndexes();
});

// Might not be great test practice to lump all these jobs together but reporting takes awhile and it'll be
// more efficient to post them all up front, then sequentially.
it('multiple jobs posted', async () => {
const reportPaths = [];
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRINT_DASHBOARD_6_2));
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_VISUALIZATION_6_2));
reportPaths.push(await reportingAPI.postJob(GenerationUrls.CSV_DISCOVER_FILTER_QUERY_6_2));

await reportingAPI.expectAllJobsToFinishSuccessfully(reportPaths);
}).timeout(1540000);

it('jobs completed successfully', async () => {
const stats = await usageAPI.getUsageStats();
reportingAPI.expectCompletedReportCount(stats, 3);
});
});

// 6.3 urls currently being tested as part of the "bwc_existing_indexes" test suite. Reports are time consuming,
// don't replicate tests if we don't need to, so no specific 6_3 url tests here.
});
}
Loading