Skip to content

Commit

Permalink
Merge branch 'master' into internal-monitoring-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Jul 22, 2020
2 parents 2c45f1c + f6bc61f commit 60daec3
Show file tree
Hide file tree
Showing 514 changed files with 22,749 additions and 4,676 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 examples/alerting_example/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["triggers_actions_ui", "charts", "data", "alerts", "actions", "developerExamples"],
"requiredPlugins": ["triggers_actions_ui", "charts", "data", "alerts", "actions", "features", "developerExamples"],
"optionalPlugins": []
}
38 changes: 37 additions & 1 deletion examples/alerting_example/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,56 @@
*/

import { Plugin, CoreSetup } from 'kibana/server';
import { i18n } from '@kbn/i18n';
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerts/server';
import { PluginSetupContract as FeaturesPluginSetup } from '../../../x-pack/plugins/features/server';

import { alertType as alwaysFiringAlert } from './alert_types/always_firing';
import { alertType as peopleInSpaceAlert } from './alert_types/astros';
import { INDEX_THRESHOLD_ID } from '../../../x-pack/plugins/alerting_builtins/server';
import { ALERTING_EXAMPLE_APP_ID } from '../common/constants';

// this plugin's dependendencies
export interface AlertingExampleDeps {
alerts: AlertingSetup;
features: FeaturesPluginSetup;
}

export class AlertingExamplePlugin implements Plugin<void, void, AlertingExampleDeps> {
public setup(core: CoreSetup, { alerts }: AlertingExampleDeps) {
public setup(core: CoreSetup, { alerts, features }: AlertingExampleDeps) {
alerts.registerType(alwaysFiringAlert);
alerts.registerType(peopleInSpaceAlert);

features.registerFeature({
id: ALERTING_EXAMPLE_APP_ID,
name: i18n.translate('alertsExample.featureRegistry.alertsExampleFeatureName', {
defaultMessage: 'Alerts Example',
}),
app: [],
alerting: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
privileges: {
all: {
alerting: {
all: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
},
savedObject: {
all: [],
read: [],
},
ui: ['alerting:show'],
},
read: {
alerting: {
read: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
},
savedObject: {
all: [],
read: [],
},
ui: ['alerting:show'],
},
},
});
}

public start() {}
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
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function ValueAxisOptions({

<LabelOptions
axisLabels={axis.labels}
axisFilterCheckboxName={`yAxisFilterLabelsCheckbox${axis.id}`}
axisFilterCheckboxName={`yAxisFilterLabelsCheckbox-${axis.id}`}
setAxisLabel={setAxisLabel}
/>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualizations/public/legacy/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = {
input_control_vis: (params) => {
return `input_control_vis ${prepareJson('visConfig', params)}`;
},
metrics: (params, schemas, uiState = {}) => {
metrics: ({ title, ...params }, schemas, uiState = {}) => {
const paramsJson = prepareJson('params', params);
const uiStateJson = prepareJson('uiState', uiState);

Expand Down
5 changes: 3 additions & 2 deletions test/functional/apps/dashboard/dashboard_filter_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export default function ({ getService, getPageObjects }) {
const browser = getService('browser');
const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'visualize', 'timePicker']);

// FLAKY: https://github.com/elastic/kibana/issues/71987
describe.skip('dashboard filter bar', () => {
describe('dashboard filter bar', () => {
before(async () => {
await esArchiver.load('dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
Expand Down Expand Up @@ -69,6 +68,7 @@ export default function ({ getService, getPageObjects }) {
it('uses default index pattern on an empty dashboard', async () => {
await testSubjects.click('addFilter');
await dashboardExpect.fieldSuggestions(['bytes']);
await filterBar.ensureFieldEditorModalIsClosed();
});

it('shows index pattern of vis when one is added', async () => {
Expand All @@ -77,6 +77,7 @@ export default function ({ getService, getPageObjects }) {
await filterBar.ensureFieldEditorModalIsClosed();
await testSubjects.click('addFilter');
await dashboardExpect.fieldSuggestions(['animal']);
await filterBar.ensureFieldEditorModalIsClosed();
});

it('works when a vis with no index pattern is added', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/functional/apps/dashboard/dashboard_snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export default function ({ getService, getPageObjects, updateBaselines }) {
const dashboardPanelActions = getService('dashboardPanelActions');
const dashboardAddPanel = getService('dashboardAddPanel');

// FLAKY: https://github.com/elastic/kibana/issues/52854
describe.skip('dashboard snapshots', function describeIndexTests() {
describe('dashboard snapshots', function describeIndexTests() {
before(async function () {
await esArchiver.load('dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
Expand Down
62 changes: 15 additions & 47 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe.skip('switch between Y axis scale types', () => {
describe('switch between Y axis scale types', () => {
before(initAreaChart);
const axisId = 'ValueAxis-1';

Expand All @@ -308,57 +308,25 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visEditor.selectYAxisScaleType(axisId, 'log');
await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, false);
await PageObjects.visEditor.clickGo();
const labels = await PageObjects.visChart.getYAxisLabels();
const expectedLabels = [
'2',
'3',
'5',
'7',
'10',
'20',
'30',
'50',
'70',
'100',
'200',
'300',
'500',
'700',
'1,000',
'2,000',
'3,000',
'5,000',
'7,000',
];
expect(labels).to.eql(expectedLabels);
const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers();
const minLabel = 2;
const maxLabel = 5000;
const numberOfLabels = 10;
expect(labels.length).to.be.greaterThan(numberOfLabels);
expect(labels[0]).to.eql(minLabel);
expect(labels[labels.length - 1]).to.be.greaterThan(maxLabel);
});

it('should show filtered ticks on selecting log scale', async () => {
await PageObjects.visEditor.changeYAxisFilterLabelsCheckbox(axisId, true);
await PageObjects.visEditor.clickGo();
const labels = await PageObjects.visChart.getYAxisLabels();
const expectedLabels = [
'2',
'3',
'5',
'7',
'10',
'20',
'30',
'50',
'70',
'100',
'200',
'300',
'500',
'700',
'1,000',
'2,000',
'3,000',
'5,000',
'7,000',
];
expect(labels).to.eql(expectedLabels);
const labels = await PageObjects.visChart.getYAxisLabelsAsNumbers();
const minLabel = 2;
const maxLabel = 5000;
const numberOfLabels = 10;
expect(labels.length).to.be.greaterThan(numberOfLabels);
expect(labels[0]).to.eql(minLabel);
expect(labels[labels.length - 1]).to.be.greaterThan(maxLabel);
});

it('should show ticks on selecting square root scale', async () => {
Expand Down
Loading

0 comments on commit 60daec3

Please sign in to comment.