mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Fixes migration bug where I was deleting attributes (#115098)
## Summary During the work here: https://github.com/elastic/kibana/pull/113577 I accidentally have introduced a bug where on migration I was deleting the attributes of `ruleThrottle` and `alertThrottle` because I was not using splat correctly. Added unit and e2e tests to fix this. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
55235c61e5
commit
95e412b4a1
3 changed files with 26 additions and 1 deletions
|
@ -20,6 +20,8 @@ describe('legacy_migrations', () => {
|
|||
test('it migrates both a "ruleAlertId" and a actions array with 1 element into the references array', () => {
|
||||
const doc = {
|
||||
attributes: {
|
||||
ruleThrottle: '1d',
|
||||
alertThrottle: '1d',
|
||||
ruleAlertId: '123',
|
||||
actions: [
|
||||
{
|
||||
|
@ -37,6 +39,8 @@ describe('legacy_migrations', () => {
|
|||
)
|
||||
).toEqual({
|
||||
attributes: {
|
||||
ruleThrottle: '1d',
|
||||
alertThrottle: '1d',
|
||||
actions: [
|
||||
{
|
||||
actionRef: 'action_0',
|
||||
|
|
|
@ -245,7 +245,7 @@ export const legacyMigrateRuleAlertId = (
|
|||
return {
|
||||
...doc,
|
||||
attributes: {
|
||||
...attributesWithoutRuleAlertId.attributes,
|
||||
...attributesWithoutRuleAlertId,
|
||||
actions: actionsWithRef,
|
||||
},
|
||||
references: [...existingReferences, ...alertReferences, ...actionsReferences],
|
||||
|
|
|
@ -65,6 +65,27 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
it('migrates legacy siem-detection-engine-rule-actions and retains "ruleThrottle" and "alertThrottle" as the same attributes as before', async () => {
|
||||
const response = await es.get<{
|
||||
'siem-detection-engine-rule-actions': {
|
||||
ruleThrottle: string;
|
||||
alertThrottle: string;
|
||||
};
|
||||
}>({
|
||||
index: '.kibana',
|
||||
id: 'siem-detection-engine-rule-actions:fce024a0-0452-11ec-9b15-d13d79d162f3',
|
||||
});
|
||||
expect(response.statusCode).to.eql(200);
|
||||
|
||||
// "alertThrottle" and "ruleThrottle" should still exist
|
||||
expect(response.body._source?.['siem-detection-engine-rule-actions'].alertThrottle).to.eql(
|
||||
'7d'
|
||||
);
|
||||
expect(response.body._source?.['siem-detection-engine-rule-actions'].ruleThrottle).to.eql(
|
||||
'7d'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue