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][Serverless E2E Tests] #163354

Merged
merged 181 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
e62ad19
initial commit
rshen91 Aug 7, 2023
1470889
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 7, 2023
c41e5ad
wip
rshen91 Aug 9, 2023
f41317f
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 9, 2023
360b635
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 9, 2023
5a95fca
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Aug 9, 2023
58b58f0
wip
rshen91 Aug 11, 2023
6038c09
Reporting Test Serverless structure: api_integration
tsullivan Aug 15, 2023
6d49f1e
Merge pull request #7 from tsullivan/e2e-svl-reporting
rshen91 Aug 16, 2023
b4883c9
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Aug 16, 2023
aa7e3c4
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 16, 2023
c0809d9
add initial functional test for reporting mgmt app
tsullivan Aug 16, 2023
11228fc
update test-subj in reporting mgmt
tsullivan Aug 16, 2023
c9c8e88
Check for enabled of each export_type
tsullivan Aug 16, 2023
5d7f02a
Provide Reporting API services for functional
tsullivan Aug 16, 2023
eb5e323
Functional test: user can see their report
tsullivan Aug 16, 2023
d0f5df5
un-adjust code for later
tsullivan Aug 17, 2023
40e2af9
Merge pull request #8 from tsullivan/e2e-svl-reporting
rshen91 Aug 17, 2023
9e38fd1
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 17, 2023
4685cb7
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Aug 17, 2023
f5e78b2
initial generate_csv_discover tests no auth yet
rshen91 Aug 17, 2023
42cf233
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Aug 17, 2023
e3bce42
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Aug 17, 2023
a24be94
wip
rshen91 Aug 17, 2023
3125f76
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 17, 2023
45616a2
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Aug 17, 2023
c9ca4b2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 17, 2023
abdc9a3
add dashboard csv ftr
rshen91 Aug 17, 2023
6a10b4f
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 17, 2023
a336e16
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Aug 17, 2023
7e21a8c
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 17, 2023
1c1b9ce
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 21, 2023
6accc19
remove unnecessary comment
rshen91 Aug 21, 2023
cc370d4
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 22, 2023
98800b3
wip
rshen91 Aug 22, 2023
be2e5eb
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 22, 2023
496ce6e
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 22, 2023
b58240c
update
rshen91 Aug 22, 2023
820182f
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 22, 2023
85ac7cc
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Aug 22, 2023
1fed8b6
fix delete report by id and remove deleteAllreports that was returnin…
rshen91 Aug 22, 2023
04854ea
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 22, 2023
00e87f8
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 22, 2023
5431f6e
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 22, 2023
4cf3655
update snapshot
rshen91 Aug 22, 2023
a742964
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 22, 2023
4654cce
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
583a595
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
80d2dbd
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
0b90af4
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
d7d6832
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
46e04f1
create logs file with canvas
rshen91 Aug 23, 2023
3489465
Merge remote-tracking branch 'origin/main' into e2e-svl-reporting
rshen91 Aug 23, 2023
a18f49c
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
68b221c
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
bbaac3f
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 23, 2023
ffbe8ca
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 24, 2023
7c45858
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 24, 2023
9a79b93
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Aug 24, 2023
5061259
update SOPath in test for canvas logs json
rshen91 Aug 24, 2023
5cac5bc
fix
rshen91 Aug 24, 2023
2149c54
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 24, 2023
cf76141
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 24, 2023
081ebf1
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 24, 2023
36d26e4
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 24, 2023
38a5893
Reset non-serverless changes
tsullivan Aug 24, 2023
b4965fe
Remove some extra methods from the reporting test API
tsullivan Aug 24, 2023
2dc0add
new reporting test archives for serverless
tsullivan Aug 24, 2023
3338291
Merge pull request #9 from tsullivan/e2e-svl-reporting
rshen91 Aug 25, 2023
ee45d16
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 25, 2023
48cca35
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 25, 2023
b73b950
skip for schema validation
rshen91 Aug 25, 2023
2b78633
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 25, 2023
923f5f9
undo skip
rshen91 Aug 25, 2023
cc6249d
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Aug 25, 2023
63553b0
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 25, 2023
2057a5b
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 25, 2023
504040c
skip test for telemetry update
rshen91 Aug 25, 2023
43dfa55
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 25, 2023
d313586
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 25, 2023
6a028c7
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Aug 28, 2023
80b835b
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 28, 2023
1c6ffaf
add comments
rshen91 Aug 28, 2023
0ea1500
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Aug 28, 2023
ed22197
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 30, 2023
d573f4b
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 31, 2023
a2698d1
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 31, 2023
693ba5a
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 31, 2023
4584770
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 31, 2023
2390734
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Aug 31, 2023
37f39fe
Merge branch 'main' into e2e-svl-reporting
rshen91 Aug 31, 2023
aadf1be
change order of loading test suites
rshen91 Aug 31, 2023
386a2da
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Aug 31, 2023
d65e3c1
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 31, 2023
9f00597
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Sep 1, 2023
64b32d8
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Sep 1, 2023
6e03402
revert
rshen91 Sep 1, 2023
95bf706
Merge branch 'main' into e2e-svl-reporting
rshen91 Sep 1, 2023
32e7d72
Merge branch 'main' into e2e-svl-reporting
rshen91 Sep 6, 2023
6fea5bf
Merge branch 'main' into e2e-svl-reporting
rshen91 Sep 8, 2023
034df9a
Merge branch 'main' into e2e-svl-reporting
rshen91 Sep 11, 2023
56e7d4c
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Sep 26, 2023
26e9f53
update
rshen91 Sep 26, 2023
78c5054
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 26, 2023
07c684b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Sep 26, 2023
791e9ab
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 26, 2023
9000230
update
rshen91 Sep 26, 2023
df3de6b
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Sep 26, 2023
338c9d8
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Sep 26, 2023
7391703
Merge branch 'main' into e2e-svl-reporting
rshen91 Sep 26, 2023
d26fdaa
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Sep 26, 2023
d530fc4
fix
rshen91 Sep 26, 2023
0ad8e31
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Sep 26, 2023
7c2cd24
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Sep 26, 2023
b72e3e9
Merge branch 'main' into e2e-svl-reporting
rshen91 Sep 27, 2023
29f1d9e
Merge branch 'main' into e2e-svl-reporting
rshen91 Sep 27, 2023
7e52eb2
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Sep 28, 2023
b273942
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Sep 28, 2023
da2bbe0
fix
rshen91 Sep 28, 2023
a976b8b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Sep 28, 2023
83c7137
update
rshen91 Sep 29, 2023
b3c5f50
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Sep 29, 2023
0ecd611
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 2, 2023
6cfa759
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 3, 2023
cf5e1c3
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 3, 2023
670a66f
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 3, 2023
be9b531
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 3, 2023
bd176c8
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 3, 2023
4a160a8
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 4, 2023
fb7a306
code review
rshen91 Oct 4, 2023
6b86479
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 4, 2023
f1795da
fix management tests
rshen91 Oct 4, 2023
f2ce7f4
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Oct 4, 2023
9d4ab7d
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 4, 2023
7e0209b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 4, 2023
d85dc9b
fix
rshen91 Oct 4, 2023
2dd26cc
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Oct 4, 2023
be571bb
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 4, 2023
46442f6
update
rshen91 Oct 5, 2023
026fc1f
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 5, 2023
6362de6
Update x-pack/test_serverless/functional/test_suites/common/reporting…
rshen91 Oct 5, 2023
f3e43cd
update
rshen91 Oct 5, 2023
72fb493
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Oct 5, 2023
7ac6a1c
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 5, 2023
e24f06d
add reporting to common configs in search and obs
rshen91 Oct 5, 2023
aa59405
unskip
rshen91 Oct 5, 2023
477268d
move reporting svl tests to group1 instead of group2d
rshen91 Oct 5, 2023
a9822cb
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 5, 2023
de6512c
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 5, 2023
ab999be
cant log in
rshen91 Oct 5, 2023
7dac314
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Oct 5, 2023
fcb6488
update management to have login
rshen91 Oct 5, 2023
ed4d382
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Oct 5, 2023
fa9b187
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 5, 2023
896ef2d
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 5, 2023
862b2c0
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 6, 2023
919d5b2
code review
rshen91 Oct 6, 2023
63cfcb9
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 6, 2023
2de1275
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Oct 6, 2023
89a9592
update
rshen91 Oct 6, 2023
df66ce1
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 6, 2023
f975c62
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 6, 2023
409cdea
update snapshots
rshen91 Oct 6, 2023
5722e8a
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 6, 2023
b31fa63
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 6, 2023
d2283a0
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 9, 2023
7c96b84
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 9, 2023
3294686
update in config groups
rshen91 Oct 9, 2023
1fb31ee
Merge remote-tracking branch 'upstream/main' into e2e-svl-reporting
rshen91 Oct 10, 2023
fb1737d
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 10, 2023
dcdcce4
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 10, 2023
7eb0a18
update
rshen91 Oct 10, 2023
863b518
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 10, 2023
4a929fc
skipping tests that are failing on MKI testing env
rshen91 Oct 10, 2023
b43a935
Merge remote-tracking branch 'origin/e2e-svl-reporting' into e2e-svl-…
rshen91 Oct 10, 2023
6e44802
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 10, 2023
b207dfc
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 10, 2023
217acc0
fix bad merge
rshen91 Oct 10, 2023
bdb5a20
fix
rshen91 Oct 10, 2023
192b5be
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 10, 2023
8d9050f
Merge branch 'main' into e2e-svl-reporting
rshen91 Oct 10, 2023
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 @@ -166,7 +166,7 @@ export const setup = async (props?: Partial<Props>) => {
flyout: {
open: async (jobId: string) => {
await act(async () => {
find(`viewReportingLink${jobId}`).simulate('click');
find(`viewReportingLink-${jobId}`).simulate('click');
});
component.update();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class ReportListingUi extends Component<Props, State> {
return (
<div data-test-subj="reportingListItemObjectTitle">
<EuiLink
data-test-subj={`viewReportingLink${job.id}`}
data-test-subj={`viewReportingLink-${job.id}`}
onClick={() => this.setState({ selectedJob: job })}
>
{objectTitle ||
Expand Down
2 changes: 2 additions & 0 deletions x-pack/test_serverless/api_integration/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { services as xpackApiIntegrationServices } from '../../../test/api_integ
import { services as svlSharedServices } from '../../shared/services';

import { SvlCommonApiServiceProvider } from './svl_common_api';
import { SvlReportingServiceProvider } from './svl_reporting';
import { AlertingApiProvider } from './alerting_api';
import { SamlToolsProvider } from './saml_tools';
import { DataViewApiProvider } from './data_view_api';
Expand All @@ -20,6 +21,7 @@ export const services = {
...svlSharedServices,

svlCommonApi: SvlCommonApiServiceProvider,
svlReportingAPI: SvlReportingServiceProvider,
alertingApi: AlertingApiProvider,
samlTools: SamlToolsProvider,
dataViewApi: DataViewApiProvider,
Expand Down
182 changes: 182 additions & 0 deletions x-pack/test_serverless/api_integration/services/svl_reporting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common';
import { INTERNAL_ROUTES } from '@kbn/reporting-plugin/common/constants';
import expect from '@kbn/expect';
import type { ReportingJobResponse } from '@kbn/reporting-plugin/server/types';
import rison from '@kbn/rison';
import { FtrProviderContext } from '../ftr_provider_context';

const API_HEADER: [string, string] = ['kbn-xsrf', 'reporting'];
const INTERNAL_HEADER: [string, string] = [X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'Kibana'];

const DATA_ANALYST_PASSWORD = 'data_analyst-password';
const DATA_ANALYST_ROLE = 'data_analyst_role';
const DATA_ANALYST_USERNAME = 'data_analyst';
const REPORTING_ROLE = 'reporting_user_role';
const REPORTING_USER_PASSWORD = 'reporting_user-password';
const REPORTING_USER_USERNAME = 'reporting_user';

Copy link
Member

Choose a reason for hiding this comment

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

@rshen91 in serverless tests, for the foreseeable future, it looks like we won't be able to run tests that use custom roles or users. It looks like we need to rely on just the elastic_serverless user: that's the user that it automatically logged in the beginning of every functional test.

I'm not sure how we can test that users can only see their own reports, but that ability might come later to the serverless tests configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok I removed the parts of the tests that might not be needed for now in 26e9f53

/**
* Services to create roles and users for security testing
*/
export function SvlReportingServiceProvider({ getService }: FtrProviderContext) {
const security = getService('security');
const log = getService('log');
const supertest = getService('supertestWithoutAuth');
const retry = getService('retry');
const config = getService('config');

return {
DATA_ANALYST_PASSWORD,
DATA_ANALYST_USERNAME,
REPORTING_USER_PASSWORD,
REPORTING_USER_USERNAME,

/**
* Define a role that DOES NOT grant privileges to create any type of report.
*/
async createDataAnalystRole() {
await security.role.create(DATA_ANALYST_ROLE, {
metadata: {},
elasticsearch: {
cluster: [],
indices: [
{
names: ['ecommerce'],
privileges: ['read', 'view_index_metadata'],
allow_restricted_indices: false,
},
],
run_as: [],
},
kibana: [
{
base: ['read'],
feature: {},
spaces: ['*'],
},
],
});
},

async createDataAnalystUser() {
await security.user.create(DATA_ANALYST_USERNAME, {
password: DATA_ANALYST_PASSWORD,
roles: [DATA_ANALYST_ROLE],
full_name: 'Data Analyst User',
});
},

/**
* Define a role that DOES grant privileges to create certain types of reports.
*/
async createReportingRole() {
await security.role.create(REPORTING_ROLE, {
metadata: {},
elasticsearch: {
cluster: [],
indices: [
{
names: ['ecommerce'],
privileges: ['read', 'view_index_metadata'],
allow_restricted_indices: false,
},
],
run_as: [],
},
kibana: [
{
base: [],
feature: { discover: ['minimal_read', 'generate_report'] },
spaces: ['*'],
},
],
});
},

async createReportingUser(
username = REPORTING_USER_USERNAME,
password = REPORTING_USER_PASSWORD
) {
await security.user.create(username, {
password,
roles: [REPORTING_ROLE],
full_name: 'Reporting User',
});
},

/**
* Use the internal API to create any kind of report job
*/
async createReportJobInternal(
jobType: string,
job: object,
username: string,
password: string
) {
const requestPath = `${INTERNAL_ROUTES.GENERATE_PREFIX}/${jobType}`;
log.debug(`POST request to ${requestPath}`);

const { status, body } = await supertest
.post(requestPath)
.auth(username, password)
.set(...API_HEADER)
.set(...INTERNAL_HEADER)
.send({ jobParams: rison.encode(job) });

expect(status).to.be(200);

return {
job: (body as ReportingJobResponse).job,
path: (body as ReportingJobResponse).path,
};
},

async waitForJobToFinish(
tsullivan marked this conversation as resolved.
Show resolved Hide resolved
downloadReportPath: string,
username: string,
password: string,
options?: { timeout?: number }
) {
await retry.waitForWithTimeout(
`job ${downloadReportPath} finished`,
options?.timeout ?? config.get('timeouts.kibanaReportCompletion'),
async () => {
const response = await supertest
.get(`${downloadReportPath}?elasticInternalOrigin=true`)
.auth(username, password)
.responseType('blob')
.set(...API_HEADER)
.set(...INTERNAL_HEADER);

if (response.status === 503) {
log.debug(`Report at path ${downloadReportPath} is pending`);
return false;
}

log.debug(`Report at path ${downloadReportPath} returned code ${response.status}`);

if (response.status === 200) {
log.debug(`Report at path ${downloadReportPath} is complete`);
return true;
}

throw new Error(`unexpected status code ${response.status}`);
}
);
},

async getCompletedJobOutput(downloadReportPath: string, username: string, password: string) {
tsullivan marked this conversation as resolved.
Show resolved Hide resolved
const response = await supertest
.get(`${downloadReportPath}?elasticInternalOrigin=true`)
.auth(username, password);
return response.text as unknown;
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./index_management'));
loadTestFile(require.resolve('./alerting'));
loadTestFile(require.resolve('./ingest_pipelines'));
loadTestFile(require.resolve('./reporting'));
});
}
Loading