Skip to content

Commit

Permalink
Merge branch 'EMT-146_use_agent_service_for_status' of github.com:nna…
Browse files Browse the repository at this point in the history
…mdifrankie/kibana into EMT-146_use_agent_service_for_status
  • Loading branch information
nnamdifrankie committed Apr 20, 2020
2 parents bcd6e4c + 578e0bf commit b36c29f
Show file tree
Hide file tree
Showing 42 changed files with 297 additions and 446 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
| [SavedQuery](./kibana-plugin-plugins-data-public.savedquery.md) | |
| [SavedQueryService](./kibana-plugin-plugins-data-public.savedqueryservice.md) | |
| [SearchSourceFields](./kibana-plugin-plugins-data-public.searchsourcefields.md) | |
| [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) | |
| [TabbedAggColumn](./kibana-plugin-plugins-data-public.tabbedaggcolumn.md) | \* |
| [TabbedTable](./kibana-plugin-plugins-data-public.tabbedtable.md) | \* |
| [TimeRange](./kibana-plugin-plugins-data-public.timerange.md) | |
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 6 additions & 6 deletions src/core/public/plugins/plugin_loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('`loadPluginBundles` creates a script tag and loads initializer', async ()
const fakeScriptTag = createdScriptTags[0];
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith(
'src',
'/bundles/plugin/plugin-a/plugin-a.plugin.js'
'/bundles/plugin:plugin-a/plugin-a.plugin.js'
);
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith('id', 'kbn-plugin-plugin-a');
expect(fakeScriptTag.onload).toBeInstanceOf(Function);
Expand All @@ -85,7 +85,7 @@ test('`loadPluginBundles` includes the basePath', async () => {
const fakeScriptTag = createdScriptTags[0];
expect(fakeScriptTag.setAttribute).toHaveBeenCalledWith(
'src',
'/mybasepath/bundles/plugin/plugin-a/plugin-a.plugin.js'
'/mybasepath/bundles/plugin:plugin-a/plugin-a.plugin.js'
);
});

Expand All @@ -96,7 +96,7 @@ test('`loadPluginBundles` rejects if script.onerror is called', async () => {
fakeScriptTag1.onerror(new Error('Whoa there!'));

await expect(loadPromise).rejects.toThrowErrorMatchingInlineSnapshot(
`"Failed to load \\"plugin-a\\" bundle (/bundles/plugin/plugin-a/plugin-a.plugin.js)"`
`"Failed to load \\"plugin-a\\" bundle (/bundles/plugin:plugin-a/plugin-a.plugin.js)"`
);
});

Expand All @@ -105,7 +105,7 @@ test('`loadPluginBundles` rejects if timeout is reached', async () => {
// Override the timeout to 1 ms for testi.
loadPluginBundle(addBasePath, 'plugin-a', { timeoutMs: 1 })
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Timeout reached when loading \\"plugin-a\\" bundle (/bundles/plugin/plugin-a/plugin-a.plugin.js)"`
`"Timeout reached when loading \\"plugin-a\\" bundle (/bundles/plugin:plugin-a/plugin-a.plugin.js)"`
);
});

Expand All @@ -115,11 +115,11 @@ test('`loadPluginBundles` rejects if bundle does attach an initializer to window
const fakeScriptTag1 = createdScriptTags[0];

// Setup a fake initializer as if a plugin bundle had actually been loaded.
coreWindow.__kbnBundles__['plugin/plugin-a'] = undefined;
coreWindow.__kbnBundles__['plugin:plugin-a'] = undefined;
// Call the onload callback
fakeScriptTag1.onload();

await expect(loadPromise).rejects.toThrowErrorMatchingInlineSnapshot(
`"Definition of plugin \\"plugin-a\\" should be a function (/bundles/plugin/plugin-a/plugin-a.plugin.js)."`
`"Definition of plugin \\"plugin-a\\" should be a function (/bundles/plugin:plugin-a/plugin-a.plugin.js)."`
);
});
2 changes: 1 addition & 1 deletion src/core/public/plugins/plugin_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const loadPluginBundle: LoadPluginBundle = <

const script = document.createElement('script');
// Assumes that all plugin bundles get put into the bundles/plugins subdirectory
const bundlePath = addBasePath(`/bundles/plugin/${pluginName}/${pluginName}.plugin.js`);
const bundlePath = addBasePath(`/bundles/plugin:${pluginName}/${pluginName}.plugin.js`);
script.setAttribute('src', bundlePath);
script.setAttribute('id', `kbn-plugin-${pluginName}`);
script.setAttribute('async', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { getIndices } from './get_indices';
import { IndexPatternCreationConfig } from '../../../../../../../../../plugins/index_pattern_management/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search';
import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search/legacy';

export const successfulResponse = {
hits: {
Expand Down
8 changes: 4 additions & 4 deletions src/legacy/ui/ui_render/bootstrap/template.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ if (window.__kbnStrictCsp__ && window.__kbnCspNotEnforced__) {
'{{this}}',
{{/each}}
'{{regularBundlePath}}/commons.bundle.js',
{{!-- '{{regularBundlePath}}/plugin/data/data.plugin.js', --}}
'{{regularBundlePath}}/plugin/kibanaUtils/kibanaUtils.plugin.js',
'{{regularBundlePath}}/plugin/esUiShared/esUiShared.plugin.js',
'{{regularBundlePath}}/plugin/kibanaReact/kibanaReact.plugin.js'
{{!-- '{{regularBundlePath}}/plugin:data/data.plugin.js', --}}
'{{regularBundlePath}}/plugin:kibanaUtils/kibanaUtils.plugin.js',
'{{regularBundlePath}}/plugin:esUiShared/esUiShared.plugin.js',
'{{regularBundlePath}}/plugin:kibanaReact/kibanaReact.plugin.js'
], function () {
load([
'{{regularBundlePath}}/{{appId}}.bundle.js',
Expand Down
4 changes: 2 additions & 2 deletions src/optimize/bundles_route/bundles_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export function createBundlesRoute({
),
...npUiPluginPublicDirs.map(({ id, path }) =>
buildRouteForBundles(
`${basePublicPath}/bundles/plugin/${id}/`,
`/bundles/plugin/${id}/`,
`${basePublicPath}/bundles/plugin:${id}/`,
`/bundles/plugin:${id}/`,
path,
fileHashCache
)
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ export {
SearchRequest,
SearchResponse,
SearchError,
SearchStrategyProvider,
ISearchSource,
SearchSource,
createSearchSource,
Expand Down
45 changes: 15 additions & 30 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1724,21 +1724,6 @@ export interface SearchSourceFields {
version?: boolean;
}

// Warning: (ae-missing-release-tag) "SearchStrategyProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface SearchStrategyProvider {
// (undocumented)
id: string;
// (undocumented)
isViable: (indexPattern: IndexPattern) => boolean;
// Warning: (ae-forgotten-export) The symbol "SearchStrategySearchParams" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "SearchStrategyResponse" needs to be exported by the entry point index.d.ts
//
// (undocumented)
search: (params: SearchStrategySearchParams) => SearchStrategyResponse;
}

// Warning: (ae-missing-release-tag) "SortDirection" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -1889,21 +1874,21 @@ export type TSearchStrategyProvider<T extends TStrategyTypes> = (context: ISearc
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:406:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:387:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:399:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:404:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:408:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromEvent" needs to be exported by the entry point index.d.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { coreMock } from '../../../../../../../src/core/public/mocks';
import { dataPluginMock } from '../../../../public/mocks';
import { coreMock } from '../../../../../../core/public/mocks';
import { dataPluginMock } from '../../../mocks';
import {
setFieldFormats,
setIndexPatterns,
Expand All @@ -29,7 +29,7 @@ import {
setQueryService,
setSearchService,
setUiSettings,
} from '../../../../public/services';
} from '../../../services';

/**
* Testing helper which calls all of the service setters used in the
Expand All @@ -49,4 +49,9 @@ export function mockDataServices() {
setQueryService(data.query);
setSearchService(data.search);
setUiSettings(core.uiSettings);

return {
core,
data,
};
}
70 changes: 70 additions & 0 deletions src/plugins/data/public/search/fetch/get_search_params.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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 { getSearchParams } from './get_search_params';
import { IUiSettingsClient } from 'kibana/public';

function getConfigStub(config: any = {}) {
return {
get: key => config[key],
} as IUiSettingsClient;
}

describe('getSearchParams', () => {
test('includes rest_total_hits_as_int', () => {
const config = getConfigStub();
const searchParams = getSearchParams(config);
expect(searchParams.rest_total_hits_as_int).toBe(true);
});

test('includes ignore_unavailable', () => {
const config = getConfigStub();
const searchParams = getSearchParams(config);
expect(searchParams.ignore_unavailable).toBe(true);
});

test('includes ignore_throttled according to search:includeFrozen', () => {
let config = getConfigStub({ 'search:includeFrozen': true });
let searchParams = getSearchParams(config);
expect(searchParams.ignore_throttled).toBe(false);

config = getConfigStub({ 'search:includeFrozen': false });
searchParams = getSearchParams(config);
expect(searchParams.ignore_throttled).toBe(true);
});

test('includes max_concurrent_shard_requests according to courier:maxConcurrentShardRequests', () => {
let config = getConfigStub({ 'courier:maxConcurrentShardRequests': 0 });
let searchParams = getSearchParams(config);
expect(searchParams.max_concurrent_shard_requests).toBe(undefined);

config = getConfigStub({ 'courier:maxConcurrentShardRequests': 5 });
searchParams = getSearchParams(config);
expect(searchParams.max_concurrent_shard_requests).toBe(5);
});

test('includes timeout according to esShardTimeout if greater than 0', () => {
const config = getConfigStub();
let searchParams = getSearchParams(config, 0);
expect(searchParams.timeout).toBe(undefined);

searchParams = getSearchParams(config, 100);
expect(searchParams.timeout).toBe('100ms');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@
* under the License.
*/

import { IUiSettingsClient } from '../../../../../core/public';
import { IUiSettingsClient } from 'kibana/public';

const sessionId = Date.now();

export function getMSearchParams(config: IUiSettingsClient) {
return {
rest_total_hits_as_int: true,
ignore_throttled: getIgnoreThrottled(config),
max_concurrent_shard_requests: getMaxConcurrentShardRequests(config),
};
}

export function getSearchParams(config: IUiSettingsClient, esShardTimeout: number = 0) {
return {
rest_total_hits_as_int: true,
Expand All @@ -40,11 +32,11 @@ export function getSearchParams(config: IUiSettingsClient, esShardTimeout: numbe
};
}

function getIgnoreThrottled(config: IUiSettingsClient) {
export function getIgnoreThrottled(config: IUiSettingsClient) {
return !config.get('search:includeFrozen');
}

function getMaxConcurrentShardRequests(config: IUiSettingsClient) {
export function getMaxConcurrentShardRequests(config: IUiSettingsClient) {
const maxConcurrentShardRequests = config.get('courier:maxConcurrentShardRequests');
return maxConcurrentShardRequests > 0 ? maxConcurrentShardRequests : undefined;
}
Expand Down
13 changes: 11 additions & 2 deletions src/plugins/data/public/search/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,14 @@
*/

export * from './types';
export { fetchSoon } from './fetch_soon';
export { RequestFailure } from './errors';
export {
getSearchParams,
getPreference,
getTimeout,
getIgnoreThrottled,
getMaxConcurrentShardRequests,
} from './get_search_params';

export { SearchError, getSearchErrorType } from './search_error';
export { RequestFailure } from './request_error';
export { handleResponse } from './handle_response';
3 changes: 3 additions & 0 deletions src/plugins/data/public/search/fetch/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import { IUiSettingsClient } from '../../../../../core/public';
import { ISearchStart } from '../types';

export type SearchRequest = any;
export type SearchResponse = any;

export interface FetchOptions {
abortSignal?: AbortSignal;
searchStrategyId?: string;
Expand Down
Loading

0 comments on commit b36c29f

Please sign in to comment.