-
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
Enable TSDB downsampling ILM configuration #138748
Changes from all commits
5d7a792
1094f89
3bcb2ba
46bf380
0fa4a3e
1216030
dc1d06f
8acc8ca
cd03455
52628b6
decd7bc
2f7fb75
9239b3a
aa43923
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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { act } from 'react-dom/test-utils'; | ||
import { i18nTexts } from '../../../../public/application/sections/edit_policy/i18n_texts'; | ||
|
||
import { PhaseWithDownsample } from '../../../../common/types'; | ||
import { setupEnvironment } from '../../helpers'; | ||
import { setupValidationTestBed, ValidationTestBed } from './validation.helpers'; | ||
|
||
describe('<EditPolicy /> downsample interval validation', () => { | ||
let testBed: ValidationTestBed; | ||
let actions: ValidationTestBed['actions']; | ||
const { httpSetup, httpRequestsMockHelpers } = setupEnvironment(); | ||
|
||
beforeAll(() => { | ||
jest.useFakeTimers(); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
httpRequestsMockHelpers.setDefaultResponses(); | ||
httpRequestsMockHelpers.setLoadPolicies([]); | ||
|
||
await act(async () => { | ||
testBed = await setupValidationTestBed(httpSetup); | ||
}); | ||
|
||
const { component } = testBed; | ||
component.update(); | ||
({ actions } = testBed); | ||
await actions.setPolicyName('mypolicy'); | ||
}); | ||
|
||
[ | ||
{ | ||
name: `doesn't allow empty interval`, | ||
value: '', | ||
error: [i18nTexts.editPolicy.errors.numberRequired], | ||
}, | ||
{ | ||
name: `doesn't allow 0 for interval`, | ||
value: '0', | ||
error: [i18nTexts.editPolicy.errors.numberGreatThan0Required], | ||
}, | ||
{ | ||
name: `doesn't allow -1 for interval`, | ||
value: '-1', | ||
error: [i18nTexts.editPolicy.errors.numberGreatThan0Required], | ||
}, | ||
{ | ||
name: `doesn't allow decimals for timing (with dot)`, | ||
value: '5.5', | ||
error: [i18nTexts.editPolicy.errors.integerRequired], | ||
}, | ||
{ | ||
name: `doesn't allow decimals for timing (with comma)`, | ||
value: '5,5', | ||
error: [i18nTexts.editPolicy.errors.integerRequired], | ||
}, | ||
].forEach((testConfig: { name: string; value: string; error: string[] }) => { | ||
(['hot', 'warm', 'cold'] as PhaseWithDownsample[]).forEach((phase: PhaseWithDownsample) => { | ||
const { name, value, error } = testConfig; | ||
test(`${phase}: ${name}`, async () => { | ||
if (phase !== 'hot') { | ||
await actions.togglePhase(phase); | ||
} | ||
|
||
await actions[phase].downsample.toggle(); | ||
|
||
// 1. We first set as dummy value to have a starting min_age value | ||
await actions[phase].downsample.setDownsampleInterval('111'); | ||
// 2. At this point we are sure there will be a change of value and that any validation | ||
// will be displayed under the field. | ||
await actions[phase].downsample.setDownsampleInterval(value); | ||
|
||
actions.errors.waitForValidation(); | ||
|
||
actions.errors.expectMessages(error); | ||
}); | ||
}); | ||
}); | ||
|
||
test('should validate an interval is greater or multiple than previous phase interval', async () => { | ||
await actions.togglePhase('warm'); | ||
await actions.togglePhase('cold'); | ||
|
||
await actions.hot.downsample.toggle(); | ||
await actions.hot.downsample.setDownsampleInterval('60', 'm'); | ||
|
||
await actions.warm.downsample.toggle(); | ||
await actions.warm.downsample.setDownsampleInterval('1', 'h'); | ||
|
||
actions.errors.waitForValidation(); | ||
actions.errors.expectMessages( | ||
['Must be greater than and a multiple of the hot phase value (60m)'], | ||
'warm' | ||
); | ||
|
||
await actions.cold.downsample.toggle(); | ||
await actions.cold.downsample.setDownsampleInterval('90', 'm'); | ||
actions.errors.waitForValidation(); | ||
actions.errors.expectMessages( | ||
['Must be greater than and a multiple of the warm phase value (1h)'], | ||
'cold' | ||
); | ||
|
||
// disable warm phase; | ||
await actions.togglePhase('warm'); | ||
// TODO: there is a bug that disabling a phase doesn't trigger downsample validation in other phases, | ||
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. Is there a separate issue open to address this? Will the validation work as expected on save? 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.
Yes! the form state stays in the error state until the validation is triggered again.
I wanted to leave a TODO comment to point this out as a known bug/edge case but didn't think this was worth an issue 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. I'll see if I can fix this with low effort: #140628 |
||
// users can work around it by changing the value | ||
await actions.cold.downsample.setDownsampleInterval('120', 'm'); | ||
actions.errors.waitForValidation(); | ||
actions.errors.expectMessages([], 'cold'); | ||
|
||
await actions.cold.downsample.setDownsampleInterval('90', 'm'); | ||
actions.errors.waitForValidation(); | ||
actions.errors.expectMessages( | ||
['Must be greater than and a multiple of the hot phase value (60m)'], | ||
'cold' | ||
); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { TestBed } from '@kbn/test-jest-helpers'; | ||
import { act } from 'react-dom/test-utils'; | ||
import { Phase } from '../../../../common/types'; | ||
import { createFormToggleAction } from '..'; | ||
|
||
const createSetDownsampleIntervalAction = | ||
(testBed: TestBed, phase: Phase) => async (value: string, units?: string) => { | ||
const { find, component } = testBed; | ||
|
||
await act(async () => { | ||
find(`${phase}-downsampleFixedInterval`).simulate('change', { target: { value } }); | ||
}); | ||
component.update(); | ||
|
||
if (units) { | ||
act(() => { | ||
find(`${phase}-downsampleFixedIntervalUnits.show-filters-button`).simulate('click'); | ||
}); | ||
component.update(); | ||
|
||
act(() => { | ||
find(`${phase}-downsampleFixedIntervalUnits.filter-option-${units}`).simulate('click'); | ||
}); | ||
component.update(); | ||
} | ||
}; | ||
|
||
export const createDownsampleActions = (testBed: TestBed, phase: Phase) => { | ||
const { exists } = testBed; | ||
return { | ||
downsample: { | ||
exists: () => exists(`${phase}-downsampleSwitch`), | ||
toggle: createFormToggleAction(testBed, `${phase}-downsampleSwitch`), | ||
setDownsampleInterval: createSetDownsampleIntervalAction(testBed, phase), | ||
}, | ||
}; | ||
}; |
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.
Thanks for adding these tests 👍