Skip to content

Commit

Permalink
[ILM] Add searchable snapshot field (#83783)
Browse files Browse the repository at this point in the history
* Added server-side endpoint for getting list of repos

* part one of client side changes: added searchable snapshot field

- added to both hot and cold
- serializing into JSON payload

* make searchable snapshot field toggleable and require value when it is being used

* fix typo in file name and remove whitespace

* added searchable snapshot state context, wip

* finished updating fields to show and hide based on searchable snapshot in the hot phase

* hiding fields when searchable snapshots is enabled in hot

- removed nested EuiFieldRow components in data allocation field
- added SCSS files for data allocation field and searchable
  snapshot field

* added translations and a first hot phase serialization test

* appease type check and i18n

* added cloud-specific behaviour for searchable snapshot default inlc. test

* refactor snapshot state -> configuration issues as this a can be re-used for other issues

* added configuration context file

* hide replicas in cold if snapshotting

* updated new field copy

* update test coverage, test for hiding certain fields too

* added license check to client side!

* moved warning to below field again and moved hot phase searchable snapshot notice to right

* make described form field lazy if needed

* render field even when license requirement is not met

* update serializer for removing searchable_snapshot field

* handle 404 from ES when looking up * snapshot repos - we return an empty array

* address license TODO

* added tests for license check and removed license check HoC

* fix legacy jest tests

* added readme about legacy tests

* updated jest tests and fix type issues

* remove unused import

* refactor component names to have "Field" at the end

* refactor searchable snapshot to single interface def and add comment about force_merge_index option

* address stakeholder feebdack and pr comments

* update tests after latest changes

* link to force merge

* Revert "link to force merge"

This reverts commit 6c714fb.

* introduce advanced section to hot, warm and cold

* added test for correctly deserializing delete phase, and added fix

* remove unused variable

* moved fields into advanced settings

* move learn more copy below enable toggle

* fix warm phase on rollover default

* remove label space above rollover toggle

* remove unused import

* update test after fixing warm on rollover default

* removed icons in callouts in searchable snapshot field, added ability to control field toggles

* move callouts to description text

* readd warning callouts to the searchable snapshot field

* slight i18n adjustment

* made callout for actions disabled a bit smaller

* fix i18n

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
jloleysens and kibanamachine authored Dec 7, 2020
1 parent 2c7a85d commit 34be1e7
Show file tree
Hide file tree
Showing 49 changed files with 1,370 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { registerTestBed, TestBed, TestBedConfig } from '@kbn/test/jest';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public/context';
import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock';
import { licensingMock } from '../../../../licensing/public/mocks';
import { App } from '../../../public/application/app';
import { TestSubjects } from '../helpers';
import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public/context';

const breadcrumbService = createBreadcrumbsMock();

const AppWithContext = (props: any) => {
return (
<KibanaContextProvider services={{ breadcrumbService }}>
<KibanaContextProvider services={{ breadcrumbService, license: licensingMock.createLicense() }}>
<App {...props} />
</KibanaContextProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import { act } from 'react-dom/test-utils';

import { registerTestBed, TestBedConfig } from '@kbn/test/jest';

import { licensingMock } from '../../../../licensing/public/mocks';

import { EditPolicy } from '../../../public/application/sections/edit_policy';
import { DataTierAllocationType } from '../../../public/application/sections/edit_policy/types';

import { Phases as PolicyPhases } from '../../../common/types';

import { KibanaContextProvider } from '../../../public/shared_imports';
import { AppServicesContext } from '../../../public/types';
import { createBreadcrumbsMock } from '../../../public/application/services/breadcrumbs.mock';

type Phases = keyof PolicyPhases;
Expand Down Expand Up @@ -53,10 +56,16 @@ const testBedConfig: TestBedConfig = {

const breadcrumbService = createBreadcrumbsMock();

const MyComponent = (props: any) => {
const MyComponent = ({ appServicesContext, ...rest }: any) => {
return (
<KibanaContextProvider services={{ breadcrumbService }}>
<EditPolicy {...props} />
<KibanaContextProvider
services={{
breadcrumbService,
license: licensingMock.createLicense({ license: { type: 'enterprise' } }),
...appServicesContext,
}}
>
<EditPolicy {...rest} />
</KibanaContextProvider>
);
};
Expand All @@ -67,10 +76,10 @@ type SetupReturn = ReturnType<typeof setup>;

export type EditPolicyTestBed = SetupReturn extends Promise<infer U> ? U : SetupReturn;

export const setup = async () => {
const testBed = await initTestBed();
export const setup = async (arg?: { appServicesContext: Partial<AppServicesContext> }) => {
const testBed = await initTestBed(arg);

const { find, component, form } = testBed;
const { find, component, form, exists } = testBed;

const createFormToggleAction = (dataTestSubject: string) => async (checked: boolean) => {
await act(async () => {
Expand Down Expand Up @@ -128,12 +137,15 @@ export const setup = async () => {
component.update();
};

const toggleForceMerge = (phase: Phases) => createFormToggleAction(`${phase}-forceMergeSwitch`);

const setForcemergeSegmentsCount = (phase: Phases) =>
createFormSetValueAction(`${phase}-selectedForceMergeSegments`);

const setBestCompression = (phase: Phases) => createFormToggleAction(`${phase}-bestCompression`);
const createForceMergeActions = (phase: Phases) => {
const toggleSelector = `${phase}-forceMergeSwitch`;
return {
forceMergeFieldExists: () => exists(toggleSelector),
toggleForceMerge: createFormToggleAction(toggleSelector),
setForcemergeSegmentsCount: createFormSetValueAction(`${phase}-selectedForceMergeSegments`),
setBestCompression: createFormToggleAction(`${phase}-bestCompression`),
};
};

const setIndexPriority = (phase: Phases) =>
createFormSetValueAction(`${phase}-phaseIndexPriority`);
Expand Down Expand Up @@ -180,7 +192,35 @@ export const setup = async () => {
await createFormSetValueAction('warm-selectedPrimaryShardCount')(value);
};

const shrinkExists = () => exists('shrinkSwitch');

const setFreeze = createFormToggleAction('freezeSwitch');
const freezeExists = () => exists('freezeSwitch');

const createSearchableSnapshotActions = (phase: Phases) => {
const fieldSelector = `searchableSnapshotField-${phase}`;
const licenseCalloutSelector = `${fieldSelector}.searchableSnapshotDisabledDueToLicense`;
const toggleSelector = `${fieldSelector}.searchableSnapshotToggle`;

const toggleSearchableSnapshot = createFormToggleAction(toggleSelector);
return {
searchableSnapshotDisabled: () => exists(licenseCalloutSelector),
searchableSnapshotsExists: () => exists(fieldSelector),
findSearchableSnapshotToggle: () => find(toggleSelector),
searchableSnapshotDisabledDueToLicense: () =>
exists(`${fieldSelector}.searchableSnapshotDisabledDueToLicense`),
toggleSearchableSnapshot,
setSearchableSnapshot: async (value: string) => {
await toggleSearchableSnapshot(true);
act(() => {
find(`searchableSnapshotField-${phase}.searchableSnapshotCombobox`).simulate('change', [
{ label: value },
]);
});
component.update();
},
};
};

return {
...testBed,
Expand All @@ -192,10 +232,9 @@ export const setup = async () => {
setMaxDocs,
setMaxAge,
toggleRollover,
toggleForceMerge: toggleForceMerge('hot'),
setForcemergeSegments: setForcemergeSegmentsCount('hot'),
setBestCompression: setBestCompression('hot'),
...createForceMergeActions('hot'),
setIndexPriority: setIndexPriority('hot'),
...createSearchableSnapshotActions('hot'),
},
warm: {
enable: enable('warm'),
Expand All @@ -206,9 +245,8 @@ export const setup = async () => {
setSelectedNodeAttribute: setSelectedNodeAttribute('warm'),
setReplicas: setReplicas('warm'),
setShrink,
toggleForceMerge: toggleForceMerge('warm'),
setForcemergeSegments: setForcemergeSegmentsCount('warm'),
setBestCompression: setBestCompression('warm'),
shrinkExists,
...createForceMergeActions('warm'),
setIndexPriority: setIndexPriority('warm'),
},
cold: {
Expand All @@ -219,7 +257,9 @@ export const setup = async () => {
setSelectedNodeAttribute: setSelectedNodeAttribute('cold'),
setReplicas: setReplicas('cold'),
setFreeze,
freezeExists,
setIndexPriority: setIndexPriority('cold'),
...createSearchableSnapshotActions('cold'),
},
delete: {
enable: enable('delete'),
Expand Down
Loading

0 comments on commit 34be1e7

Please sign in to comment.