Skip to content

Commit

Permalink
Merge branch 'master' into apm-jump-to-trace-action-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 7, 2020
2 parents e1ba61b + f304176 commit 27f3d5f
Show file tree
Hide file tree
Showing 573 changed files with 20,291 additions and 7,191 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Delete any items that are not applicable to this PR.
- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)
- [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)
- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)
- [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

Expand Down
1 change: 1 addition & 0 deletions docs/apm/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ allowing you to easily see how these events are impacting the performance of you

By default, annotations are stored in a newly created `observability-annotations` index.
The name of this index can be changed in your `config.yml` by editing `xpack.observability.annotations.index`.
If you change the default index name, you'll also need to <<apm-app-annotation-user-create,update your user privileges>> accordingly.

The following APIs are available:

Expand Down
50 changes: 49 additions & 1 deletion docs/apm/apm-app-users.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

:beat_default_index_prefix: apm
:beat_kib_app: APM app
:annotation_index: `observability-annotations`
:annotation_index: observability-annotations

++++
<titleabbrev>Users and privileges</titleabbrev>
Expand Down Expand Up @@ -102,6 +102,54 @@ Here are two examples:
*********************************** ***********************************
////

[role="xpack"]
[[apm-app-annotation-user-create]]
=== APM app annotation user

++++
<titleabbrev>Create an annotation user</titleabbrev>
++++

NOTE: By default, the `apm_user` built-in role provides access to Observability annotations.
You only need to create an annotation user if the default annotation index
defined in <<apm-settings-kb,`xpack.observability.annotations.index`>> has been customized.

[[apm-app-annotation-user]]
==== Annotation user

View deployment annotations in the APM app.

. Create a new role, named something like `annotation_user`,
and assign the following privileges:
+
[options="header"]
|====
|Type | Privilege | Purpose

|Index
|`read` on +\{ANNOTATION_INDEX\}+^1^
|Read-only access to the observability annotation index

|Index
|`view_index_metadata` on +\{ANNOTATION_INDEX\}+^1^
|Read-only access to observability annotation index metadata
|====
+
^1^ +\{ANNOTATION_INDEX\}+ should be the index name you've defined in
<<apm-settings-kb,`xpack.observability.annotations.index`>>.

. Assign the `annotation_user` created previously, and the built-in roles necessary to create
a <<apm-app-reader-full,full>> or <<apm-app-reader-partial,partial>> APM reader to any users that need to view annotations in the APM app

[[apm-app-annotation-api]]
==== Annotation API

See <<apm-app-api-user>>.

////
*********************************** ***********************************
////

[role="xpack"]
[[apm-app-central-config-user]]
=== APM app central config user
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export declare class IndexPattern implements IIndexPattern
| [\_fetchFields()](./kibana-plugin-plugins-data-public.indexpattern._fetchfields.md) | | |
| [addScriptedField(name, script, fieldType, lang)](./kibana-plugin-plugins-data-public.indexpattern.addscriptedfield.md) | | |
| [create(allowOverride)](./kibana-plugin-plugins-data-public.indexpattern.create.md) | | |
| [destroy()](./kibana-plugin-plugins-data-public.indexpattern.destroy.md) | | |
| [getAggregationRestrictions()](./kibana-plugin-plugins-data-public.indexpattern.getaggregationrestrictions.md) | | |
| [getComputedFields()](./kibana-plugin-plugins-data-public.indexpattern.getcomputedfields.md) | | |
| [getFieldByName(name)](./kibana-plugin-plugins-data-public.indexpattern.getfieldbyname.md) | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ two out-of-the box connectors: <<slack-action-type, Slack>> and <<webhook-action
my-slack1: <1>
actionTypeId: .slack <2>
name: 'Slack #xyz' <3>
secrets: <4>
secrets:
webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz'
webhook-service:
actionTypeId: .webhook
name: 'Email service'
config:
config: <4>
url: 'https://email-alert-service.elastic.co'
method: post
headers:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,10 @@
"is-path-inside": "^2.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"jest": "^25.5.4",
"jest-environment-jsdom-thirteen": "^1.0.1",
"jest-canvas-mock": "^2.2.0",
"jest-circus": "^25.5.4",
"jest-cli": "^25.5.4",
"jest-environment-jsdom-thirteen": "^1.0.1",
"jest-raw-loader": "^1.0.1",
"jimp": "^0.9.6",
"json5": "^1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { inspect } from 'util';

import cpy from 'cpy';
import del from 'del';
import { toArray, tap } from 'rxjs/operators';
import { toArray, tap, filter } from 'rxjs/operators';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '@kbn/optimizer';

Expand Down Expand Up @@ -63,8 +63,7 @@ afterAll(async () => {
await del(TMP_DIR);
});

// FLAKY: https://github.com/elastic/kibana/issues/70762
it.skip('builds expected bundles, saves bundle counts to metadata', async () => {
it('builds expected bundles, saves bundle counts to metadata', async () => {
const config = OptimizerConfig.create({
repoRoot: MOCK_REPO_DIR,
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
Expand All @@ -75,7 +74,11 @@ it.skip('builds expected bundles, saves bundle counts to metadata', async () =>
expect(config).toMatchSnapshot('OptimizerConfig');

const msgs = await runOptimizer(config)
.pipe(logOptimizerState(log, config), toArray())
.pipe(
logOptimizerState(log, config),
filter((x) => x.event?.type !== 'worker stdio'),
toArray()
)
.toPromise();

const assert = (statement: string, truth: boolean, altStates?: OptimizerUpdate[]) => {
Expand Down Expand Up @@ -168,8 +171,7 @@ it.skip('builds expected bundles, saves bundle counts to metadata', async () =>
`);
});

// FLAKY: https://github.com/elastic/kibana/issues/70764
it.skip('uses cache on second run and exist cleanly', async () => {
it('uses cache on second run and exist cleanly', async () => {
const config = OptimizerConfig.create({
repoRoot: MOCK_REPO_DIR,
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
Expand Down
105 changes: 20 additions & 85 deletions src/core/server/elasticsearch/elasticsearch_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,14 @@
*/

import { BehaviorSubject } from 'rxjs';
import { Client } from 'elasticsearch';
import {
ILegacyClusterClient,
ILegacyCustomClusterClient,
ILegacyScopedClusterClient,
} from './legacy';
import { ILegacyClusterClient, ILegacyCustomClusterClient } from './legacy';
import { legacyClientMock } from './legacy/mocks';
import { ElasticsearchConfig } from './elasticsearch_config';
import { ElasticsearchService } from './elasticsearch_service';
import { InternalElasticsearchServiceSetup, ElasticsearchStatusMeta } from './types';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';
import { ServiceStatus, ServiceStatusLevels } from '../status';

const createScopedClusterClientMock = (): jest.Mocked<ILegacyScopedClusterClient> => ({
callAsInternalUser: jest.fn(),
callAsCurrentUser: jest.fn(),
});

const createCustomClusterClientMock = (): jest.Mocked<ILegacyCustomClusterClient> => ({
...createClusterClientMock(),
close: jest.fn(),
});

function createClusterClientMock() {
const client: jest.Mocked<ILegacyClusterClient> = {
callAsInternalUser: jest.fn(),
asScoped: jest.fn(),
};
client.asScoped.mockReturnValue(createScopedClusterClientMock());
return client;
}

interface MockedElasticSearchServiceSetup {
legacy: {
createClient: jest.Mock<ILegacyCustomClusterClient, any>;
Expand All @@ -60,11 +37,13 @@ const createSetupContractMock = () => {
const setupContract: MockedElasticSearchServiceSetup = {
legacy: {
createClient: jest.fn(),
client: createClusterClientMock(),
client: legacyClientMock.createClusterClient(),
},
};
setupContract.legacy.createClient.mockReturnValue(createCustomClusterClientMock());
setupContract.legacy.client.asScoped.mockReturnValue(createScopedClusterClientMock());
setupContract.legacy.createClient.mockReturnValue(legacyClientMock.createCustomClusterClient());
setupContract.legacy.client.asScoped.mockReturnValue(
legacyClientMock.createScopedClusterClient()
);
return setupContract;
};

Expand All @@ -74,11 +53,14 @@ const createStartContractMock = () => {
const startContract: MockedElasticSearchServiceStart = {
legacy: {
createClient: jest.fn(),
client: createClusterClientMock(),
client: legacyClientMock.createClusterClient(),
},
};
startContract.legacy.createClient.mockReturnValue(createCustomClusterClientMock());
startContract.legacy.client.asScoped.mockReturnValue(createScopedClusterClientMock());
startContract.legacy.createClient.mockReturnValue(legacyClientMock.createCustomClusterClient());
startContract.legacy.client.asScoped.mockReturnValue(
legacyClientMock.createScopedClusterClient()
);

return startContract;
};

Expand All @@ -104,7 +86,9 @@ const createInternalSetupContractMock = () => {
...createSetupContractMock().legacy,
},
};
setupContract.legacy.client.asScoped.mockReturnValue(createScopedClusterClientMock());
setupContract.legacy.client.asScoped.mockReturnValue(
legacyClientMock.createScopedClusterClient()
);
return setupContract;
};

Expand All @@ -121,62 +105,13 @@ const createMock = () => {
return mocked;
};

const createElasticsearchClientMock = () => {
const mocked: jest.Mocked<Client> = {
cat: {} as any,
cluster: {} as any,
indices: {} as any,
ingest: {} as any,
nodes: {} as any,
snapshot: {} as any,
tasks: {} as any,
bulk: jest.fn(),
clearScroll: jest.fn(),
count: jest.fn(),
create: jest.fn(),
delete: jest.fn(),
deleteByQuery: jest.fn(),
deleteScript: jest.fn(),
deleteTemplate: jest.fn(),
exists: jest.fn(),
explain: jest.fn(),
fieldStats: jest.fn(),
get: jest.fn(),
getScript: jest.fn(),
getSource: jest.fn(),
getTemplate: jest.fn(),
index: jest.fn(),
info: jest.fn(),
mget: jest.fn(),
msearch: jest.fn(),
msearchTemplate: jest.fn(),
mtermvectors: jest.fn(),
ping: jest.fn(),
putScript: jest.fn(),
putTemplate: jest.fn(),
reindex: jest.fn(),
reindexRethrottle: jest.fn(),
renderSearchTemplate: jest.fn(),
scroll: jest.fn(),
search: jest.fn(),
searchShards: jest.fn(),
searchTemplate: jest.fn(),
suggest: jest.fn(),
termvectors: jest.fn(),
update: jest.fn(),
updateByQuery: jest.fn(),
close: jest.fn(),
};
return mocked;
};

export const elasticsearchServiceMock = {
create: createMock,
createInternalSetup: createInternalSetupContractMock,
createSetup: createSetupContractMock,
createStart: createStartContractMock,
createClusterClient: createClusterClientMock,
createCustomClusterClient: createCustomClusterClientMock,
createScopedClusterClient: createScopedClusterClientMock,
createElasticsearchClient: createElasticsearchClientMock,
createLegacyClusterClient: legacyClientMock.createClusterClient,
createLegacyCustomClusterClient: legacyClientMock.createCustomClusterClient,
createLegacyScopedClusterClient: legacyClientMock.createScopedClusterClient,
createLegacyElasticsearchClient: legacyClientMock.createElasticsearchClient,
};
8 changes: 4 additions & 4 deletions src/core/server/elasticsearch/elasticsearch_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('#setup', () => {
});

it('returns elasticsearch client as a part of the contract', async () => {
const mockClusterClientInstance = elasticsearchServiceMock.createClusterClient();
const mockClusterClientInstance = elasticsearchServiceMock.createLegacyClusterClient();
MockClusterClient.mockImplementationOnce(() => mockClusterClientInstance);

const setupContract = await elasticsearchService.setup(deps);
Expand Down Expand Up @@ -209,7 +209,7 @@ describe('#setup', () => {
});

it('esNodeVersionCompatibility$ only starts polling when subscribed to', async (done) => {
const clusterClientInstance = elasticsearchServiceMock.createClusterClient();
const clusterClientInstance = elasticsearchServiceMock.createLegacyClusterClient();
MockClusterClient.mockImplementationOnce(() => clusterClientInstance);

clusterClientInstance.callAsInternalUser.mockRejectedValue(new Error());
Expand All @@ -225,7 +225,7 @@ describe('#setup', () => {
});

it('esNodeVersionCompatibility$ stops polling when unsubscribed from', async (done) => {
const mockClusterClientInstance = elasticsearchServiceMock.createClusterClient();
const mockClusterClientInstance = elasticsearchServiceMock.createLegacyClusterClient();
MockClusterClient.mockImplementationOnce(() => mockClusterClientInstance);

mockClusterClientInstance.callAsInternalUser.mockRejectedValue(new Error());
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('#stop', () => {

it('stops pollEsNodeVersions even if there are active subscriptions', async (done) => {
expect.assertions(2);
const mockClusterClientInstance = elasticsearchServiceMock.createCustomClusterClient();
const mockClusterClientInstance = elasticsearchServiceMock.createLegacyCustomClusterClient();

MockClusterClient.mockImplementationOnce(() => mockClusterClientInstance);

Expand Down
Loading

0 comments on commit 27f3d5f

Please sign in to comment.