Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ILM] Add warnings for managed system policies #132269

Merged
merged 11 commits into from
May 20, 2022

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

Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ export const POLICY_WITH_KNOWN_AND_UNKNOWN_FIELDS = {
name: POLICY_NAME,
} as any as PolicyFromES;

export const POLICY_MANAGED_BY_ES: PolicyFromES = {
version: 1,
modifiedDate: Date.now().toString(),
policy: {
name: POLICY_NAME,
phases: {
hot: {
min_age: '0ms',
actions: {
rollover: {
max_age: '30d',
max_primary_shard_size: '50gb',
},
},
},
},
_meta: {
managed: true,
},
},
name: POLICY_NAME,
};

export const getGeneratedPolicies = (): PolicyFromES[] => {
const policy = {
phases: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils';
import { TestBed } from '@kbn/test-jest-helpers';
import { setupEnvironment } from '../../helpers';
import { initTestBed } from '../init_test_bed';
import { getDefaultHotPhasePolicy, POLICY_NAME } from '../constants';
import { getDefaultHotPhasePolicy, POLICY_NAME, POLICY_MANAGED_BY_ES } from '../constants';

describe('<EditPolicy /> edit warning', () => {
let testBed: TestBed;
Expand Down Expand Up @@ -54,6 +54,19 @@ describe('<EditPolicy /> edit warning', () => {
expect(exists('editWarning')).toBe(true);
});

test('an edit warning callout is shown for an existing, managed policy', async () => {
httpRequestsMockHelpers.setLoadPolicies([POLICY_MANAGED_BY_ES]);

await act(async () => {
testBed = await initTestBed(httpSetup);
});
const { exists, component } = testBed;
component.update();

expect(exists('editWarning')).toBe(true);
expect(exists('editManagedPolicyCallOut')).toBe(true);
});

test('no indices link if no indices', async () => {
httpRequestsMockHelpers.setLoadPolicies([
{ ...getDefaultHotPhasePolicy(POLICY_NAME), indices: [] },
Expand Down
Loading