Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into session-expir…
Browse files Browse the repository at this point in the history
…ed-message
  • Loading branch information
thomheymann committed Sep 30, 2021
2 parents 03f88b2 + a33ae63 commit a60d9da
Show file tree
Hide file tree
Showing 209 changed files with 7,080 additions and 2,555 deletions.
20 changes: 20 additions & 0 deletions docs/migration/migrate_8_0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,24 @@ The output directory after extracting an archive no longer includes the target p
*Impact:*
Configuration management tools and automation will need to be updated to use the new directory.

[float]
=== `elasticsearch.preserveHost` is no longer valid
*Details:* The deprecated `elasticsearch.preserveHost` setting in the `kibana.yml` file has been removed.

*Impact:* Configure {kibana-ref}/settings.html#elasticsearch-requestHeadersWhitelist[`elasticsearch.requestHeadersWhitelist`] to whitelist client-side headers.

[float]
=== `elasticsearch.startupTimeout` is no longer valid
*Details:* The deprecated `elasticsearch.startupTimeout` setting in the `kibana.yml` file has been removed.

*Impact:* Kibana will keep on trying to connect to Elasticsearch until it manages to connect.

[float]
=== `savedObjects.indexCheckTimeout` is no longer valid
*Details:* The deprecated `savedObjects.indexCheckTimeout` setting in the `kibana.yml` file has been removed.

[float]
=== `server.xsrf.token` is no longer valid
*Details:* The deprecated `server.xsrf.token` setting in the `kibana.yml` file has been removed.

// end::notable-breaking-changes[]
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
"@elastic/apm-rum-react": "^1.3.1",
"@elastic/charts": "34.2.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.20",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.21",
"@elastic/ems-client": "7.15.0",
"@elastic/eui": "37.6.0",
"@elastic/eui": "38.0.1",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/maki": "6.3.0",
Expand Down Expand Up @@ -266,6 +266,7 @@
"js-levenshtein": "^1.1.6",
"js-search": "^1.4.3",
"js-sha256": "^0.9.0",
"js-sql-parser": "^1.4.1",
"js-yaml": "^3.14.0",
"json-stable-stringify": "^1.0.1",
"json-stringify-pretty-compact": "1.2.0",
Expand Down Expand Up @@ -298,7 +299,6 @@
"nock": "12.0.3",
"node-fetch": "^2.6.1",
"node-forge": "^0.10.0",
"node-sql-parser": "^3.6.1",
"nodemailer": "^6.6.2",
"normalize-path": "^3.0.0",
"object-hash": "^1.3.1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions src/core/public/chrome/ui/header/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import { applicationServiceMock } from '../../../mocks';
import { Header } from './header';
import { ChromeBreadcrumbsAppendExtension } from '../../types';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => () => 'mockId',
}));

function mockProps() {
const http = httpServiceMock.createSetupContract({ basePath: '/test' });
const application = applicationServiceMock.createInternalStartContract();
Expand Down
22 changes: 17 additions & 5 deletions src/core/public/saved_objects/saved_objects_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ describe('SavedObjectsClient', () => {
});

describe('#resolve', () => {
beforeEach(() => {
function mockResolvedObjects(...objects: Array<Record<string, unknown>>) {
http.fetch.mockResolvedValue({
resolved_objects: [
{ saved_object: doc, outcome: 'conflict', alias_target_id: 'another-id' },
],
resolved_objects: objects.map((obj) => ({
saved_object: obj,
outcome: 'conflict',
alias_target_id: 'another-id',
})),
});
});
}

test('rejects if `type` parameter is undefined', () => {
return expect(
Expand All @@ -176,6 +178,7 @@ describe('SavedObjectsClient', () => {
});

test('makes HTTP call', async () => {
mockResolvedObjects(doc);
await savedObjectsClient.resolve(doc.type, doc.id);
expect(http.fetch.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Expand All @@ -191,10 +194,12 @@ describe('SavedObjectsClient', () => {

test('batches several #resolve calls into a single HTTP call', async () => {
// Await #resolve call to ensure batchQueue is empty and throttle has reset
mockResolvedObjects({ ...doc, type: 'type2' });
await savedObjectsClient.resolve('type2', doc.id);
http.fetch.mockClear();

// Make two #resolve calls right after one another
mockResolvedObjects({ ...doc, type: 'type1' }, { ...doc, type: 'type0' });
savedObjectsClient.resolve('type1', doc.id);
await savedObjectsClient.resolve('type0', doc.id);
expect(http.fetch.mock.calls).toMatchInlineSnapshot(`
Expand All @@ -213,9 +218,11 @@ describe('SavedObjectsClient', () => {

test('removes duplicates when calling `_bulk_resolve`', async () => {
// Await #resolve call to ensure batchQueue is empty and throttle has reset
mockResolvedObjects({ ...doc, type: 'type2' });
await savedObjectsClient.resolve('type2', doc.id);
http.fetch.mockClear();

mockResolvedObjects(doc, { ...doc, type: 'some-type', id: 'some-id' }); // the client will only request two objects, so we only mock two results
savedObjectsClient.resolve(doc.type, doc.id);
savedObjectsClient.resolve('some-type', 'some-id');
await savedObjectsClient.resolve(doc.type, doc.id);
Expand All @@ -235,9 +242,11 @@ describe('SavedObjectsClient', () => {

test('resolves with correct object when there are duplicates present', async () => {
// Await #resolve call to ensure batchQueue is empty and throttle has reset
mockResolvedObjects({ ...doc, type: 'type2' });
await savedObjectsClient.resolve('type2', doc.id);
http.fetch.mockClear();

mockResolvedObjects(doc);
const call1 = savedObjectsClient.resolve(doc.type, doc.id);
const objFromCall2 = await savedObjectsClient.resolve(doc.type, doc.id);
const objFromCall1 = await call1;
Expand All @@ -252,8 +261,10 @@ describe('SavedObjectsClient', () => {
test('do not share instances or references between duplicate callers', async () => {
// Await #resolve call to ensure batchQueue is empty and throttle has reset
await savedObjectsClient.resolve('type2', doc.id);
mockResolvedObjects({ ...doc, type: 'type2' });
http.fetch.mockClear();

mockResolvedObjects(doc);
const call1 = savedObjectsClient.resolve(doc.type, doc.id);
const objFromCall2 = await savedObjectsClient.resolve(doc.type, doc.id);
const objFromCall1 = await call1;
Expand All @@ -263,6 +274,7 @@ describe('SavedObjectsClient', () => {
});

test('resolves with ResolvedSimpleSavedObject instance', async () => {
mockResolvedObjects(doc);
const result = await savedObjectsClient.resolve(doc.type, doc.id);
expect(result.saved_object).toBeInstanceOf(SimpleSavedObject);
expect(result.saved_object.type).toBe(doc.type);
Expand Down
56 changes: 31 additions & 25 deletions src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ interface ObjectTypeAndId {
type: string;
}

const getObjectsToFetch = (
queue: Array<BatchGetQueueEntry | BatchResolveQueueEntry>
): ObjectTypeAndId[] => {
const getObjectsToFetch = (queue: BatchGetQueueEntry[]): ObjectTypeAndId[] => {
const objects: ObjectTypeAndId[] = [];
const inserted = new Set<string>();
queue.forEach(({ id, type }) => {
Expand All @@ -165,6 +163,24 @@ const getObjectsToFetch = (
return objects;
};

const getObjectsToResolve = (queue: BatchResolveQueueEntry[]) => {
const responseIndices: number[] = [];
const objectsToResolve: ObjectTypeAndId[] = [];
const inserted = new Map<string, number>();
queue.forEach(({ id, type }, currentIndex) => {
const key = `${type}|${id}`;
const indexForTypeAndId = inserted.get(key);
if (indexForTypeAndId === undefined) {
inserted.set(key, currentIndex);
objectsToResolve.push({ id, type });
responseIndices.push(currentIndex);
} else {
responseIndices.push(indexForTypeAndId);
}
});
return { objectsToResolve, responseIndices };
};

/**
* Saved Objects is Kibana's data persisentence mechanism allowing plugins to
* use Elasticsearch for storing plugin state. The client-side
Expand Down Expand Up @@ -224,28 +240,18 @@ export class SavedObjectsClient {
this.batchResolveQueue = [];

try {
const objectsToFetch = getObjectsToFetch(queue);
const { resolved_objects: savedObjects } = await this.performBulkResolve(objectsToFetch);

queue.forEach((queueItem) => {
const foundObject = savedObjects.find((resolveResponse) => {
return (
resolveResponse.saved_object.id === queueItem.id &&
resolveResponse.saved_object.type === queueItem.type
);
});

if (foundObject) {
// multiple calls may have been requested the same object.
// we need to clone to avoid sharing references between the instances
queueItem.resolve(this.createResolvedSavedObject(cloneDeep(foundObject)));
} else {
queueItem.resolve(
this.createResolvedSavedObject({
saved_object: pick(queueItem, ['id', 'type']),
} as SavedObjectsResolveResponse)
);
}
const { objectsToResolve, responseIndices } = getObjectsToResolve(queue);
const { resolved_objects: resolvedObjects } = await this.performBulkResolve(
objectsToResolve
);

queue.forEach((queueItem, i) => {
// This differs from the older processBatchGetQueue approach because the resolved object IDs are *not* guaranteed to be the same.
// Instead, we rely on the guarantee that the objects in the bulkResolve response will be in the same order as the requests.
// However, we still need to clone the response object because we deduplicate batched requests.
const responseIndex = responseIndices[i];
const clone = cloneDeep(resolvedObjects[responseIndex]);
queueItem.resolve(this.createResolvedSavedObject(clone));
});
} catch (err) {
queue.forEach((queueItem) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ describe('migration actions', () => {

// Reindex doesn't return any errors on it's own, so we have to test
// together with waitForReindexTask
// FLAKY: https://github.com/elastic/kibana/issues/103231
describe.skip('reindex & waitForReindexTask', () => {
describe('reindex & waitForReindexTask', () => {
it('resolves right when reindex succeeds without reindex script', async () => {
const res = (await reindex({
client,
Expand Down Expand Up @@ -792,6 +791,11 @@ describe('migration actions', () => {
`);
});
it('resolves left wait_for_task_completion_timeout when the task does not finish within the timeout', async () => {
await waitForIndexStatusYellow({
client,
index: '.kibana_1',
})();

const res = (await reindex({
client,
sourceIndex: '.kibana_1',
Expand Down
3 changes: 1 addition & 2 deletions src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ export const DEV_ONLY_LICENSE_ALLOWED = ['MPL-2.0'];
export const LICENSE_OVERRIDES = {
'jsts@1.6.2': ['Eclipse Distribution License - v 1.0'], // cf. https://github.com/bjornharrtell/jsts
'@mapbox/jsonlint-lines-primitives@2.0.2': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'node-sql-parser@3.6.1': ['(GPL-2.0 OR MIT)'], // GPL-2.0* https://github.com/taozhi8833998/node-sql-parser
'@elastic/ems-client@7.15.0': ['Elastic License 2.0'],
'@elastic/eui@37.6.0': ['SSPL-1.0 OR Elastic License 2.0'],
'@elastic/eui@38.0.1': ['SSPL-1.0 OR Elastic License 2.0'],

// TODO can be removed if the https://github.com/jindw/xmldom/issues/239 is released
'xmldom@0.1.27': ['MIT'],
Expand Down
7 changes: 6 additions & 1 deletion src/plugins/custom_integrations/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ export const CATEGORY_DISPLAY = {

export type Category = keyof typeof CATEGORY_DISPLAY;

export interface CustomIntegrationIcon {
src: string;
type: 'eui' | 'svg';
}

export interface CustomIntegration {
id: string;
title: string;
description: string;
type: 'ui_link';
uiInternalPath: string;
isBeta: boolean;
icons: Array<{ src: string; type: string }>;
icons: CustomIntegrationIcon[];
categories: Category[];
shipper: string;
}
Expand Down
8 changes: 3 additions & 5 deletions src/plugins/custom_integrations/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
* Side Public License, v 1.
*/

import type { MockedKeys } from '@kbn/utility-types/jest';

import { CustomIntegrationsPluginSetup } from '../server';

function createCustomIntegrationsSetup(): MockedKeys<CustomIntegrationsPluginSetup> {
const mock = {
function createCustomIntegrationsSetup(): jest.Mocked<CustomIntegrationsPluginSetup> {
const mock: jest.Mocked<CustomIntegrationsPluginSetup> = {
registerCustomIntegration: jest.fn(),
getAppendCustomIntegrations: jest.fn(),
};

return mock as MockedKeys<CustomIntegrationsPluginSetup>;
return mock;
}

export const customIntegrationsMock = {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dashboard/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"data",
"embeddable",
"inspector",
"kibanaLegacy",
"navigation",
"savedObjects",
"share",
Expand Down
Loading

0 comments on commit a60d9da

Please sign in to comment.