Skip to content

Commit

Permalink
Merge branch 'lens/drag_n_drop_for_xy' of https://github.com/mbondyra…
Browse files Browse the repository at this point in the history
…/kibana into lens/drag_n_drop_for_xy
  • Loading branch information
mbondyra committed Dec 2, 2020
2 parents a5eaaff + 5284ca5 commit 0d13d11
Show file tree
Hide file tree
Showing 77 changed files with 1,971 additions and 580 deletions.
6 changes: 4 additions & 2 deletions docs/api/saved-objects/create.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ experimental[] Create {kib} saved objects.
[[saved-objects-api-create-request]]
==== Request

`POST <kibana host>:<port>/api/saved_objects/<type>` +
`POST <kibana host>:<port>/api/saved_objects/<type>`

`POST <kibana host>:<port>/api/saved_objects/<type>/<id>`

`POST <kibana host>:<port>/s/<space_id>/saved_objects/<type>`
`POST <kibana host>:<port>/s/<space_id>/api/saved_objects/<type>`

`POST <kibana host>:<port>/s/<space_id>/api/saved_objects/<type>/<id>`

[[saved-objects-api-create-path-params]]
==== Path parameters
Expand Down
9 changes: 5 additions & 4 deletions packages/kbn-babel-preset/common_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ const plugins = [
// See https://github.com/babel/proposals/issues/12 for progress
require.resolve('@babel/plugin-proposal-class-properties'),

// Optional Chaining proposal is stage 3 (https://github.com/tc39/proposal-optional-chaining)
// Optional Chaining proposal is stage 4 (https://github.com/tc39/proposal-optional-chaining)
// Need this since we are using TypeScript 3.7+
require.resolve('@babel/plugin-proposal-optional-chaining'),
// Nullish coalescing proposal is stage 3 (https://github.com/tc39/proposal-nullish-coalescing)

// Nullish coalescing proposal is stage 4 (https://github.com/tc39/proposal-nullish-coalescing)
// Need this since we are using TypeScript 3.7+
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),

// Proposal is on stage 4 (https://github.com/tc39/proposal-export-ns-from)
// Proposal is on stage 4, and included in ECMA-262 (https://github.com/tc39/proposal-export-ns-from)
// Need this since we are using TypeScript 3.8+
require.resolve('@babel/plugin-proposal-export-namespace-from'),

// Proposal is on stage 4 (https://github.com/tc39/proposal-export-ns-from)
// Proposal is on stage 4, and included in ECMA-262 (https://github.com/tc39/proposal-export-ns-from)
// Need this since we are using TypeScript 3.9+
require.resolve('@babel/plugin-proposal-private-methods'),
];
Expand Down
8 changes: 5 additions & 3 deletions test/api_integration/apis/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ function getLogMock() {
export default ({ getService }: FtrProviderContext) => {
const esClient = getService('es');

// FLAKY: https://github.com/elastic/kibana/issues/84445
describe.skip('Kibana index migration', () => {
describe('Kibana index migration', () => {
before(() => esClient.indices.delete({ index: '.migrate-*' }));

it('Migrates an existing index that has never been migrated before', async () => {
Expand Down Expand Up @@ -313,7 +312,10 @@ export default ({ getService }: FtrProviderContext) => {
result
// @ts-expect-error destIndex exists only on MigrationResult status: 'migrated';
.map(({ status, destIndex }) => ({ status, destIndex }))
.sort((a) => (a.destIndex ? 0 : 1))
.sort(({ destIndex: a }, { destIndex: b }) =>
// sort by destIndex in ascending order, keeping falsy values at the end
(a && !b) || a < b ? -1 : (!a && b) || a > b ? 1 : 0
)
).to.eql([
{ status: 'migrated', destIndex: '.migration-c_2' },
{ status: 'skipped', destIndex: undefined },
Expand Down
3 changes: 1 addition & 2 deletions test/functional/apps/discover/_doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
defaultIndex: 'logstash-*',
};

// Failing: See https://github.com/elastic/kibana/issues/82445
describe.skip('discover doc table', function describeIndexTests() {
describe('discover doc table', function describeIndexTests() {
const defaultRowsLimit = 50;
const rowsHardLimit = 500;

Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/alerts/common/builtin_action_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import { i18n } from '@kbn/i18n';
import { ActionGroup } from './alert_type';

export const RecoveredActionGroup: ActionGroup = {
id: 'recovered',
name: i18n.translate('xpack.alerts.builtinActionGroups.recovered', {
defaultMessage: 'Recovered',
export const ResolvedActionGroup: ActionGroup = {
id: 'resolved',
name: i18n.translate('xpack.alerts.builtinActionGroups.resolved', {
defaultMessage: 'Resolved',
}),
};

export function getBuiltinActionGroups(): ActionGroup[] {
return [RecoveredActionGroup];
return [ResolvedActionGroup];
}
14 changes: 7 additions & 7 deletions x-pack/plugins/alerts/server/alert_type_registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ describe('register()', () => {
name: 'Default',
},
{
id: 'recovered',
name: 'Recovered',
id: 'resolved',
name: 'Resolved',
},
],
defaultActionGroupId: 'default',
Expand All @@ -117,7 +117,7 @@ describe('register()', () => {

expect(() => registry.register(alertType)).toThrowError(
new Error(
`Alert type [id="${alertType.id}"] cannot be registered. Action groups [recovered] are reserved by the framework.`
`Alert type [id="${alertType.id}"] cannot be registered. Action groups [resolved] are reserved by the framework.`
)
);
});
Expand Down Expand Up @@ -229,8 +229,8 @@ describe('get()', () => {
"name": "Default",
},
Object {
"id": "recovered",
"name": "Recovered",
"id": "resolved",
"name": "Resolved",
},
],
"actionVariables": Object {
Expand Down Expand Up @@ -287,8 +287,8 @@ describe('list()', () => {
"name": "Test Action Group",
},
Object {
"id": "recovered",
"name": "Recovered",
"id": "resolved",
"name": "Resolved",
},
],
"actionVariables": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('getAlertInstanceSummary()', () => {
.addActiveInstance('instance-previously-active', 'action group B')
.advanceTime(10000)
.addExecute()
.addRecoveredInstance('instance-previously-active')
.addResolvedInstance('instance-previously-active')
.addActiveInstance('instance-currently-active', 'action group A')
.getEvents();
const eventsResult = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { SanitizedAlert, AlertInstanceSummary } from '../types';
import { IValidatedEvent } from '../../../event_log/server';
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER, LEGACY_EVENT_LOG_ACTIONS } from '../plugin';
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER } from '../plugin';
import { alertInstanceSummaryFromEventLog } from './alert_instance_summary_from_event_log';

const ONE_HOUR_IN_MILLIS = 60 * 60 * 1000;
Expand Down Expand Up @@ -189,43 +189,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
.addActiveInstance('instance-1', 'action group A')
.advanceTime(10000)
.addExecute()
.addRecoveredInstance('instance-1')
.getEvents();

const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
alert,
events,
dateStart,
dateEnd,
});

const { lastRun, status, instances } = summary;
expect({ lastRun, status, instances }).toMatchInlineSnapshot(`
Object {
"instances": Object {
"instance-1": Object {
"actionGroupId": undefined,
"activeStartDate": undefined,
"muted": false,
"status": "OK",
},
},
"lastRun": "2020-06-18T00:00:10.000Z",
"status": "OK",
}
`);
});

test('legacy alert with currently inactive instance', async () => {
const alert = createAlert({});
const eventsFactory = new EventsFactory();
const events = eventsFactory
.addExecute()
.addNewInstance('instance-1')
.addActiveInstance('instance-1', 'action group A')
.advanceTime(10000)
.addExecute()
.addLegacyResolvedInstance('instance-1')
.addResolvedInstance('instance-1')
.getEvents();

const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
Expand Down Expand Up @@ -260,7 +224,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
.addActiveInstance('instance-1', 'action group A')
.advanceTime(10000)
.addExecute()
.addRecoveredInstance('instance-1')
.addResolvedInstance('instance-1')
.getEvents();

const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
Expand Down Expand Up @@ -442,7 +406,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
.advanceTime(10000)
.addExecute()
.addActiveInstance('instance-1', 'action group A')
.addRecoveredInstance('instance-2')
.addResolvedInstance('instance-2')
.getEvents();

const summary: AlertInstanceSummary = alertInstanceSummaryFromEventLog({
Expand Down Expand Up @@ -487,7 +451,7 @@ describe('alertInstanceSummaryFromEventLog', () => {
.advanceTime(10000)
.addExecute()
.addActiveInstance('instance-1', 'action group A')
.addRecoveredInstance('instance-2')
.addResolvedInstance('instance-2')
.advanceTime(10000)
.addExecute()
.addActiveInstance('instance-1', 'action group B')
Expand Down Expand Up @@ -597,24 +561,12 @@ export class EventsFactory {
return this;
}

addRecoveredInstance(instanceId: string): EventsFactory {
this.events.push({
'@timestamp': this.date,
event: {
provider: EVENT_LOG_PROVIDER,
action: EVENT_LOG_ACTIONS.recoveredInstance,
},
kibana: { alerting: { instance_id: instanceId } },
});
return this;
}

addLegacyResolvedInstance(instanceId: string): EventsFactory {
addResolvedInstance(instanceId: string): EventsFactory {
this.events.push({
'@timestamp': this.date,
event: {
provider: EVENT_LOG_PROVIDER,
action: LEGACY_EVENT_LOG_ACTIONS.resolvedInstance,
action: EVENT_LOG_ACTIONS.resolvedInstance,
},
kibana: { alerting: { instance_id: instanceId } },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { SanitizedAlert, AlertInstanceSummary, AlertInstanceStatus } from '../types';
import { IEvent } from '../../../event_log/server';
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER, LEGACY_EVENT_LOG_ACTIONS } from '../plugin';
import { EVENT_LOG_ACTIONS, EVENT_LOG_PROVIDER } from '../plugin';

export interface AlertInstanceSummaryFromEventLogParams {
alert: SanitizedAlert;
Expand Down Expand Up @@ -80,8 +80,7 @@ export function alertInstanceSummaryFromEventLog(
status.status = 'Active';
status.actionGroupId = event?.kibana?.alerting?.action_group_id;
break;
case LEGACY_EVENT_LOG_ACTIONS.resolvedInstance:
case EVENT_LOG_ACTIONS.recoveredInstance:
case EVENT_LOG_ACTIONS.resolvedInstance:
status.status = 'OK';
status.activeStartDate = undefined;
status.actionGroupId = undefined;
Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/alerts/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ export const EVENT_LOG_ACTIONS = {
execute: 'execute',
executeAction: 'execute-action',
newInstance: 'new-instance',
recoveredInstance: 'recovered-instance',
activeInstance: 'active-instance',
};
export const LEGACY_EVENT_LOG_ACTIONS = {
resolvedInstance: 'resolved-instance',
activeInstance: 'active-instance',
};

export interface PluginSetupContract {
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/alerts/server/task_runner/task_runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import { alertsMock, alertsClientMock } from '../mocks';
import { eventLoggerMock } from '../../../event_log/server/event_logger.mock';
import { IEventLogger } from '../../../event_log/server';
import { SavedObjectsErrorHelpers } from '../../../../../src/core/server';
import { Alert, RecoveredActionGroup } from '../../common';
import { Alert, ResolvedActionGroup } from '../../common';
import { omit } from 'lodash';
const alertType = {
id: 'test',
name: 'My test alert',
actionGroups: [{ id: 'default', name: 'Default' }, RecoveredActionGroup],
actionGroups: [{ id: 'default', name: 'Default' }, ResolvedActionGroup],
defaultActionGroupId: 'default',
executor: jest.fn(),
producer: 'alerts',
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Task Runner', () => {
},
},
{
group: RecoveredActionGroup.id,
group: ResolvedActionGroup.id,
id: '2',
actionTypeId: 'action',
params: {
Expand Down Expand Up @@ -517,7 +517,7 @@ describe('Task Runner', () => {
`);
});

test('fire recovered actions for execution for the alertInstances which is in the recovered state', async () => {
test('fire resolved actions for execution for the alertInstances which is in the resolved state', async () => {
taskRunnerFactoryInitializerParams.actionsPlugin.isActionTypeEnabled.mockReturnValue(true);
taskRunnerFactoryInitializerParams.actionsPlugin.isActionExecutable.mockReturnValue(true);

Expand Down Expand Up @@ -650,7 +650,7 @@ describe('Task Runner', () => {
Array [
Object {
"event": Object {
"action": "recovered-instance",
"action": "resolved-instance",
},
"kibana": Object {
"alerting": Object {
Expand All @@ -666,7 +666,7 @@ describe('Task Runner', () => {
},
],
},
"message": "test:1: 'alert-name' instance '2' has recovered",
"message": "test:1: 'alert-name' resolved instance: '2'",
},
],
Array [
Expand Down
Loading

0 comments on commit 0d13d11

Please sign in to comment.