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] Policy phases redesign #88671

Merged
merged 32 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0245480
Phases redesign
yuliacech Jan 15, 2021
644cc52
Title and name field layout
yuliacech Jan 15, 2021
9cc164e
Active highlight wip
yuliacech Jan 15, 2021
a8c32f4
Copy comments
yuliacech Jan 15, 2021
a649f7f
Updated data allocation dropdown
yuliacech Jan 18, 2021
6a4894c
Min age error message
yuliacech Jan 18, 2021
811d7da
Fixed tests
yuliacech Jan 19, 2021
1fb4236
Fixed edit policy integration tests
yuliacech Jan 19, 2021
a5d6f42
Fixed more tests
yuliacech Jan 19, 2021
2248eeb
Cleaned up test files
yuliacech Jan 19, 2021
009efef
Use hotProperty instead of a string
yuliacech Jan 19, 2021
b17f99d
Clean up in phase component
yuliacech Jan 19, 2021
2078edd
Fixed i18n files
yuliacech Jan 19, 2021
ea1f318
Updated optional fields
yuliacech Jan 19, 2021
d9d4d8b
Updated aria attributes after running axe tests
yuliacech Jan 19, 2021
4a8fd7e
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 19, 2021
6796d7d
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 20, 2021
04da014
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 25, 2021
36db34a
Added review suggestions
yuliacech Jan 25, 2021
13cc606
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 25, 2021
4906392
Reversed data allocation field changes
yuliacech Jan 25, 2021
2ecac59
Fixed type error
yuliacech Jan 25, 2021
87a1ba6
Reversed on/off label and prepend input label
yuliacech Jan 25, 2021
0e6fcdc
Deleted property consts from phases components
yuliacech Jan 25, 2021
2338c94
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 26, 2021
983808f
Removed not needed i18n consts and added i18n where missing
yuliacech Jan 26, 2021
09d0f00
Merge branch 'master' into ilm_phase_blocks
yuliacech Jan 27, 2021
e2f26b3
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 27, 2021
2b47f0d
Fixed merge conflicts with master
yuliacech Jan 27, 2021
6441c70
Merge remote-tracking branch 'origin/ilm_phase_blocks' into ilm_phase…
yuliacech Jan 27, 2021
2c62c4b
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 27, 2021
697c925
Merge branch 'master' into ilm_phase_blocks
kibanamachine Jan 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const PERCENT_SIGN_NAME = 'test%';
const PERCENT_SIGN_WITH_OTHER_CHARS_NAME = 'test%#';
const PERCENT_SIGN_25_SEQUENCE = 'test%25';

const createPolicyTitle = 'Create Policy';
const editPolicyTitle = 'Edit Policy';

window.scrollTo = jest.fn();

describe('<App />', () => {
Expand All @@ -43,7 +46,7 @@ describe('<App />', () => {
await actions.clickCreatePolicyButton();
component.update();

expect(testBed.find('policyTitle').text()).toBe(`Create an index lifecycle policy`);
expect(testBed.find('policyTitle').text()).toBe(createPolicyTitle);
expect(testBed.find('policyNameField').props().value).toBe('');
});

Expand All @@ -59,7 +62,7 @@ describe('<App />', () => {
await actions.clickCreatePolicyButton();
component.update();

expect(testBed.find('policyTitle').text()).toBe(`Create an index lifecycle policy`);
expect(testBed.find('policyTitle').text()).toBe(createPolicyTitle);
expect(testBed.find('policyNameField').props().value).toBe('');
});
});
Expand All @@ -80,9 +83,7 @@ describe('<App />', () => {
await actions.clickPolicyNameLink();
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${SPECIAL_CHARS_NAME}`
);
expect(testBed.find('policyTitle').text()).toBe(`${editPolicyTitle} ${SPECIAL_CHARS_NAME}`);
});

test('loading edit policy page url works', async () => {
Expand All @@ -93,9 +94,7 @@ describe('<App />', () => {
const { component } = testBed;
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${SPECIAL_CHARS_NAME}`
);
expect(testBed.find('policyTitle').text()).toBe(`${editPolicyTitle} ${SPECIAL_CHARS_NAME}`);
});

// using double encoding to counteract react-router's v5 internal decodeURI call
Expand All @@ -108,9 +107,7 @@ describe('<App />', () => {
const { component } = testBed;
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${SPECIAL_CHARS_NAME}`
);
expect(testBed.find('policyTitle').text()).toBe(`${editPolicyTitle} ${SPECIAL_CHARS_NAME}`);
});
});

Expand All @@ -127,9 +124,7 @@ describe('<App />', () => {
const { component } = testBed;
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_NAME}`
);
expect(testBed.find('policyTitle').text()).toBe(`${editPolicyTitle} ${PERCENT_SIGN_NAME}`);
});

test('loading edit policy page url with double encoding works', async () => {
Expand All @@ -140,9 +135,7 @@ describe('<App />', () => {
const { component } = testBed;
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_NAME}`
);
expect(testBed.find('policyTitle').text()).toBe(`${editPolicyTitle} ${PERCENT_SIGN_NAME}`);
});
});

Expand All @@ -165,7 +158,7 @@ describe('<App />', () => {
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_WITH_OTHER_CHARS_NAME}`
`${editPolicyTitle} ${PERCENT_SIGN_WITH_OTHER_CHARS_NAME}`
);
});

Expand All @@ -179,7 +172,7 @@ describe('<App />', () => {

// known issue https://github.com/elastic/kibana/issues/82440
expect(testBed.find('policyTitle').text()).not.toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_WITH_OTHER_CHARS_NAME}`
`${editPolicyTitle} ${PERCENT_SIGN_WITH_OTHER_CHARS_NAME}`
);
});

Expand All @@ -194,7 +187,7 @@ describe('<App />', () => {
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_WITH_OTHER_CHARS_NAME}`
`${editPolicyTitle} ${PERCENT_SIGN_WITH_OTHER_CHARS_NAME}`
);
});
});
Expand All @@ -216,7 +209,7 @@ describe('<App />', () => {
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_25_SEQUENCE}`
`${editPolicyTitle} ${PERCENT_SIGN_25_SEQUENCE}`
);
});

Expand All @@ -230,7 +223,7 @@ describe('<App />', () => {

// known issue https://github.com/elastic/kibana/issues/82440
expect(testBed.find('policyTitle').text()).not.toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_25_SEQUENCE}`
`${editPolicyTitle} ${PERCENT_SIGN_25_SEQUENCE}`
);
});

Expand All @@ -245,7 +238,7 @@ describe('<App />', () => {
component.update();

expect(testBed.find('policyTitle').text()).toBe(
`Edit index lifecycle policy ${PERCENT_SIGN_25_SEQUENCE}`
`${editPolicyTitle} ${PERCENT_SIGN_25_SEQUENCE}`
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
component.update();
};

const createFormCheckboxAction = (dataTestSubject: string) => async (checked: boolean) => {
await act(async () => {
form.selectCheckBox(dataTestSubject, checked);
});
component.update();
};

function createFormSetValueAction<V extends string = string>(dataTestSubject: string) {
return async (value: V) => {
await act(async () => {
Expand Down Expand Up @@ -145,17 +152,21 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
forceMergeFieldExists: () => exists(toggleSelector),
toggleForceMerge: createFormToggleAction(toggleSelector),
setForcemergeSegmentsCount: createFormSetValueAction(`${phase}-selectedForceMergeSegments`),
setBestCompression: createFormToggleAction(`${phase}-bestCompression`),
setBestCompression: createFormCheckboxAction(`${phase}-bestCompression`),
};
};

const setIndexPriority = (phase: Phases) =>
createFormSetValueAction(`${phase}-phaseIndexPriority`);
const createIndexPriorityActions = (phase: Phases) => {
const toggleSelector = `${phase}-indexPrioritySwitch`;
return {
indexPriorityExists: () => exists(toggleSelector),
toggleIndexPriority: createFormToggleAction(toggleSelector),
setIndexPriority: createFormSetValueAction(`${phase}-indexPriority`),
};
};

const enable = (phase: Phases) => createFormToggleAction(`enablePhaseSwitch-${phase}`);

const warmPhaseOnRollover = createFormToggleAction(`warm-warmPhaseOnRollover`);

const setMinAgeValue = (phase: Phases) => createFormSetValueAction(`${phase}-selectedMinimumAge`);

const setMinAgeUnits = (phase: Phases) =>
Expand Down Expand Up @@ -189,13 +200,15 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
await createFormSetValueAction(`${phase}-selectedReplicaCount`)(value);
};

const setShrink = (phase: Phases) => async (value: string) => {
await createFormToggleAction(`${phase}-shrinkSwitch`)(true);
await createFormSetValueAction(`${phase}-selectedPrimaryShardCount`)(value);
const createShrinkActions = (phase: Phases) => {
const toggleSelector = `${phase}-shrinkSwitch`;
return {
shrinkExists: () => exists(toggleSelector),
toggleShrink: createFormToggleAction(toggleSelector),
setShrink: createFormSetValueAction(`${phase}-primaryShardCount`),
};
};

const shrinkExists = (phase: Phases) => () => exists(`${phase}-shrinkSwitch`);

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

Expand Down Expand Up @@ -243,25 +256,22 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
toggleRollover,
toggleDefaultRollover,
...createForceMergeActions('hot'),
setIndexPriority: setIndexPriority('hot'),
setShrink: setShrink('hot'),
shrinkExists: shrinkExists('hot'),
...createIndexPriorityActions('hot'),
...createShrinkActions('hot'),
setReadonly: setReadonly('hot'),
...createSearchableSnapshotActions('hot'),
},
warm: {
enable: enable('warm'),
warmPhaseOnRollover,
setMinAgeValue: setMinAgeValue('warm'),
setMinAgeUnits: setMinAgeUnits('warm'),
setDataAllocation: setDataAllocation('warm'),
setSelectedNodeAttribute: setSelectedNodeAttribute('warm'),
setReplicas: setReplicas('warm'),
setShrink: setShrink('warm'),
shrinkExists: shrinkExists('warm'),
...createShrinkActions('warm'),
...createForceMergeActions('warm'),
setReadonly: setReadonly('warm'),
setIndexPriority: setIndexPriority('warm'),
...createIndexPriorityActions('warm'),
},
cold: {
enable: enable('cold'),
Expand All @@ -272,7 +282,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
setReplicas: setReplicas('cold'),
setFreeze,
freezeExists,
setIndexPriority: setIndexPriority('cold'),
...createIndexPriorityActions('cold'),
...createSearchableSnapshotActions('cold'),
},
delete: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ describe('<EditPolicy />', () => {
max_size: '50gb',
unknown_setting: 123, // Made up setting that should stay preserved
},
set_priority: {
priority: 100,
},
},
min_age: '0ms',
},
Expand Down Expand Up @@ -126,8 +123,10 @@ describe('<EditPolicy />', () => {
await actions.hot.toggleForceMerge(true);
await actions.hot.setForcemergeSegmentsCount('123');
await actions.hot.setBestCompression(true);
await actions.hot.toggleShrink(true);
await actions.hot.setShrink('2');
await actions.hot.setReadonly(true);
await actions.hot.toggleIndexPriority(true);
await actions.hot.setIndexPriority('123');

await actions.savePolicy();
Expand Down Expand Up @@ -186,13 +185,7 @@ describe('<EditPolicy />', () => {
const hotActions = policy.phases.hot.actions;
const rolloverAction = hotActions.rollover;
expect(rolloverAction).toBe(undefined);
expect(hotActions).toMatchInlineSnapshot(`
Object {
"set_priority": Object {
"priority": 100,
},
}
`);
expect(hotActions).toMatchInlineSnapshot(`Object {}`);
});

test('enabling searchable snapshot should hide force merge, freeze and shrink in subsequent phases', async () => {
Expand Down Expand Up @@ -260,6 +253,7 @@ describe('<EditPolicy />', () => {
"priority": 50,
},
},
"min_age": "0ms",
}
`);
});
Expand All @@ -270,6 +264,7 @@ describe('<EditPolicy />', () => {
await actions.warm.setDataAllocation('node_attrs');
await actions.warm.setSelectedNodeAttribute('test:123');
await actions.warm.setReplicas('123');
await actions.warm.toggleShrink(true);
await actions.warm.setShrink('123');
await actions.warm.toggleForceMerge(true);
await actions.warm.setForcemergeSegmentsCount('123');
Expand All @@ -290,9 +285,6 @@ describe('<EditPolicy />', () => {
"max_age": "30d",
"max_size": "50gb",
},
"set_priority": Object {
"priority": 100,
},
},
"min_age": "0ms",
},
Expand All @@ -316,24 +308,12 @@ describe('<EditPolicy />', () => {
"number_of_shards": 123,
},
},
"min_age": "0ms",
},
},
}
`);
});

test('setting warm phase on rollover to "false"', async () => {
const { actions } = testBed;
await actions.warm.enable(true);
await actions.warm.warmPhaseOnRollover(false);
await actions.warm.setMinAgeValue('123');
await actions.warm.setMinAgeUnits('d');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
const warmPhaseMinAge = JSON.parse(JSON.parse(latestRequest.requestBody).body).phases.warm
.min_age;
expect(warmPhaseMinAge).toBe('123d');
});
});

describe('policy with include and exclude', () => {
Expand Down Expand Up @@ -458,9 +438,6 @@ describe('<EditPolicy />', () => {
"max_age": "30d",
"max_size": "50gb",
},
"set_priority": Object {
"priority": 100,
},
},
"min_age": "0ms",
},
Expand Down Expand Up @@ -662,9 +639,6 @@ describe('<EditPolicy />', () => {
"allocate": Object {
"number_of_replicas": 123,
},
"set_priority": Object {
"priority": 50,
},
}
`);
});
Expand Down
Loading