Skip to content

Commit

Permalink
Merge branch 'master' into ts-project-refs/index_pattern_management
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers committed Jan 31, 2021
2 parents 954c10d + af337ce commit 11f98f9
Show file tree
Hide file tree
Showing 424 changed files with 6,380 additions and 4,706 deletions.
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
# APM
/x-pack/plugins/apm/ @elastic/apm-ui
/x-pack/test/functional/apps/apm/ @elastic/apm-ui
/x-pack/test/apm_api_integration/ @elastic/apm-ui
/src/plugins/apm_oss/ @elastic/apm-ui
/src/apm.js @elastic/kibana-core @vigneshshanmugam
/packages/kbn-apm-config-loader/ @elastic/kibana-core @vigneshshanmugam
Expand All @@ -80,6 +81,7 @@
/x-pack/plugins/apm/server/lib/rum_client @elastic/uptime
/x-pack/plugins/apm/server/routes/rum_client.ts @elastic/uptime
/x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts @elastic/uptime
/x-pack/test/apm_api_integration/tests/csm/ @elastic/uptime

# Beats
/x-pack/plugins/beats_management/ @elastic/beats
Expand All @@ -99,7 +101,7 @@

# Observability UIs
/x-pack/plugins/infra/ @elastic/logs-metrics-ui
/x-pack/plugins/fleet/ @elastic/ingest-management
/x-pack/plugins/fleet/ @elastic/fleet
/x-pack/plugins/observability/ @elastic/observability-ui
/x-pack/plugins/monitoring/ @elastic/stack-monitoring-ui
/x-pack/plugins/uptime @elastic/uptime
Expand Down
2 changes: 1 addition & 1 deletion .github/paths-labeller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- "src/plugins/bfetch/**/*.*"
- "Team:apm":
- "x-pack/plugins/apm/**/*.*"
- "Team:Ingest Management":
- "Team:Fleet":
- "x-pack/plugins/fleet/**/*.*"
- "x-pack/test/fleet_api_integration/**/*.*"
- "Team:uptime":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<b>Signature:</b>

```typescript
protected handleSearchError(e: any, timeoutSignal: AbortSignal, options?: ISearchOptions): Error;
protected handleSearchError(e: KibanaServerError | AbortError, timeoutSignal: AbortSignal, options?: ISearchOptions): Error;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| e | <code>any</code> | |
| e | <code>KibanaServerError &#124; AbortError</code> | |
| timeoutSignal | <code>AbortSignal</code> | |
| options | <code>ISearchOptions</code> | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

## SearchSource.fetch() method

Fetch this source and reject the returned Promise on error
> Warning: This API is now obsolete.
>
> Use fetch$ instead
>
Fetch this source and reject the returned Promise on error

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [SearchSource](./kibana-plugin-plugins-data-public.searchsource.md) &gt; [fetch$](./kibana-plugin-plugins-data-public.searchsource.fetch_.md)

## SearchSource.fetch$() method

Fetch this source from Elasticsearch, returning an observable over the response(s)

<b>Signature:</b>

```typescript
fetch$(options?: ISearchOptions): import("rxjs").Observable<import("elasticsearch").SearchResponse<any>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| options | <code>ISearchOptions</code> | |

<b>Returns:</b>

`import("rxjs").Observable<import("elasticsearch").SearchResponse<any>>`

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export declare class SearchSource
| [createCopy()](./kibana-plugin-plugins-data-public.searchsource.createcopy.md) | | creates a copy of this search source (without its children) |
| [destroy()](./kibana-plugin-plugins-data-public.searchsource.destroy.md) | | Completely destroy the SearchSource. {<!-- -->undefined<!-- -->} |
| [fetch(options)](./kibana-plugin-plugins-data-public.searchsource.fetch.md) | | Fetch this source and reject the returned Promise on error |
| [fetch$(options)](./kibana-plugin-plugins-data-public.searchsource.fetch_.md) | | Fetch this source from Elasticsearch, returning an observable over the response(s) |
| [getField(field, recurse)](./kibana-plugin-plugins-data-public.searchsource.getfield.md) | | Gets a single field from the fields |
| [getFields()](./kibana-plugin-plugins-data-public.searchsource.getfields.md) | | returns all search source fields |
| [getId()](./kibana-plugin-plugins-data-public.searchsource.getid.md) | | returns search source id |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Constructs a new instance of the `SearchTimeoutError` class
<b>Signature:</b>

```typescript
constructor(err: Error, mode: TimeoutErrorMode);
constructor(err: Record<string, any>, mode: TimeoutErrorMode);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| err | <code>Error</code> | |
| err | <code>Record&lt;string, any&gt;</code> | |
| mode | <code>TimeoutErrorMode</code> | |

35 changes: 35 additions & 0 deletions packages/kbn-legacy-logging/src/setup_logging.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import { Server } from '@hapi/hapi';
import { reconfigureLogging, setupLogging } from './setup_logging';
import { LegacyLoggingConfig } from './schema';

describe('reconfigureLogging', () => {
test(`doesn't throw an error`, () => {
const server = new Server();
const config: LegacyLoggingConfig = {
silent: false,
quiet: false,
verbose: true,
events: {},
dest: '/tmp/foo',
filter: {},
json: true,
rotate: {
enabled: false,
everyBytes: 0,
keepFiles: 0,
pollingInterval: 0,
usePolling: false,
},
};
setupLogging(server, config, 10);
reconfigureLogging(server, { ...config, dest: '/tmp/bar' }, 0);
});
});
2 changes: 1 addition & 1 deletion packages/kbn-legacy-logging/src/setup_logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ export function reconfigureLogging(
opsInterval: number
) {
const loggingOptions = getLoggingConfiguration(config, opsInterval);
(server.plugins as any)['@elastic/good'].reconfigure(loggingOptions);
(server.plugins as any).good.reconfigure(loggingOptions);
}
1 change: 1 addition & 0 deletions src/plugins/dashboard/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export function plugin(initializerContext: PluginInitializerContext) {
}

export { DashboardPluginSetup, DashboardPluginStart } from './types';
export { findByValueEmbeddables } from './usage/find_by_value_embeddables';
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import { SavedDashboardPanel730ToLatest } from '../../common';
import { findByValueEmbeddables } from './find_by_value_embeddables';

const visualizationByValue = ({
embeddableConfig: {
value: 'visualization-by-value',
},
type: 'visualization',
} as unknown) as SavedDashboardPanel730ToLatest;

const mapByValue = ({
embeddableConfig: {
value: 'map-by-value',
},
type: 'map',
} as unknown) as SavedDashboardPanel730ToLatest;

const embeddableByRef = ({
panelRefName: 'panel_ref_1',
} as unknown) as SavedDashboardPanel730ToLatest;

describe('findByValueEmbeddables', () => {
it('finds the by value embeddables for the given type', async () => {
const savedObjectsResult = {
saved_objects: [
{
attributes: {
panelsJSON: JSON.stringify([visualizationByValue, mapByValue, embeddableByRef]),
},
},
{
attributes: {
panelsJSON: JSON.stringify([embeddableByRef, mapByValue, visualizationByValue]),
},
},
],
};
const savedObjectClient = { find: jest.fn().mockResolvedValue(savedObjectsResult) };

const maps = await findByValueEmbeddables(savedObjectClient, 'map');

expect(maps.length).toBe(2);
expect(maps[0]).toEqual(mapByValue.embeddableConfig);
expect(maps[1]).toEqual(mapByValue.embeddableConfig);

const visualizations = await findByValueEmbeddables(savedObjectClient, 'visualization');

expect(visualizations.length).toBe(2);
expect(visualizations[0]).toEqual(visualizationByValue.embeddableConfig);
expect(visualizations[1]).toEqual(visualizationByValue.embeddableConfig);
});
});
34 changes: 34 additions & 0 deletions src/plugins/dashboard/server/usage/find_by_value_embeddables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

import { ISavedObjectsRepository, SavedObjectAttributes } from 'kibana/server';
import { SavedDashboardPanel730ToLatest } from '../../common';

export const findByValueEmbeddables = async (
savedObjectClient: Pick<ISavedObjectsRepository, 'find'>,
embeddableType: string
) => {
const dashboards = await savedObjectClient.find<SavedObjectAttributes>({
type: 'dashboard',
});

return dashboards.saved_objects
.map((dashboard) => {
try {
return (JSON.parse(
dashboard.attributes.panelsJSON as string
) as unknown) as SavedDashboardPanel730ToLatest[];
} catch (exception) {
return [];
}
})
.flat()
.filter((panel) => (panel as Record<string, any>).panelRefName === undefined)
.filter((panel) => panel.type === embeddableType)
.map((panel) => panel.embeddableConfig);
};
3 changes: 2 additions & 1 deletion src/plugins/data/common/search/search_source/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Public License, v 1.
*/

import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, of } from 'rxjs';
import type { MockedKeys } from '@kbn/utility-types/jest';
import { uiSettingsServiceMock } from '../../../../../core/public/mocks';

Expand All @@ -27,6 +27,7 @@ export const searchSourceInstanceMock: MockedKeys<ISearchSource> = {
createChild: jest.fn().mockReturnThis(),
setParent: jest.fn(),
getParent: jest.fn().mockReturnThis(),
fetch$: jest.fn().mockReturnValue(of({})),
fetch: jest.fn().mockResolvedValue({}),
onRequestStart: jest.fn(),
getSearchRequestBody: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ describe('SearchSource', () => {
let searchSource: SearchSource;

beforeEach(() => {
mockSearchMethod = jest.fn().mockReturnValue(of({ rawResponse: '' }));
mockSearchMethod = jest
.fn()
.mockReturnValue(
of(
{ rawResponse: { isPartial: true, isRunning: true } },
{ rawResponse: { isPartial: false, isRunning: false } }
)
);

searchSourceDependencies = {
getConfig: jest.fn(),
Expand Down Expand Up @@ -564,6 +571,34 @@ describe('SearchSource', () => {
await searchSource.fetch(options);
expect(mockSearchMethod).toBeCalledTimes(1);
});

test('should return partial results', (done) => {
searchSource = new SearchSource({ index: indexPattern }, searchSourceDependencies);
const options = {};

const next = jest.fn();
const complete = () => {
expect(next).toBeCalledTimes(2);
expect(next.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Object {
"isPartial": true,
"isRunning": true,
},
]
`);
expect(next.mock.calls[1]).toMatchInlineSnapshot(`
Array [
Object {
"isPartial": false,
"isRunning": false,
},
]
`);
done();
};
searchSource.fetch$(options).subscribe({ next, complete });
});
});

describe('#serialize', () => {
Expand Down
Loading

0 comments on commit 11f98f9

Please sign in to comment.