Skip to content

Commit

Permalink
Reporting API test expansion and clean up (elastic#18986)
Browse files Browse the repository at this point in the history
* Update & expand reporting API tests

* remove xpack stuff from oss archive

* wrap "it"s so they are in expected order.

* Update expected recent stats

* url was pointing to a visualization not a csv

* Move comment around

* Merging with changes on master renaming stats to usage

* fix reference to old stats file.

* bad merge
  • Loading branch information
stacey-gammon committed May 22, 2018
1 parent 742f9b5 commit fbcee4e
Show file tree
Hide file tree
Showing 21 changed files with 730 additions and 686 deletions.
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

0 comments on commit fbcee4e

Please sign in to comment.