Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into migrate_last_disc…
Browse files Browse the repository at this point in the history
…over_karma_tests
  • Loading branch information
VladLasitsa committed Jul 22, 2020
2 parents 15d12d6 + 47eaf60 commit 0645089
Show file tree
Hide file tree
Showing 275 changed files with 5,386 additions and 2,080 deletions.
6 changes: 6 additions & 0 deletions .ci/Jenkinsfile_baseline_trigger
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ kibanaLibrary.load()

withGithubCredentials {
branches.each { branch ->
if (branch == '6.8') {
// skip 6.8, it is tracked but we don't need snapshots for it and haven't backported
// the baseline capture scripts to it.
return;
}

stage(branch) {
def commits = getCommits(branch, MAXIMUM_COMMITS_TO_CHECK, MAXIMUM_COMMITS_TO_BUILD)

Expand Down
2 changes: 1 addition & 1 deletion .ci/end2end.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pipeline {
}
}
cleanup {
notifyBuildResult(notifyPRComment: false, analyzeFlakey: false, shouldNotify: false)
notifyBuildResult(prComment: false, analyzeFlakey: false, shouldNotify: false)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/visualize/aggregations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Bucket aggregations sort documents into buckets, depending on the contents of th
{ref}/search-aggregations-bucket-filter-aggregation.html[Filter]:: Each filter creates a bucket of documents. You can specify a filter as a
<<kuery-query, KQL>> or <<lucene-query, Lucene>> query string.

{ref}/search-aggregations-bucket-geohashgrid-aggregation.html[Geohash]:: Displays points based on a geohash. Supported by the tile map and data table visualizations.
{ref}/search-aggregations-bucket-geohashgrid-aggregation.html[Geohash]:: Displays points based on a geohash. Supported by data table visualizations and <<maps>>.

{ref}/search-aggregations-bucket-geotilegrid-aggregation.html[Geotile]:: Groups points based on web map tiling. Supported by the tile map and data table visualizations.
{ref}/search-aggregations-bucket-geotilegrid-aggregation.html[Geotile]:: Groups points based on web map tiling. Supported by data table visualizations and <<maps>>.

{ref}/search-aggregations-bucket-histogram-aggregation.html[Histogram]:: Builds from a numeric field.

Expand Down
7 changes: 6 additions & 1 deletion src/core/server/http/http_server.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ function createKibanaRequestMock<P = any, Q = any, B = any>({
settings: { tags: routeTags, auth: routeAuthRequired, app: kibanaRouteState },
},
raw: {
req: { socket },
req: {
socket,
// these are needed to avoid an error when consuming KibanaRequest.events
on: jest.fn(),
off: jest.fn(),
},
},
}),
{
Expand Down
10 changes: 8 additions & 2 deletions src/core/server/http/http_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { OnPreRoutingToolkit } from './lifecycle/on_pre_routing';
import { AuthToolkit } from './lifecycle/auth';
import { sessionStorageMock } from './cookie_session_storage.mocks';
import { OnPostAuthToolkit } from './lifecycle/on_post_auth';
import { OnPreAuthToolkit } from './lifecycle/on_pre_auth';
import { OnPreResponseToolkit } from './lifecycle/on_pre_response';

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

const createOnPreAuthToolkitMock = (): jest.Mocked<OnPreRoutingToolkit> => ({
const createOnPreAuthToolkitMock = (): jest.Mocked<OnPreAuthToolkit> => ({
next: jest.fn(),
rewriteUrl: jest.fn(),
});

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

const createOnPreRoutingToolkitMock = (): jest.Mocked<OnPreRoutingToolkit> => ({
next: jest.fn(),
rewriteUrl: jest.fn(),
});

const createAuthToolkitMock = (): jest.Mocked<AuthToolkit> => ({
authenticated: jest.fn(),
notHandled: jest.fn(),
Expand All @@ -205,6 +210,7 @@ export const httpServiceMock = {
createOnPreAuthToolkit: createOnPreAuthToolkitMock,
createOnPostAuthToolkit: createOnPostAuthToolkitMock,
createOnPreResponseToolkit: createOnPreResponseToolkitMock,
createOnPreRoutingToolkit: createOnPreRoutingToolkitMock,
createAuthToolkit: createAuthToolkitMock,
createRouter: mockRouter.create,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"abc": "123"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';
import { fetch } from '../team_assignment/get_data';
import { noop } from '../utils';

describe(`Team Assignment`, () => {
const mockPath = 'src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.json';
describe(`fetch fn`, () => {
it(`should be a fn`, () => {
expect(typeof fetch).to.be('function');
});
describe(`applied to a path that exists`, () => {
it(`should return the contents of the path`, () => {
const sut = fetch(mockPath);
expect(sut.chain(JSON.parse)).to.have.property('abc');
});
});
describe(`applied to an non-existing path`, () => {
it(`should return a Left with the error message within`, () => {
const expectLeft = (err) =>
expect(err.message).to.contain('ENOENT: no such file or directory');

fetch('fake_path.json').fold(expectLeft, noop);
});
});
});
});
2 changes: 1 addition & 1 deletion src/dev/code_coverage/ingest_coverage/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export const TEAM_ASSIGNMENT_PIPELINE_NAME = process.env.PIPELINE_NAME || 'team_
export const CODE_COVERAGE_CI_JOB_NAME = 'elastic+kibana+code-coverage';
export const RESEARCH_CI_JOB_NAME = 'elastic+kibana+qa-research';
export const CI_JOB_NAME = process.env.COVERAGE_JOB_NAME || RESEARCH_CI_JOB_NAME;
export const RESEARCH_CLUSTER_ES_HOST = process.env.ES_HOST || 'http://localhost:9200';
export const ES_HOST = process.env.ES_HOST || 'http://localhost:9200';
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

import { readFileSync } from 'fs';
import { resolve } from 'path';
import { fromNullable } from '../either';
import { tryCatch as tc } from '../either';

const ROOT = resolve(__dirname, '../../../../..');

const resolveFromRoot = resolve.bind(null, ROOT);
const path = `
src/dev/code_coverage/ingest_coverage/team_assignment/ingestion_pipeline_painless.json`;
const resolved = resolveFromRoot(path.trimStart());
const getContents = (scriptPath) => readFileSync(scriptPath, 'utf8');

export const fetch = () => fromNullable(resolved).map(getContents);
const resolved = (path) => () => resolveFromRoot(path);

const getContents = (path) => tc(() => readFileSync(path, 'utf8'));

// fetch :: String -> Left | Right
export const fetch = (path) => tc(resolved(path)).chain(getContents);
32 changes: 21 additions & 11 deletions src/dev/code_coverage/ingest_coverage/team_assignment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,39 @@
import { run } from '@kbn/dev-utils';
import { TEAM_ASSIGNMENT_PIPELINE_NAME } from '../constants';
import { fetch } from './get_data';
import { noop } from '../utils';
import { update } from './update_ingest_pipeline';

export const uploadTeamAssignmentJson = () => run(execute, { description });

const updatePipeline = update(TEAM_ASSIGNMENT_PIPELINE_NAME);

function execute({ flags, log }) {
const execute = ({ flags, log }) => {
if (flags.verbose) log.verbose(`### Verbose logging enabled`);

fetch().fold(noop, updatePipeline(log));
const logLeft = handleErr(log);
const updateAndLog = updatePipeline(log);

const { path } = flags;

fetch(path).fold(logLeft, updateAndLog);
};

function handleErr(log) {
return (msg) => log.error(msg);
}

function description() {
return `
const description = `
Upload the latest team assignment pipeline def from src,
to the cluster.
`;

Examples:
const flags = {
string: ['path', 'verbose'],
help: `
--path Required, path to painless definition for team assignment.
`,
};

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

`;
}
export const uploadTeamAssignmentJson = () => run(execute, { description, flags, usage });
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

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

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

const node = RESEARCH_CLUSTER_ES_HOST;
const node = ES_HOST;
const client = new Client({ node });

export const update = (id) => (log) => async (body) => {
Expand Down
2 changes: 1 addition & 1 deletion src/dev/code_coverage/shell_scripts/assign_teams.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export PIPELINE_NAME
ES_HOST="https://${USER_FROM_VAULT}:${PASS_FROM_VAULT}@${HOST_FROM_VAULT}"
export ES_HOST

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

echo "### Code Coverage Team Assignment - Complete"
echo ""
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,31 @@ import { IIndexPattern } from '../..';

describe('SearchSource#normalizeSortRequest', function () {
const scriptedField = {
name: 'script string',
name: 'script number',
type: 'number',
scripted: true,
sortable: true,
script: 'foo',
lang: 'painless',
};
const stringScriptedField = {
...scriptedField,
name: 'script string',
type: 'string',
};
const booleanScriptedField = {
...scriptedField,
name: 'script boolean',
type: 'boolean',
};
const murmurScriptedField = {
...scriptedField,
sortable: false,
name: 'murmur script',
type: 'murmur3',
};
const indexPattern = {
fields: [scriptedField, murmurScriptedField],
fields: [scriptedField, stringScriptedField, booleanScriptedField, murmurScriptedField],
} as IIndexPattern;

it('should return an array', function () {
Expand Down Expand Up @@ -106,6 +116,54 @@ describe('SearchSource#normalizeSortRequest', function () {
]);
});

it('should use script based sorting with string type', function () {
const result = normalizeSortRequest(
[
{
[stringScriptedField.name]: SortDirection.asc,
},
],
indexPattern
);

expect(result).toEqual([
{
_script: {
script: {
source: stringScriptedField.script,
lang: stringScriptedField.lang,
},
type: 'string',
order: SortDirection.asc,
},
},
]);
});

it('should use script based sorting with boolean type as string type', function () {
const result = normalizeSortRequest(
[
{
[booleanScriptedField.name]: SortDirection.asc,
},
],
indexPattern
);

expect(result).toEqual([
{
_script: {
script: {
source: booleanScriptedField.script,
lang: booleanScriptedField.lang,
},
type: 'string',
order: SortDirection.asc,
},
},
]);
});

it('should use script based sorting only on sortable types', function () {
const result = normalizeSortRequest(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function normalize(

// The ES API only supports sort scripts of type 'number' and 'string'
function castSortType(type: string) {
if (['number', 'string'].includes(type)) {
if (['number'].includes(type)) {
return 'number';
} else if (['string', 'boolean'].includes(type)) {
return 'string';
Expand Down
1 change: 1 addition & 0 deletions src/plugins/dev_tools/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export function renderApp(
});

return () => {
chrome.docTitle.reset();
ReactDOM.unmountComponentAtNode(element);
unlisten();
};
Expand Down
Loading

0 comments on commit 0645089

Please sign in to comment.