Skip to content

Commit

Permalink
[Reporting] Consolidate API Integration Test configs (elastic#66637)
Browse files Browse the repository at this point in the history
* [Reporting] Consolidate API Integration Test configs

* fix test isolation

* tweak

* import order

* fix ts refactor ish

* fix a test bug

* fix test

* --wip-- [skip ci]

* revision

* undo bad cherrypick

* fix delete reports

* log tweak

* fix default index pattern

* fix the test

* revert

* --wip-- [skip ci]

* unrevert

* harden the deleteAllReportingIndexes function

* fix tests

* move the log.debug line

* fix config path

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
tsullivan and elasticmachine committed May 19, 2020
1 parent a74535b commit 8696276
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 129 deletions.
1 change: 1 addition & 0 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ require('@kbn/test').runTestsCli([
require.resolve('../test/functional_endpoint_ingest_failure/config.ts'),
require.resolve('../test/functional_endpoint/config.ts'),
require.resolve('../test/endpoint_api_integration_no_ingest/config.ts'),
require.resolve('../test/reporting_api_integration/config.js'),
]);
1 change: 0 additions & 1 deletion x-pack/test/reporting/.gitignore

This file was deleted.

36 changes: 0 additions & 36 deletions x-pack/test/reporting/api/chromium_tests.ts

This file was deleted.

39 changes: 0 additions & 39 deletions x-pack/test/reporting/configs/chromium_api.js

This file was deleted.

15 changes: 0 additions & 15 deletions x-pack/test/reporting/services/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,35 @@

import { esTestConfig, kbnTestConfig, kibanaServerTestUser } from '@kbn/test';
import { format as formatUrl } from 'url';
import { ReportingAPIProvider } from '../services';
import { ReportingAPIProvider } from './services';

export default async function({ readConfigFile }) {
const apiConfig = await readConfigFile(require.resolve('../../api_integration/config.js'));
const apiConfig = await readConfigFile(require.resolve('../api_integration/config'));
const functionalConfig = await readConfigFile(require.resolve('../functional/config')); // Reporting API tests need a fully working UI

return {
servers: apiConfig.get('servers'),
junit: { reportName: 'X-Pack Reporting Generate API Integration Tests' },
testFiles: [require.resolve('../api/generate')],
junit: { reportName: 'X-Pack Reporting API Integration Tests' },
testFiles: [require.resolve('./reporting')],
services: {
...apiConfig.get('services'),
reportingAPI: ReportingAPIProvider,
},
kbnTestServer: {
...apiConfig.get('kbnTestServer'),
serverArgs: [
'--logging.events.log',
'["info","warning","error","fatal","optimize","reporting"]',
...functionalConfig.get('kbnTestServer.serverArgs'),

`--elasticsearch.hosts=${formatUrl(esTestConfig.getUrlParts())}`,
`--elasticsearch.password=${kibanaServerTestUser.password}`,
`--elasticsearch.username=${kibanaServerTestUser.username}`,
`--logging.json=false`,
`--optimize.enabled=false`,
`--server.maxPayloadBytes=1679958`,
`--server.port=${kbnTestConfig.getPort()}`,
`--xpack.reporting.csv.enablePanelActionDownload=true`,
`--xpack.reporting.capture.maxAttempts=1`,
`--xpack.reporting.csv.maxSizeBytes=2850`,
`--xpack.reporting.queue.pollInterval=3000`,
`--xpack.security.session.idleTimeout=3600000`,
`--xpack.spaces.enabled=false`,
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import * as GenerationUrls from './generation_urls';
import * as GenerationUrls from '../generation_urls';

/**
* This file tests the situation when a reporting index spans releases. By default reporting indexes are created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import * as GenerationUrls from './generation_urls';
import * as GenerationUrls from '../generation_urls';

export default function({ getService }) {
const reportingAPI = getService('reportingAPI');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { REPO_ROOT } from '@kbn/dev-utils';
import path from 'path';

export const OSS_KIBANA_ARCHIVE_PATH = path.resolve(
__dirname,
'../../../../test/functional/fixtures/es_archiver/dashboard/current/kibana'
REPO_ROOT,
'test/functional/fixtures/es_archiver/dashboard/current/kibana'
);
export const OSS_DATA_ARCHIVE_PATH = path.resolve(
__dirname,
'../../../../test/functional/fixtures/es_archiver/dashboard/current/data'
REPO_ROOT,
'test/functional/fixtures/es_archiver/dashboard/current/data'
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

import expect from '@kbn/expect';
import supertest from 'supertest';
import { JOB_PARAMS_RISON } from './fixtures';
import { JOB_PARAMS_RISON } from '../fixtures';
import { FtrProviderContext } from '../ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function({ getService }: { getService: any }) {
export default function({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertestSvc = getService('supertest');
const reportingAPI = getService('reportingAPI');

const generateAPI = {
getCsvFromParamsInPayload: async (jobParams: object = {}) => {
return await supertestSvc
Expand All @@ -30,11 +33,13 @@ export default function({ getService }: { getService: any }) {
before(async () => {
await esArchiver.load('reporting/logs');
await esArchiver.load('logstash_functional');
}); // prettier-ignore
});

after(async () => {
await esArchiver.unload('reporting/logs');
await esArchiver.unload('logstash_functional');
}); // prettier-ignore
await reportingAPI.deleteAllReports();
});

it('Rejects bogus jobParams', async () => {
const { status: resStatus, text: resText } = (await generateAPI.getCsvFromParamsInPayload({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
import expect from '@kbn/expect';
import supertest from 'supertest';
import {
CSV_RESULT_DOCVALUE,
CSV_RESULT_HUGE,
CSV_RESULT_NANOS,
CSV_RESULT_SCRIPTED,
CSV_RESULT_SCRIPTED_REQUERY,
CSV_RESULT_SCRIPTED_RESORTED,
CSV_RESULT_TIMEBASED,
CSV_RESULT_TIMELESS,
CSV_RESULT_NANOS,
CSV_RESULT_DOCVALUE,
} from './fixtures';
} from '../fixtures';
import { FtrProviderContext } from '../ftr_provider_context';

interface GenerateOpts {
timerange?: {
Expand All @@ -27,9 +28,11 @@ interface GenerateOpts {
}

// eslint-disable-next-line import/no-default-export
export default function({ getService }: { getService: any }) {
export default function({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertestSvc = getService('supertest');
const reportingAPI = getService('reportingAPI');

const generateAPI = {
getCsvFromSavedSearch: async (
id: string,
Expand All @@ -45,6 +48,10 @@ export default function({ getService }: { getService: any }) {

describe('Generation from Saved Search ID', () => {
describe('Saved Search Features', () => {
after(async () => {
await reportingAPI.deleteAllReports();
});

it('With filters and timebased data', async () => {
// load test data that contains a saved search and documents
await esArchiver.load('reporting/logs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../../ftr_provider_context';
import { FtrProviderContext } from '../ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function({ loadTestFile }: FtrProviderContext) {
describe('CSV', function() {
describe('Reporting APIs', function() {
this.tags('ciGroup2');
loadTestFile(require.resolve('./csv_saved_search'));
loadTestFile(require.resolve('./bwc_existing_indexes'));
loadTestFile(require.resolve('./bwc_generation_urls'));
loadTestFile(require.resolve('./csv_job_params'));
loadTestFile(require.resolve('./csv_saved_search'));
loadTestFile(require.resolve('./usage'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';
import { ReportingUsageStats } from '../services/reporting_api';
import * as GenerationUrls from './generation_urls';
import * as GenerationUrls from '../generation_urls';
import { ReportingUsageStats } from '../services';
import { OSS_DATA_ARCHIVE_PATH, OSS_KIBANA_ARCHIVE_PATH } from './constants';

interface UsageStats {
reporting: ReportingUsageStats;
Expand All @@ -16,12 +17,29 @@ interface UsageStats {
// eslint-disable-next-line import/no-default-export
export default function({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const reportingAPI = getService('reportingAPI');
const usageAPI = getService('usageAPI' as any); // NOTE Usage API service is not Typescript

describe('reporting usage', () => {
before(() => reportingAPI.deleteAllReportingIndexes());
afterEach(() => reportingAPI.deleteAllReportingIndexes());
before(async () => {
await esArchiver.load(OSS_KIBANA_ARCHIVE_PATH);
await esArchiver.load(OSS_DATA_ARCHIVE_PATH);

await kibanaServer.uiSettings.update({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await reportingAPI.deleteAllReports();
});

after(async () => {
await esArchiver.unload(OSS_KIBANA_ARCHIVE_PATH);
await esArchiver.unload(OSS_DATA_ARCHIVE_PATH);
});

afterEach(async () => {
await reportingAPI.deleteAllReports();
});

describe('initial state', () => {
let usage: UsageStats;
Expand Down Expand Up @@ -98,7 +116,7 @@ export default function({ getService }: FtrProviderContext) {
});

describe('from new jobs posted', () => {
it('csv', async () => {
it('should handle csv', async () => {
await reportingAPI.expectAllJobsToFinishSuccessfully(
await Promise.all([
reportingAPI.postJob(GenerationUrls.CSV_DISCOVER_KUERY_AND_FILTER_6_3),
Expand All @@ -114,7 +132,7 @@ export default function({ getService }: FtrProviderContext) {
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 0);
});

it('preserve_layout pdf', async () => {
it('should handle preserve_layout pdf', async () => {
await reportingAPI.expectAllJobsToFinishSuccessfully(
await Promise.all([
reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_DASHBOARD_FILTER_6_3),
Expand All @@ -131,7 +149,7 @@ export default function({ getService }: FtrProviderContext) {
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 2);
});

it('print_layout pdf', async () => {
it('should handle print_layout pdf', async () => {
await reportingAPI.expectAllJobsToFinishSuccessfully(
await Promise.all([
reportingAPI.postJob(GenerationUrls.PDF_PRINT_DASHBOARD_6_3),
Expand Down
Loading

0 comments on commit 8696276

Please sign in to comment.