Skip to content

Commit 6bfd2c5

Browse files
Merge branch 'master' into lens/legend-config
2 parents 7f98197 + 47eaf60 commit 6bfd2c5

File tree

256 files changed

+5156
-2035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+5156
-2035
lines changed

.ci/Jenkinsfile_baseline_trigger

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ kibanaLibrary.load()
1616

1717
withGithubCredentials {
1818
branches.each { branch ->
19+
if (branch == '6.8') {
20+
// skip 6.8, it is tracked but we don't need snapshots for it and haven't backported
21+
// the baseline capture scripts to it.
22+
return;
23+
}
24+
1925
stage(branch) {
2026
def commits = getCommits(branch, MAXIMUM_COMMITS_TO_CHECK, MAXIMUM_COMMITS_TO_BUILD)
2127

src/core/server/http/http_server.mocks.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ function createKibanaRequestMock<P = any, Q = any, B = any>({
8989
settings: { tags: routeTags, auth: routeAuthRequired, app: kibanaRouteState },
9090
},
9191
raw: {
92-
req: { socket },
92+
req: {
93+
socket,
94+
// these are needed to avoid an error when consuming KibanaRequest.events
95+
on: jest.fn(),
96+
off: jest.fn(),
97+
},
9398
},
9499
}),
95100
{

src/core/server/http/http_service.mock.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { OnPreRoutingToolkit } from './lifecycle/on_pre_routing';
3333
import { AuthToolkit } from './lifecycle/auth';
3434
import { sessionStorageMock } from './cookie_session_storage.mocks';
3535
import { OnPostAuthToolkit } from './lifecycle/on_post_auth';
36+
import { OnPreAuthToolkit } from './lifecycle/on_pre_auth';
3637
import { OnPreResponseToolkit } from './lifecycle/on_pre_response';
3738

3839
type BasePathMocked = jest.Mocked<InternalHttpServiceSetup['basePath']>;
@@ -175,15 +176,19 @@ const createHttpServiceMock = () => {
175176
return mocked;
176177
};
177178

178-
const createOnPreAuthToolkitMock = (): jest.Mocked<OnPreRoutingToolkit> => ({
179+
const createOnPreAuthToolkitMock = (): jest.Mocked<OnPreAuthToolkit> => ({
179180
next: jest.fn(),
180-
rewriteUrl: jest.fn(),
181181
});
182182

183183
const createOnPostAuthToolkitMock = (): jest.Mocked<OnPostAuthToolkit> => ({
184184
next: jest.fn(),
185185
});
186186

187+
const createOnPreRoutingToolkitMock = (): jest.Mocked<OnPreRoutingToolkit> => ({
188+
next: jest.fn(),
189+
rewriteUrl: jest.fn(),
190+
});
191+
187192
const createAuthToolkitMock = (): jest.Mocked<AuthToolkit> => ({
188193
authenticated: jest.fn(),
189194
notHandled: jest.fn(),
@@ -205,6 +210,7 @@ export const httpServiceMock = {
205210
createOnPreAuthToolkit: createOnPreAuthToolkitMock,
206211
createOnPostAuthToolkit: createOnPostAuthToolkitMock,
207212
createOnPreResponseToolkit: createOnPreResponseToolkitMock,
213+
createOnPreRoutingToolkit: createOnPreRoutingToolkitMock,
208214
createAuthToolkit: createAuthToolkitMock,
209215
createRouter: mockRouter.create,
210216
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"abc": "123"
3+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import expect from '@kbn/expect';
21+
import { fetch } from '../team_assignment/get_data';
22+
import { noop } from '../utils';
23+
24+
describe(`Team Assignment`, () => {
25+
const mockPath = 'src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.json';
26+
describe(`fetch fn`, () => {
27+
it(`should be a fn`, () => {
28+
expect(typeof fetch).to.be('function');
29+
});
30+
describe(`applied to a path that exists`, () => {
31+
it(`should return the contents of the path`, () => {
32+
const sut = fetch(mockPath);
33+
expect(sut.chain(JSON.parse)).to.have.property('abc');
34+
});
35+
});
36+
describe(`applied to an non-existing path`, () => {
37+
it(`should return a Left with the error message within`, () => {
38+
const expectLeft = (err) =>
39+
expect(err.message).to.contain('ENOENT: no such file or directory');
40+
41+
fetch('fake_path.json').fold(expectLeft, noop);
42+
});
43+
});
44+
});
45+
});

src/dev/code_coverage/ingest_coverage/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ export const TEAM_ASSIGNMENT_PIPELINE_NAME = process.env.PIPELINE_NAME || 'team_
3232
export const CODE_COVERAGE_CI_JOB_NAME = 'elastic+kibana+code-coverage';
3333
export const RESEARCH_CI_JOB_NAME = 'elastic+kibana+qa-research';
3434
export const CI_JOB_NAME = process.env.COVERAGE_JOB_NAME || RESEARCH_CI_JOB_NAME;
35-
export const RESEARCH_CLUSTER_ES_HOST = process.env.ES_HOST || 'http://localhost:9200';
35+
export const ES_HOST = process.env.ES_HOST || 'http://localhost:9200';

src/dev/code_coverage/ingest_coverage/team_assignment/get_data.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919

2020
import { readFileSync } from 'fs';
2121
import { resolve } from 'path';
22-
import { fromNullable } from '../either';
22+
import { tryCatch as tc } from '../either';
2323

2424
const ROOT = resolve(__dirname, '../../../../..');
25+
2526
const resolveFromRoot = resolve.bind(null, ROOT);
26-
const path = `
27-
src/dev/code_coverage/ingest_coverage/team_assignment/ingestion_pipeline_painless.json`;
28-
const resolved = resolveFromRoot(path.trimStart());
29-
const getContents = (scriptPath) => readFileSync(scriptPath, 'utf8');
3027

31-
export const fetch = () => fromNullable(resolved).map(getContents);
28+
const resolved = (path) => () => resolveFromRoot(path);
29+
30+
const getContents = (path) => tc(() => readFileSync(path, 'utf8'));
31+
32+
// fetch :: String -> Left | Right
33+
export const fetch = (path) => tc(resolved(path)).chain(getContents);

src/dev/code_coverage/ingest_coverage/team_assignment/index.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,39 @@
2020
import { run } from '@kbn/dev-utils';
2121
import { TEAM_ASSIGNMENT_PIPELINE_NAME } from '../constants';
2222
import { fetch } from './get_data';
23-
import { noop } from '../utils';
2423
import { update } from './update_ingest_pipeline';
2524

26-
export const uploadTeamAssignmentJson = () => run(execute, { description });
27-
2825
const updatePipeline = update(TEAM_ASSIGNMENT_PIPELINE_NAME);
2926

30-
function execute({ flags, log }) {
27+
const execute = ({ flags, log }) => {
3128
if (flags.verbose) log.verbose(`### Verbose logging enabled`);
3229

33-
fetch().fold(noop, updatePipeline(log));
30+
const logLeft = handleErr(log);
31+
const updateAndLog = updatePipeline(log);
32+
33+
const { path } = flags;
34+
35+
fetch(path).fold(logLeft, updateAndLog);
36+
};
37+
38+
function handleErr(log) {
39+
return (msg) => log.error(msg);
3440
}
3541

36-
function description() {
37-
return `
42+
const description = `
3843
3944
Upload the latest team assignment pipeline def from src,
4045
to the cluster.
4146
47+
`;
4248

43-
Examples:
49+
const flags = {
50+
string: ['path', 'verbose'],
51+
help: `
52+
--path Required, path to painless definition for team assignment.
53+
`,
54+
};
4455

45-
node scripts/load_team_assignment.js --verbose
56+
const usage = 'node scripts/load_team_assignment.js --verbose --path PATH_TO_PAINLESS_SCRIPT.json';
4657

47-
`;
48-
}
58+
export const uploadTeamAssignmentJson = () => run(execute, { description, flags, usage });

src/dev/code_coverage/ingest_coverage/team_assignment/update_ingest_pipeline.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
*/
1919

2020
import { createFailError } from '@kbn/dev-utils';
21-
import { RESEARCH_CLUSTER_ES_HOST } from '../constants';
21+
import { ES_HOST } from '../constants';
2222
import { pretty, green } from '../utils';
2323

2424
const { Client } = require('@elastic/elasticsearch');
2525

26-
const node = RESEARCH_CLUSTER_ES_HOST;
26+
const node = ES_HOST;
2727
const client = new Client({ node });
2828

2929
export const update = (id) => (log) => async (body) => {

src/dev/code_coverage/shell_scripts/assign_teams.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export PIPELINE_NAME
99
ES_HOST="https://${USER_FROM_VAULT}:${PASS_FROM_VAULT}@${HOST_FROM_VAULT}"
1010
export ES_HOST
1111

12-
node scripts/load_team_assignment.js --verbose
12+
node scripts/load_team_assignment.js --verbose --path src/dev/code_coverage/ingest_coverage/team_assignment/ingestion_pipeline_painless.json
1313

1414
echo "### Code Coverage Team Assignment - Complete"
1515
echo ""

0 commit comments

Comments
 (0)