Skip to content

Commit

Permalink
Merge branch 'master' into cross_cluster_search
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 29, 2020
2 parents 4322db4 + dbdc3cd commit d6c1b44
Show file tree
Hide file tree
Showing 68 changed files with 1,430 additions and 561 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ Public information about a registered [application](./kibana-plugin-core-public.
```typescript
export declare type PublicAppInfo = Omit<App, 'mount' | 'updater$'> & {
legacy: false;
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
appRoute: string;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ Information about a registered [legacy application](./kibana-plugin-core-public.
```typescript
export declare type PublicLegacyAppInfo = Omit<LegacyApp, 'updater$'> & {
legacy: true;
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
};
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
"inline-style": "^2.0.0",
"joi": "^13.5.2",
"jquery": "^3.5.0",
"js-levenshtein": "^1.1.6",
"js-yaml": "3.13.1",
"json-stable-stringify": "^1.0.1",
"json-stringify-pretty-compact": "1.2.0",
Expand Down
7 changes: 7 additions & 0 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ export interface LegacyApp extends AppBase {
*/
export type PublicAppInfo = Omit<App, 'mount' | 'updater$'> & {
legacy: false;
// remove optional on fields populated with default values
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
appRoute: string;
};

/**
Expand All @@ -278,6 +282,9 @@ export type PublicAppInfo = Omit<App, 'mount' | 'updater$'> & {
*/
export type PublicLegacyAppInfo = Omit<LegacyApp, 'updater$'> & {
legacy: true;
// remove optional on fields populated with default values
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
};

/**
Expand Down
5 changes: 5 additions & 0 deletions src/core/public/application/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ export function getAppInfo(app: App<unknown> | LegacyApp): PublicAppInfo | Publi
const { updater$, ...infos } = app;
return {
...infos,
status: app.status!,
navLinkStatus: app.navLinkStatus!,
legacy: true,
};
} else {
const { updater$, mount, ...infos } = app;
return {
...infos,
status: app.status!,
navLinkStatus: app.navLinkStatus!,
appRoute: app.appRoute!,
legacy: false,
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1143,11 +1143,16 @@ export type PluginOpaqueId = symbol;
// @public
export type PublicAppInfo = Omit<App, 'mount' | 'updater$'> & {
legacy: false;
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
appRoute: string;
};

// @public
export type PublicLegacyAppInfo = Omit<LegacyApp, 'updater$'> & {
legacy: true;
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
};

// @public
Expand Down
2 changes: 2 additions & 0 deletions vars/kibanaPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def functionalTestProcess(String name, Closure closure) {
def kibanaPort = "61${processNumber}1"
def esPort = "61${processNumber}2"
def esTransportPort = "61${processNumber}3"
def ingestManagementPackageRegistryPort = "61${processNumber}4"

withEnv([
"CI_PARALLEL_PROCESS_NUMBER=${processNumber}",
Expand All @@ -29,6 +30,7 @@ def functionalTestProcess(String name, Closure closure) {
"TEST_KIBANA_URL=http://elastic:changeme@localhost:${kibanaPort}",
"TEST_ES_URL=http://elastic:changeme@localhost:${esPort}",
"TEST_ES_TRANSPORT_PORT=${esTransportPort}",
"INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=${ingestManagementPackageRegistryPort}",
"IS_PIPELINE_JOB=1",
"JOB=${name}",
"KBN_NP_PLUGINS_BUILT=true",
Expand Down
25 changes: 22 additions & 3 deletions x-pack/plugins/apm/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,38 @@ For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)

### API integration tests

Our tests are separated in two suites: one suite runs with a basic license, and the other
with a trial license (the equivalent of gold+). This requires separate test servers and test runs.

**Start server**

Basic:

```
node scripts/functional_tests_server --config x-pack/test/apm_api_integration/basic/config.ts
```

Trial:

```
node scripts/functional_tests_server --config x-pack/test/api_integration/config.ts
node scripts/functional_tests_server --config x-pack/test/apm_api_integration/trial/config.ts
```

**Run tests**

Basic:

```
node scripts/functional_test_runner --config x-pack/test/apm_api_integration/basic/config.ts
```

Trial:

```
node scripts/functional_test_runner --config x-pack/test/api_integration/config.ts --grep='APM specs'
node scripts/functional_test_runner --config x-pack/test/apm_api_integration/trial/config.ts
```

APM tests are located in `x-pack/test/api_integration/apis/apm`.
APM tests are located in `x-pack/test/apm_api_integration`.
For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)

### Linting
Expand Down
64 changes: 28 additions & 36 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,42 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import { combineLatest, Observable } from 'rxjs';
import { map, take } from 'rxjs/operators';
import {
PluginInitializerContext,
Plugin,
CoreSetup,
CoreStart,
Logger,
Plugin,
PluginInitializerContext,
} from 'src/core/server';
import { Observable, combineLatest } from 'rxjs';
import { map, take } from 'rxjs/operators';
import { ObservabilityPluginSetup } from '../../observability/server';
import { SecurityPluginSetup } from '../../security/server';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
import { TaskManagerSetupContract } from '../../task_manager/server';
import { AlertingPlugin } from '../../alerts/server';
import { ActionsPlugin } from '../../actions/server';
import { APMConfig, APMXPackConfig, mergeConfigs } from '.';
import { APMOSSPluginSetup } from '../../../../src/plugins/apm_oss/server';
import { createApmAgentConfigurationIndex } from './lib/settings/agent_configuration/create_agent_config_index';
import { createApmCustomLinkIndex } from './lib/settings/custom_link/create_custom_link_index';
import { createApmApi } from './routes/create_apm_api';
import { getApmIndices } from './lib/settings/apm_indices/get_apm_indices';
import { APMConfig, mergeConfigs, APMXPackConfig } from '.';
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
import { ActionsPlugin } from '../../actions/server';
import { AlertingPlugin } from '../../alerts/server';
import { CloudSetup } from '../../cloud/server';
import { getInternalSavedObjectsClient } from './lib/helpers/get_internal_saved_objects_client';
import {
LicensingPluginSetup,
LicensingPluginStart,
} from '../../licensing/server';
import { registerApmAlerts } from './lib/alerts/register_apm_alerts';
import { createApmTelemetry } from './lib/apm_telemetry';

import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
import { LicensingPluginSetup } from '../../licensing/server';
import { MlPluginSetup } from '../../ml/server';
import { ObservabilityPluginSetup } from '../../observability/server';
import { SecurityPluginSetup } from '../../security/server';
import { TaskManagerSetupContract } from '../../task_manager/server';
import {
APM_FEATURE,
APM_SERVICE_MAPS_FEATURE_NAME,
APM_SERVICE_MAPS_LICENSE_TYPE,
} from './feature';
import { registerApmAlerts } from './lib/alerts/register_apm_alerts';
import { createApmTelemetry } from './lib/apm_telemetry';
import { getInternalSavedObjectsClient } from './lib/helpers/get_internal_saved_objects_client';
import { createApmAgentConfigurationIndex } from './lib/settings/agent_configuration/create_agent_config_index';
import { getApmIndices } from './lib/settings/apm_indices/get_apm_indices';
import { createApmCustomLinkIndex } from './lib/settings/custom_link/create_custom_link_index';
import { createApmApi } from './routes/create_apm_api';
import { apmIndices, apmTelemetry } from './saved_objects';
import { createElasticCloudInstructions } from './tutorial/elastic_cloud';
import { MlPluginSetup } from '../../ml/server';

export interface APMPluginSetup {
config$: Observable<APMConfig>;
Expand Down Expand Up @@ -135,18 +131,14 @@ export class APMPlugin implements Plugin<APMPluginSetup> {
APM_SERVICE_MAPS_LICENSE_TYPE
);

core.getStartServices().then(([_coreStart, pluginsStart]) => {
createApmApi().init(core, {
config$: mergedConfig$,
logger: this.logger!,
plugins: {
licensing: (pluginsStart as { licensing: LicensingPluginStart })
.licensing,
observability: plugins.observability,
security: plugins.security,
ml: plugins.ml,
},
});
createApmApi().init(core, {
config$: mergedConfig$,
logger: this.logger!,
plugins: {
observability: plugins.observability,
security: plugins.security,
ml: plugins.ml,
},
});

return {
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/apm/server/routes/create_api/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { CoreSetup, Logger } from 'src/core/server';
import { Params } from '../typings';
import { BehaviorSubject } from 'rxjs';
import { APMConfig } from '../..';
import { LicensingPluginStart } from '../../../../licensing/server';

const getCoreMock = () => {
const get = jest.fn();
Expand Down Expand Up @@ -41,7 +40,7 @@ const getCoreMock = () => {
logger: ({
error: jest.fn(),
} as unknown) as Logger,
plugins: { licensing: {} as LicensingPluginStart },
plugins: {},
},
};
};
Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/apm/server/routes/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export const serviceMapRoute = createRoute(() => ({
if (!isValidPlatinumLicense(context.licensing.license)) {
throw Boom.forbidden(invalidLicenseMessage);
}

context.plugins.licensing.featureUsage.notifyUsage(
APM_SERVICE_MAPS_FEATURE_NAME
);
context.licensing.featureUsage.notifyUsage(APM_SERVICE_MAPS_FEATURE_NAME);

const setup = await setupRequest(context, request);
const {
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/apm/server/routes/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import { PickByValue, Optional } from 'utility-types';
import { Observable } from 'rxjs';
import { Server } from 'hapi';
import { LicensingPluginStart } from '../../../licensing/server';
import { ObservabilityPluginSetup } from '../../../observability/server';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { FetchOptions } from '../../public/services/rest/callApi';
Expand Down Expand Up @@ -67,7 +66,6 @@ export type APMRequestHandlerContext<
config: APMConfig;
logger: Logger;
plugins: {
licensing: LicensingPluginStart;
observability?: ObservabilityPluginSetup;
security?: SecurityPluginSetup;
ml?: MlPluginSetup;
Expand Down Expand Up @@ -116,7 +114,6 @@ export interface ServerAPI<TRouteState extends RouteState> {
config$: Observable<APMConfig>;
logger: Logger;
plugins: {
licensing: LicensingPluginStart;
observability?: ObservabilityPluginSetup;
security?: SecurityPluginSetup;
ml?: MlPluginSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export const registerPermissionsRoute = ({
});

const missingClusterPrivileges = Object.keys(cluster).reduce(
(permissions: any, permissionName: any) => {
(permissions: string[], permissionName: string) => {
if (!cluster[permissionName]) {
permissions.push(permissionName);
return permissions;
}
return permissions;
},
[] as any[]
[]
);

return response.ok({
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/global_search_providers/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "globalSearchProviders",
"version": "8.0.0",
"kibanaVersion": "kibana",
"server": false,
"ui": true,
"requiredPlugins": ["globalSearch"],
"optionalPlugins": [],
"configPath": ["xpack", "global_search_providers"]
}
11 changes: 11 additions & 0 deletions x-pack/plugins/global_search_providers/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { PluginInitializer } from 'src/core/public';
import { GlobalSearchProvidersPlugin, GlobalSearchProvidersPluginSetupDeps } from './plugin';

export const plugin: PluginInitializer<{}, {}, GlobalSearchProvidersPluginSetupDeps, {}> = () =>
new GlobalSearchProvidersPlugin();
33 changes: 33 additions & 0 deletions x-pack/plugins/global_search_providers/public/plugin.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { coreMock } from '../../../../src/core/public/mocks';
import { globalSearchPluginMock } from '../../global_search/public/mocks';
import { GlobalSearchProvidersPlugin } from './plugin';

describe('GlobalSearchProvidersPlugin', () => {
let plugin: GlobalSearchProvidersPlugin;
let globalSearchSetup: ReturnType<typeof globalSearchPluginMock.createSetupContract>;

beforeEach(() => {
globalSearchSetup = globalSearchPluginMock.createSetupContract();
plugin = new GlobalSearchProvidersPlugin();
});

describe('#setup', () => {
it('registers the `application` result provider', () => {
const coreSetup = coreMock.createSetup();
plugin.setup(coreSetup, { globalSearch: globalSearchSetup });

expect(globalSearchSetup.registerResultProvider).toHaveBeenCalledTimes(1);
expect(globalSearchSetup.registerResultProvider).toHaveBeenCalledWith(
expect.objectContaining({
id: 'application',
})
);
});
});
});
29 changes: 29 additions & 0 deletions x-pack/plugins/global_search_providers/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { CoreSetup, Plugin } from 'src/core/public';
import { GlobalSearchPluginSetup } from '../../global_search/public';
import { createApplicationResultProvider } from './providers';

export interface GlobalSearchProvidersPluginSetupDeps {
globalSearch: GlobalSearchPluginSetup;
}

export class GlobalSearchProvidersPlugin
implements Plugin<{}, {}, GlobalSearchProvidersPluginSetupDeps, {}> {
setup(
{ getStartServices }: CoreSetup<{}, {}>,
{ globalSearch }: GlobalSearchProvidersPluginSetupDeps
) {
const applicationPromise = getStartServices().then(([core]) => core.application);
globalSearch.registerResultProvider(createApplicationResultProvider(applicationPromise));
return {};
}

start() {
return {};
}
}
Loading

0 comments on commit d6c1b44

Please sign in to comment.