forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restoring snoozeEndTime to AlertAttributesExcludedFromAAD (elastic#13…
…5663) * Restoring snoozeEndTime to AlertAttributesExcludedFromAAD * Apply suggestions from code review Co-authored-by: Gidi Meir Morris <github@gidi.io> * Temp fix migration * New way to do migrations * Add two scenarios * Skip functional test * Revert some archive changes Co-authored-by: Ying Mao <ying.mao@elastic.co> Co-authored-by: Gidi Meir Morris <github@gidi.io>
- Loading branch information
1 parent
c0a629b
commit 2d29934
Showing
7 changed files
with
25,745 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations/8_2_0.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
import type { RawRule } from '@kbn/alerting-plugin/server/types'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function createGetTests({ getService }: FtrProviderContext) { | ||
const es = getService('es'); | ||
const retry = getService('retry'); | ||
const supertest = getService('supertest'); | ||
const esArchiver = getService('esArchiver'); | ||
|
||
// Race condition between task manager running tasks and Kibana running the migrations after loading the ES Archive | ||
describe.skip('migrates 8.2.0 rules to the latest version approriately', () => { | ||
let testStart: null | number = null; | ||
before(async () => { | ||
testStart = Date.now(); | ||
await esArchiver.load('x-pack/test/functional/es_archives/alerting/8_2_0'); | ||
}); | ||
|
||
after(async () => { | ||
await esArchiver.unload('x-pack/test/functional/es_archives/alerting/8_2_0'); | ||
}); | ||
|
||
describe('rule with null snoozeEndTime value', async () => { | ||
it('has snoozeEndTime removed', async () => { | ||
const response = await es.get<{ alert: RawRule }>( | ||
{ | ||
index: '.kibana', | ||
id: 'alert:bdfce750-fba0-11ec-9157-2f379249da99', | ||
}, | ||
{ meta: true } | ||
); | ||
|
||
expect(response.statusCode).to.equal(200); | ||
expect(response.body._source?.alert?.snoozeEndTime).to.be(undefined); | ||
expect(response.body._source?.alert?.snoozeSchedule).not.to.be(undefined); | ||
|
||
const snoozeSchedule = response.body._source?.alert.snoozeSchedule!; | ||
expect(snoozeSchedule.length).to.eql(0); | ||
}); | ||
|
||
it('runs successfully after migration', async () => { | ||
await retry.try(async () => { | ||
const { body: rule } = await supertest.get( | ||
`/api/alerting/rule/bdfce750-fba0-11ec-9157-2f379249da99` | ||
); | ||
expect(Date.parse(rule.execution_status.last_execution_date)).to.be.greaterThan( | ||
testStart! | ||
); | ||
expect(rule.execution_status.status).to.be('ok'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('rules with snoozeEndTime value', async () => { | ||
it('has snoozeEndTime migrated to snoozeSchedule', async () => { | ||
const response = await es.get<{ alert: RawRule }>( | ||
{ | ||
index: '.kibana', | ||
id: 'alert:402084f0-fbb8-11ec-856c-39466bd4c433', | ||
}, | ||
{ meta: true } | ||
); | ||
|
||
expect(response.statusCode).to.equal(200); | ||
expect(response.body._source?.alert?.snoozeEndTime).to.be(undefined); | ||
expect(response.body._source?.alert?.snoozeSchedule).not.to.be(undefined); | ||
|
||
const snoozeSchedule = response.body._source?.alert.snoozeSchedule!; | ||
expect(snoozeSchedule.length).to.eql(1); | ||
}); | ||
|
||
it('runs successfully after migration', async () => { | ||
await retry.try(async () => { | ||
const { body: rule } = await supertest.get( | ||
`/api/alerting/rule/402084f0-fbb8-11ec-856c-39466bd4c433` | ||
); | ||
expect(Date.parse(rule.execution_status.last_execution_date)).to.be.greaterThan( | ||
testStart! | ||
); | ||
expect(rule.execution_status.status).to.be('ok'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
15 changes: 15 additions & 0 deletions
15
x-pack/test/alerting_api_integration/spaces_only/tests/alerting/migrations/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function migrationTests({ loadTestFile, getService }: FtrProviderContext) { | ||
describe('Migrations', () => { | ||
loadTestFile(require.resolve('./8_2_0')); | ||
}); | ||
} |
22,034 changes: 22,034 additions & 0 deletions
22,034
x-pack/test/functional/es_archives/alerting/8_2_0/data.json
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.