Skip to content

Commit

Permalink
[Security Solution][Detections] Fix flaky threshold API tests (#97768) (
Browse files Browse the repository at this point in the history
#97898)

* Explicitly refreshes signals index for threshold api tests to prevent flakiness

* Unskip test suite

Co-authored-by: Marshall Main <55718608+marshallmain@users.noreply.github.com>
  • Loading branch information
kibanamachine and marshallmain authored Apr 22, 2021
1 parent e5b8452 commit c95fbe5
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
createSignalsIndex,
deleteAllAlerts,
deleteSignalsIndex,
getOpenSignals,
getRuleForSignalTesting,
getSignalsByIds,
getSignalsByRuleIds,
Expand All @@ -39,9 +40,9 @@ export const ID = 'BhbXBmkBR346wHgn4PeZ';
export default ({ getService }: FtrProviderContext) => {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
const es = getService('es');

// FLAKY: https://github.com/elastic/kibana/issues/97584
describe.skip('Generating signals from source indexes', () => {
describe('Generating signals from source indexes', () => {
beforeEach(async () => {
await createSignalsIndex(supertest);
});
Expand Down Expand Up @@ -728,9 +729,8 @@ export default ({ getService }: FtrProviderContext) => {
],
},
};
const { id } = await createRule(supertest, rule);
await waitForRuleSuccessOrStatus(supertest, id);
const signalsOpen = await getSignalsByRuleIds(supertest, [ruleId]);
const createdRule = await createRule(supertest, rule);
const signalsOpen = await getOpenSignals(supertest, es, createdRule);
expect(signalsOpen.hits.hits.length).eql(0);
});

Expand All @@ -753,9 +753,8 @@ export default ({ getService }: FtrProviderContext) => {
],
},
};
const { id } = await createRule(supertest, rule);
await waitForRuleSuccessOrStatus(supertest, id);
const signalsOpen = await getSignalsByRuleIds(supertest, [ruleId]);
const createdRule = await createRule(supertest, rule);
const signalsOpen = await getOpenSignals(supertest, es, createdRule);
expect(signalsOpen.hits.hits.length).eql(0);
});

Expand All @@ -778,9 +777,8 @@ export default ({ getService }: FtrProviderContext) => {
],
},
};
const { id } = await createRule(supertest, rule);
await waitForRuleSuccessOrStatus(supertest, id);
const signalsOpen = await getSignalsByRuleIds(supertest, [ruleId]);
const createdRule = await createRule(supertest, rule);
const signalsOpen = await getOpenSignals(supertest, es, createdRule);
expect(signalsOpen.hits.hits.length).eql(1);
const signal = signalsOpen.hits.hits[0];
expect(signal._source.signal.threshold_result).eql({
Expand Down Expand Up @@ -814,9 +812,8 @@ export default ({ getService }: FtrProviderContext) => {
value: 22,
},
};
const { id } = await createRule(supertest, rule);
await waitForRuleSuccessOrStatus(supertest, id);
const signalsOpen = await getSignalsByRuleIds(supertest, [ruleId]);
const createdRule = await createRule(supertest, rule);
const signalsOpen = await getOpenSignals(supertest, es, createdRule);
expect(signalsOpen.hits.hits.length).eql(0);
});

Expand All @@ -833,9 +830,8 @@ export default ({ getService }: FtrProviderContext) => {
value: 21,
},
};
const { id } = await createRule(supertest, rule);
await waitForRuleSuccessOrStatus(supertest, id);
const signalsOpen = await getSignalsByRuleIds(supertest, [ruleId]);
const createdRule = await createRule(supertest, rule);
const signalsOpen = await getOpenSignals(supertest, es, createdRule);
expect(signalsOpen.hits.hits.length).eql(1);
const signal = signalsOpen.hits.hits[0];
expect(signal._source.signal.threshold_result).eql({
Expand Down

0 comments on commit c95fbe5

Please sign in to comment.