-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Migrate Warm phase to Form Lib #81323
Changes from 13 commits
d844b12
e867ffe
d349eee
779534e
5bb0be9
98bf14b
0121411
d7896d7
805a55d
4f2a615
2ed016f
5aed5cf
271351e
db3894d
7b2f0ba
1affb8e
97da20e
2befd67
96e45ae
cb03877
6109d3a
750992e
b85f492
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import { POLICY_NAME } from './constants'; | |
import { TestSubjects } from '../helpers'; | ||
|
||
import { EditPolicy } from '../../../public/application/sections/edit_policy'; | ||
import { DataTierAllocationType } from '../../../public/application/sections/edit_policy/types'; | ||
|
||
jest.mock('@elastic/eui', () => { | ||
const original = jest.requireActual('@elastic/eui'); | ||
|
@@ -54,6 +55,22 @@ export const setup = async () => { | |
|
||
const { find, component } = testBed; | ||
|
||
const createFormClickAction = (dataTestSubject: string) => async () => { | ||
await act(async () => { | ||
find(dataTestSubject).simulate('click'); | ||
}); | ||
component.update(); | ||
}; | ||
|
||
function createFormSetValueAction<V = string>(dataTestSubject: string) { | ||
return async (value: V) => { | ||
await act(async () => { | ||
find(dataTestSubject).simulate('change', { target: { value } }); | ||
}); | ||
component.update(); | ||
}; | ||
} | ||
|
||
const setWaitForSnapshotPolicy = async (snapshotPolicyName: string) => { | ||
act(() => { | ||
find('snapshotPolicyCombobox').simulate('change', [{ label: snapshotPolicyName }]); | ||
|
@@ -68,12 +85,7 @@ export const setup = async () => { | |
component.update(); | ||
}; | ||
|
||
const toggleRollover = async (checked: boolean) => { | ||
await act(async () => { | ||
find('rolloverSwitch').simulate('click', { target: { checked } }); | ||
}); | ||
component.update(); | ||
}; | ||
const toggleRollover = createFormClickAction('rolloverSwitch'); | ||
|
||
const setMaxSize = async (value: string, units?: string) => { | ||
await act(async () => { | ||
|
@@ -87,12 +99,7 @@ export const setup = async () => { | |
component.update(); | ||
}; | ||
|
||
const setMaxDocs = async (value: string) => { | ||
await act(async () => { | ||
find('hot-selectedMaxDocuments').simulate('change', { target: { value } }); | ||
}); | ||
component.update(); | ||
}; | ||
const setMaxDocs = createFormSetValueAction('hot-selectedMaxDocuments'); | ||
|
||
const setMaxAge = async (value: string, units?: string) => { | ||
await act(async () => { | ||
|
@@ -104,32 +111,56 @@ export const setup = async () => { | |
component.update(); | ||
}; | ||
|
||
const toggleForceMerge = (phase: string) => async (checked: boolean) => { | ||
await act(async () => { | ||
find(`${phase}-forceMergeSwitch`).simulate('click', { target: { checked } }); | ||
const toggleForceMerge = (phase: string) => createFormClickAction(`${phase}-forceMergeSwitch`); | ||
|
||
const setForcemergeSegmentsCount = (phase: string) => | ||
createFormSetValueAction(`${phase}-selectedForceMergeSegments`); | ||
|
||
const setBestCompression = (phase: string) => createFormClickAction(`${phase}-bestCompression`); | ||
|
||
const setIndexPriority = (phase: string) => | ||
createFormSetValueAction(`${phase}-phaseIndexPriority`); | ||
|
||
const enable = (phase: string) => createFormClickAction(`enablePhaseSwitch-${phase}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should we type the phase here and below? |
||
|
||
const warmPhaseOnRollover = createFormClickAction(`warm-warmPhaseOnRollover`); | ||
|
||
const setMinAgeValue = (phase: string) => createFormSetValueAction(`${phase}-selectedMinimumAge`); | ||
|
||
const setMinAgeUnits = (phase: string) => | ||
createFormSetValueAction(`${phase}-selectedMinimumAgeUnits`); | ||
|
||
const setDataAllocation = (phase: string) => async (value: DataTierAllocationType) => { | ||
act(() => { | ||
find(`${phase}-dataTierAllocationControls.dataTierSelect`).simulate('click'); | ||
}); | ||
component.update(); | ||
}; | ||
|
||
const setForcemergeSegmentsCount = (phase: string) => async (value: string) => { | ||
await act(async () => { | ||
find(`${phase}-selectedForceMergeSegments`).simulate('change', { target: { value } }); | ||
switch (value) { | ||
case 'node_roles': | ||
find(`${phase}-dataTierAllocationControls.defaultDataAllocationOption`).simulate('click'); | ||
break; | ||
case 'node_attrs': | ||
find(`${phase}-dataTierAllocationControls.customDataAllocationOption`).simulate('click'); | ||
break; | ||
default: | ||
find(`${phase}-dataTierAllocationControls.noneDataAllocationOption`).simulate('click'); | ||
} | ||
}); | ||
component.update(); | ||
}; | ||
|
||
const setBestCompression = (phase: string) => async (checked: boolean) => { | ||
await act(async () => { | ||
find(`${phase}-bestCompression`).simulate('click', { target: { checked } }); | ||
}); | ||
component.update(); | ||
const setSelectedNodeAttribute = (phase: string) => | ||
createFormSetValueAction(`${phase}-selectedNodeAttrs`); | ||
|
||
const setReplicas = async (value: string) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would happen if we call twice this method in a test? It seems that the first time the switch would be "on" and the second time "off" and we would not be able to set thevalue. I think this is why we had the option to pass the I think that for toggles we could use the handler from form.toggleEuiSwitch('warm-setReplicasSwitch', true); WDYT? |
||
await createFormClickAction('warm-setReplicasSwitch')(); | ||
await createFormSetValueAction('warm-selectedReplicaCount')(value); | ||
}; | ||
|
||
const setIndexPriority = (phase: string) => async (value: string) => { | ||
await act(async () => { | ||
find(`${phase}-phaseIndexPriority`).simulate('change', { target: { value } }); | ||
}); | ||
component.update(); | ||
const setShrink = async (value: string) => { | ||
await createFormClickAction('shrinkSwitch')(); | ||
await createFormSetValueAction('warm-selectedPrimaryShardCount')(value); | ||
}; | ||
|
||
return { | ||
|
@@ -147,6 +178,20 @@ export const setup = async () => { | |
setBestCompression: setBestCompression('hot'), | ||
setIndexPriority: setIndexPriority('hot'), | ||
}, | ||
warm: { | ||
enable: enable('warm'), | ||
warmPhaseOnRollover, | ||
setMinAgeValue: setMinAgeValue('warm'), | ||
setMinAgeUnits: setMinAgeUnits('warm'), | ||
setDataAllocation: setDataAllocation('warm'), | ||
setSelectedNodeAttribute: setSelectedNodeAttribute('warm'), | ||
setReplicas, | ||
setShrink, | ||
toggleForceMerge: toggleForceMerge('warm'), | ||
setForcemergeSegments: setForcemergeSegmentsCount('warm'), | ||
setBestCompression: setBestCompression('warm'), | ||
setIndexPriority: setIndexPriority('warm'), | ||
}, | ||
}, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you could use the
form
helper from thetestBed
object