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] Consolidate API Integration Test configs #66637

Merged
merged 29 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c64896d
[Reporting] Consolidate API Integration Test configs
tsullivan May 14, 2020
a499f88
fix test isolation
tsullivan May 14, 2020
7e510e8
tweak
tsullivan May 14, 2020
a62d6f3
Merge branch 'master' into reporting/api-test-unify
tsullivan May 14, 2020
796fd5b
Merge branch 'master' into reporting/api-test-unify
tsullivan May 15, 2020
72037e6
import order
tsullivan May 15, 2020
37bd652
fix ts refactor ish
tsullivan May 15, 2020
81b0c15
Merge branch 'master' into reporting/api-test-unify
tsullivan May 15, 2020
ecee222
fix a test bug
tsullivan May 15, 2020
8267e04
fix test
tsullivan May 15, 2020
cbea357
--wip-- [skip ci]
tsullivan May 15, 2020
7590bbc
revision
tsullivan May 15, 2020
d0beba7
undo bad cherrypick
tsullivan May 15, 2020
dfdabfb
fix delete reports
tsullivan May 15, 2020
981d6b2
log tweak
tsullivan May 15, 2020
77a44f7
fix default index pattern
tsullivan May 15, 2020
7536c95
fix the test
tsullivan May 15, 2020
0064950
revert
tsullivan May 15, 2020
c7e11f9
--wip-- [skip ci]
tsullivan May 15, 2020
778db3a
unrevert
tsullivan May 15, 2020
133bcf9
harden the deleteAllReportingIndexes function
tsullivan May 18, 2020
4b77347
Merge branch 'master' into reporting/api-test-unify
tsullivan May 18, 2020
aa4108b
fix tests
tsullivan May 18, 2020
0539a76
Merge branch 'master' into reporting/api-test-unify
elasticmachine May 18, 2020
62ff1aa
move the log.debug line
tsullivan May 18, 2020
ba21be6
Merge branch 'reporting/api-test-unify' of github.com:tsullivan/kiban…
tsullivan May 18, 2020
3426c86
fix config path
tsullivan May 19, 2020
4a6e200
Merge branch 'master' into reporting/api-test-unify
elasticmachine May 19, 2020
1975fd4
Merge branch 'master' into reporting/api-test-unify
tsullivan May 19, 2020
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
3 changes: 1 addition & 2 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const alwaysImportedTests = [
require.resolve('../test/plugin_functional/config.ts'),
];
const onlyNotInCoverageTests = [
require.resolve('../test/reporting/configs/chromium_api.js'),
require.resolve('../test/reporting/configs/generate_api.js'),
require.resolve('../test/api_integration/config_security_basic.js'),
require.resolve('../test/api_integration/config.js'),
require.resolve('../test/alerting_api_integration/basic/config.ts'),
Expand Down Expand Up @@ -53,6 +51,7 @@ const onlyNotInCoverageTests = [
require.resolve('../test/licensing_plugin/config.public.ts'),
require.resolve('../test/licensing_plugin/config.legacy.ts'),
require.resolve('../test/endpoint_api_integration_no_ingest/config.ts'),
require.resolve('../test/reporting_api_integration/config.ts'),
];

require('@kbn/plugin-helpers').babelRegister();
Expand Down
1 change: 0 additions & 1 deletion x-pack/test/reporting/.gitignore

This file was deleted.

34 changes: 0 additions & 34 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"]',
Copy link
Member Author

Choose a reason for hiding this comment

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

This logging config param was removed, because it isn't the correct way to see debug logs for just Reporting. This is the case since the Reporting config migration.

...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 @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nice!

'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,14 @@
* 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('./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