Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6f1a0e2
Merge remote-tracking branch 'upstream/master' into lens/formula-erro…
flash1293 Feb 9, 2021
527ef37
Merge branch 'lens/formula-error-handling' of github.com:dej611/kiban…
flash1293 Feb 10, 2021
f5602ac
Merge remote-tracking branch 'upstream/master' into lens/formula-erro…
flash1293 Feb 10, 2021
bd87d98
refactoring
flash1293 May 10, 2021
571501a
move main column generation into parse module
flash1293 May 10, 2021
70a6b86
fix tests
flash1293 May 10, 2021
40c43e4
documentation
flash1293 May 10, 2021
557b3a8
Merge branch 'lens/formula-error-handling' into formula-documentation
flash1293 May 12, 2021
51a8f62
Merge remote-tracking branch 'wylieconlon/lens/formula-error-handling…
flash1293 May 12, 2021
614b357
Merge remote-tracking branch 'MichaelMarcialis/lens/formula-error-han…
flash1293 May 12, 2021
091ca43
[App Search] Meta engines schema view (#100087)
constancecchen May 14, 2021
ca2930c
[status_page test] use navigateToApp (#100146)
dmlemeshko May 14, 2021
bfe08d2
[Security Solutions] Removes deprecation and more copied code between…
FrankHassanabad May 14, 2021
ea8c92b
[App Search] Allow user to manage source engines through Kibana UX (#…
byronhulcher May 15, 2021
5e410f5
[Uptime] [Synthetics Integration] update tls passphrase and http pass…
dominiqueclarke May 16, 2021
d8a2f8f
Improve migration perf (#99773)
mshustov May 17, 2021
a85d91c
Merge remote-tracking branch 'wylieconlon/lens/formula-error-handling…
flash1293 May 17, 2021
5c97610
Merge remote-tracking branch 'upstream/master' into formula-documenta…
flash1293 May 17, 2021
507dd53
fix stuff
flash1293 May 17, 2021
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
2 changes: 0 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@
/packages/kbn-legacy-logging/ @elastic/kibana-core
/packages/kbn-crypto/ @elastic/kibana-core
/packages/kbn-http-tools/ @elastic/kibana-core
/src/plugins/status_page/ @elastic/kibana-core
/src/plugins/saved_objects_management/ @elastic/kibana-core
/src/dev/run_check_published_api_changes.ts @elastic/kibana-core
/src/plugins/home/public @elastic/kibana-core
Expand All @@ -215,7 +214,6 @@
#CC# /src/plugins/legacy_export/ @elastic/kibana-core
#CC# /src/plugins/xpack_legacy/ @elastic/kibana-core
#CC# /src/plugins/saved_objects/ @elastic/kibana-core
#CC# /src/plugins/status_page/ @elastic/kibana-core
#CC# /x-pack/plugins/cloud/ @elastic/kibana-core
#CC# /x-pack/plugins/features/ @elastic/kibana-core
#CC# /x-pack/plugins/global_search/ @elastic/kibana-core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The version in which this object type is being converted to a multi-namespace ty
<b>Signature:</b>

```typescript
convertToMultiNamespaceTypeVersion?: string;
readonly convertToMultiNamespaceTypeVersion?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ logger instance to be used by the migration handler
<b>Signature:</b>

```typescript
log: SavedObjectsMigrationLogger;
readonly log: SavedObjectsMigrationLogger;
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The migration version that this migration function is defined for
<b>Signature:</b>

```typescript
migrationVersion: string;
readonly migrationVersion: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,14 @@ function wrapWithTry(
migrationFn: SavedObjectMigrationFn,
log: Logger
) {
const context = Object.freeze({
log: new MigrationLogger(log),
migrationVersion: version,
convertToMultiNamespaceTypeVersion: type.convertToMultiNamespaceTypeVersion,
});

return function tryTransformDoc(doc: SavedObjectUnsanitizedDoc) {
try {
const context = {
log: new MigrationLogger(log),
migrationVersion: version,
convertToMultiNamespaceTypeVersion: type.convertToMultiNamespaceTypeVersion,
};
const result = migrationFn(doc, context);

// A basic sanity check to help migration authors detect basic errors
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/saved_objects/migrations/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ export interface SavedObjectMigrationContext {
/**
* logger instance to be used by the migration handler
*/
log: SavedObjectsMigrationLogger;
readonly log: SavedObjectsMigrationLogger;
/**
* The migration version that this migration function is defined for
*/
migrationVersion: string;
readonly migrationVersion: string;
/**
* The version in which this object type is being converted to a multi-namespace type
*/
convertToMultiNamespaceTypeVersion?: string;
readonly convertToMultiNamespaceTypeVersion?: string;
}

/**
Expand Down
25 changes: 25 additions & 0 deletions src/core/server/saved_objects/migrationsv2/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,31 @@ describe('migrations v2 model', () => {
});

describe('model transitions from', () => {
it('transition returns new state', () => {
const initState: State = {
...baseState,
controlState: 'INIT',
currentAlias: '.kibana',
versionAlias: '.kibana_7.11.0',
versionIndex: '.kibana_7.11.0_001',
};

const res: ResponseType<'INIT'> = Either.right({
'.kibana_7.11.0_001': {
aliases: {
'.kibana': {},
'.kibana_7.11.0': {},
},
mappings: {
properties: {},
},
settings: {},
},
});
const newState = model(initState, res);
expect(newState).not.toBe(initState);
});

describe('INIT', () => {
const initState: State = {
...baseState,
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/migrationsv2/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { gt, valid } from 'semver';
import * as Either from 'fp-ts/lib/Either';
import * as Option from 'fp-ts/lib/Option';
import { cloneDeep } from 'lodash';

import { AliasAction, FetchIndexResponse, isLeftTypeof, RetryableEsClientError } from './actions';
import { AllActionStates, InitState, State } from './types';
import { IndexMapping } from '../mappings';
Expand Down Expand Up @@ -187,7 +187,7 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
// control state using:
// `const res = resW as ResponseType<typeof stateP.controlState>;`

let stateP: State = cloneDeep(currentState);
let stateP: State = currentState;

// Handle retryable_es_client_errors. Other left values need to be handled
// by the control state specific code below.
Expand Down
5 changes: 3 additions & 2 deletions src/core/server/saved_objects/migrationsv2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export interface LegacyDeleteState extends LegacyBaseState {
readonly controlState: 'LEGACY_DELETE';
}

export type State =
export type State = Readonly<
| FatalState
| InitState
| DoneState
Expand Down Expand Up @@ -411,7 +411,8 @@ export type State =
| LegacySetWriteBlockState
| LegacyReindexState
| LegacyReindexWaitForTaskState
| LegacyDeleteState;
| LegacyDeleteState
>;

export type AllControlStates = State['controlState'];
/**
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2152,9 +2152,9 @@ export interface SavedObjectExportBaseOptions {

// @public
export interface SavedObjectMigrationContext {
convertToMultiNamespaceTypeVersion?: string;
log: SavedObjectsMigrationLogger;
migrationVersion: string;
readonly convertToMultiNamespaceTypeVersion?: string;
readonly log: SavedObjectsMigrationLogger;
readonly migrationVersion: string;
}

// @public
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/dashboard/common/saved_dashboard_references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import semverSatisfies from 'semver/functions/satisfies';
import Semver from 'semver';
import { SavedObjectAttributes, SavedObjectReference } from '../../../core/types';
import { DashboardContainerStateWithType, DashboardPanelState } from './types';
import { EmbeddablePersistableStateService } from '../../embeddable/common/types';
Expand All @@ -24,7 +23,7 @@ export interface SavedObjectAttributesAndReferences {
}

const isPre730Panel = (panel: Record<string, string>): boolean => {
return 'version' in panel ? semverSatisfies(panel.version, '<7.3') : true;
return 'version' in panel ? Semver.gt('7.3.0', panel.version) : true;
};

function dashboardAttributesToState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*/

export { mockEngineValues, mockEngineActions } from './engine_logic.mock';
export { mockRecursivelyFetchEngines, mockSourceEngines } from './recursively_fetch_engines.mock';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 { EngineDetails } from '../components/engine/types';

export const mockSourceEngines = [
{ name: 'source-engine-1' },
{ name: 'source-engine-2' },
] as EngineDetails[];

export const mockRecursivelyFetchEngines = jest.fn(({ onComplete }) =>
onComplete(mockSourceEngines)
);

jest.mock('../utils/recursively_fetch_engines', () => ({
recursivelyFetchEngines: mockRecursivelyFetchEngines,
}));
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
* 2.0.
*/

import { LogicMounter, mockFlashMessageHelpers, mockHttpValues } from '../../../../../__mocks__';

import { nextTick } from '@kbn/test/jest';
import { LogicMounter } from '../../../../../__mocks__';
import { mockRecursivelyFetchEngines } from '../../../../__mocks__/recursively_fetch_engines.mock';

import { EngineDetails } from '../../../engine/types';

import { MetaEnginesTableLogic } from './meta_engines_table_logic';

describe('MetaEnginesTableLogic', () => {
const { mount } = new LogicMounter(MetaEnginesTableLogic);

const DEFAULT_VALUES = {
expandedRows: {},
sourceEngines: {},
Expand Down Expand Up @@ -44,15 +45,11 @@ describe('MetaEnginesTableLogic', () => {
metaEngines: [...SOURCE_ENGINES, ...META_ENGINES] as EngineDetails[],
};

const { http } = mockHttpValues;
const { mount } = new LogicMounter(MetaEnginesTableLogic);
const { flashAPIErrors } = mockFlashMessageHelpers;

beforeEach(() => {
jest.clearAllMocks();
});

it('has expected default values', async () => {
it('has expected default values', () => {
mount({}, DEFAULT_PROPS);
expect(MetaEnginesTableLogic.values).toEqual(DEFAULT_VALUES);
});
Expand Down Expand Up @@ -122,16 +119,6 @@ describe('MetaEnginesTableLogic', () => {
});

it('calls fetchSourceEngines when it needs to fetch data for the itemId', () => {
http.get.mockReturnValueOnce(
Promise.resolve({
meta: {
page: {
total_pages: 1,
},
},
results: [{ name: 'source-engine-1' }, { name: 'source-engine-2' }],
})
);
mount();
jest.spyOn(MetaEnginesTableLogic.actions, 'fetchSourceEngines');

Expand All @@ -142,88 +129,22 @@ describe('MetaEnginesTableLogic', () => {
});

describe('fetchSourceEngines', () => {
it('calls addSourceEngines and displayRow when it has retrieved all pages', async () => {
it('calls addSourceEngines and displayRow when it has retrieved all pages', () => {
mount();
http.get.mockReturnValueOnce(
Promise.resolve({
meta: {
page: {
total_pages: 1,
},
},
results: [{ name: 'source-engine-1' }, { name: 'source-engine-2' }],
})
);
jest.spyOn(MetaEnginesTableLogic.actions, 'displayRow');
jest.spyOn(MetaEnginesTableLogic.actions, 'addSourceEngines');

MetaEnginesTableLogic.actions.fetchSourceEngines('test-engine-1');
await nextTick();

expect(http.get).toHaveBeenCalledWith(
'/api/app_search/engines/test-engine-1/source_engines',
{
query: {
'page[current]': 1,
'page[size]': 25,
},
}
);
expect(MetaEnginesTableLogic.actions.addSourceEngines).toHaveBeenCalledWith({
'test-engine-1': [{ name: 'source-engine-1' }, { name: 'source-engine-2' }],
});
expect(MetaEnginesTableLogic.actions.displayRow).toHaveBeenCalledWith('test-engine-1');
});

it('display a flash message on error', async () => {
http.get.mockReturnValueOnce(Promise.reject());
mount();

MetaEnginesTableLogic.actions.fetchSourceEngines('test-engine-1');
await nextTick();

expect(flashAPIErrors).toHaveBeenCalledTimes(1);
});

it('recursively fetches a number of pages', async () => {
mount();
jest.spyOn(MetaEnginesTableLogic.actions, 'addSourceEngines');

// First page
http.get.mockReturnValueOnce(
Promise.resolve({
meta: {
page: {
total_pages: 2,
},
},
results: [{ name: 'source-engine-1' }],
})
);

// Second and final page
http.get.mockReturnValueOnce(
Promise.resolve({
meta: {
page: {
total_pages: 2,
},
},
results: [{ name: 'source-engine-2' }],
expect(mockRecursivelyFetchEngines).toHaveBeenCalledWith(
expect.objectContaining({
endpoint: '/api/app_search/engines/test-engine-1/source_engines',
})
);

MetaEnginesTableLogic.actions.fetchSourceEngines('test-engine-1');
await nextTick();

expect(MetaEnginesTableLogic.actions.addSourceEngines).toHaveBeenCalledWith({
'test-engine-1': [
// First page
{ name: 'source-engine-1' },
// Second and final page
{ name: 'source-engine-2' },
],
'test-engine-1': [{ name: 'source-engine-1' }, { name: 'source-engine-2' }],
});
expect(MetaEnginesTableLogic.actions.displayRow).toHaveBeenCalledWith('test-engine-1');
});
});
});
Expand Down
Loading