Skip to content

Commit 3ccdd79

Browse files
[SIEM][Detection Engine] Reduces flakiness within the tests using waitFor() and un-skips the tests (#72479)
## Summary * Utilizes the `waitFor` so that the tests are less flaky and more resilient * Unskips a test that was due to a regression within Elastic Search that should be fixed now * #71867 * #71814 * #71612 ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
1 parent 2771d69 commit 3ccdd79

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

x-pack/test/detection_engine_api_integration/basic/tests/add_prepackaged_rules.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import {
1313
deleteAllAlerts,
1414
deleteAllTimelines,
1515
deleteSignalsIndex,
16+
waitFor,
1617
} from '../../utils';
1718

1819
// eslint-disable-next-line import/no-default-export
1920
export default ({ getService }: FtrProviderContext): void => {
2021
const supertest = getService('supertest');
2122
const es = getService('es');
2223

23-
// FLAKY: https://github.com/elastic/kibana/issues/71867
24-
describe.skip('add_prepackaged_rules', () => {
24+
describe('add_prepackaged_rules', () => {
2525
describe('validation errors', () => {
2626
it('should give an error that the index must exist first if it does not exist before adding prepackaged rules', async () => {
2727
const { body } = await supertest
@@ -91,6 +91,16 @@ export default ({ getService }: FtrProviderContext): void => {
9191
.send()
9292
.expect(200);
9393

94+
// NOTE: I call the GET call until eventually it becomes consistent and that the number of rules to install are zero.
95+
// This is to reduce flakiness where it can for a short period of time try to install the same rule twice.
96+
await waitFor(async () => {
97+
const { body } = await supertest
98+
.get(`${DETECTION_ENGINE_PREPACKAGED_URL}/_status`)
99+
.set('kbn-xsrf', 'true')
100+
.expect(200);
101+
return body.rules_not_installed === 0;
102+
});
103+
94104
const { body } = await supertest
95105
.put(DETECTION_ENGINE_PREPACKAGED_URL)
96106
.set('kbn-xsrf', 'true')

x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import {
1313
deleteAllAlerts,
1414
deleteAllTimelines,
1515
deleteSignalsIndex,
16+
waitFor,
1617
} from '../../utils';
1718

1819
// eslint-disable-next-line import/no-default-export
1920
export default ({ getService }: FtrProviderContext): void => {
2021
const supertest = getService('supertest');
2122
const es = getService('es');
2223

23-
// FLAKY: https://github.com/elastic/kibana/issues/71814
24-
describe.skip('add_prepackaged_rules', () => {
24+
describe('add_prepackaged_rules', () => {
2525
describe('validation errors', () => {
2626
it('should give an error that the index must exist first if it does not exist before adding prepackaged rules', async () => {
2727
const { body } = await supertest
@@ -91,6 +91,16 @@ export default ({ getService }: FtrProviderContext): void => {
9191
.send()
9292
.expect(200);
9393

94+
// NOTE: I call the GET call until eventually it becomes consistent and that the number of rules to install are zero.
95+
// This is to reduce flakiness where it can for a short period of time try to install the same rule the same rule twice.
96+
await waitFor(async () => {
97+
const { body } = await supertest
98+
.get(`${DETECTION_ENGINE_PREPACKAGED_URL}/_status`)
99+
.set('kbn-xsrf', 'true')
100+
.expect(200);
101+
return body.rules_not_installed === 0;
102+
});
103+
94104
const { body } = await supertest
95105
.put(DETECTION_ENGINE_PREPACKAGED_URL)
96106
.set('kbn-xsrf', 'true')

x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export default ({ getService }: FtrProviderContext): void => {
2929
const supertest = getService('supertest');
3030
const es = getService('es');
3131

32-
// Failing ES promotion: https://github.com/elastic/kibana/issues/71612
33-
describe.skip('create_rules_bulk', () => {
32+
describe('create_rules_bulk', () => {
3433
describe('validation errors', () => {
3534
it('should give a 200 even if the index does not exist as all bulks return a 200 but have an error of 409 bad request in the body', async () => {
3635
const { body } = await supertest

0 commit comments

Comments
 (0)